diff --git a/source/tlang/compiler/parsing/core.d b/source/tlang/compiler/parsing/core.d index b399593..1098a55 100644 --- a/source/tlang/compiler/parsing/core.d +++ b/source/tlang/compiler/parsing/core.d @@ -781,6 +781,25 @@ public final class Parser return bruh; } + + /** + * Only a subset of expressions are parsed without coming after + * an assignment, functioncall parameters etc + * + * Therefore instead of mirroring a lot fo what is in expression, for now atleast + * I will support everything using discard + * + * TODO: Remove discard and implement the needed mirrors + */ + private Expression parseDiscard() + { + /* Consume the `discard` */ + nextToken(); + + return parseExpression(); + } + + /** * Parses an expression * @@ -963,7 +982,7 @@ public final class Parser /* Get the identifier */ string identifier = getCurrentToken().getToken(); nextToken(); - + Expression toAdd; @@ -1444,6 +1463,13 @@ public final class Parser /* Add the struct definition to the program */ modulle.addStatement(ztruct); } + /* If it is a `discard` statement */ + else if(symbol == SymbolType.DISCARD) + { + Expression expression = parseDiscard(); + + modulle.addStatement(expression); + } else { expect("parse(): Unknown '" ~ tok.getToken() ~ "'"); diff --git a/source/tlang/compiler/symbols/check.d b/source/tlang/compiler/symbols/check.d index b985b47..9e47719 100644 --- a/source/tlang/compiler/symbols/check.d +++ b/source/tlang/compiler/symbols/check.d @@ -27,6 +27,7 @@ public enum SymbolType NEW, IF, ELSE, + DISCARD, WHILE, CLASS, INHERIT_OPP, @@ -313,6 +314,11 @@ public SymbolType getSymbolType(Token tokenIn) { return SymbolType.NEW; } + /* discard keyword */ + else if(cmp(token, "discard") == 0) + { + return SymbolType.DISCARD; + } /* An identifier/type (of some sorts) - further inspection in parser is needed */ else if(isPathIdentifier(token) || isIdentifier(token)) {