diff --git a/source/main.d b/source/main.d index faf1253..8a48c36 100644 --- a/source/main.d +++ b/source/main.d @@ -2,25 +2,29 @@ module main; import parsing.tokenizer.tokens; import parsing.tokenizer.make_tokens; +import tern.typecons.common : Nullable, nullable; +import parsing.treegen.scopeParser; +import parsing.treegen.tokenRelationships; +import std.stdio; void main() { - // Token[] tokens = tokenizeText(" - // int x, y; - // x = 5; - // y = 1; - // x = 3; - // void x, y; - // int tv = x++ + y; - // float floaty = tv / 2; - // int xx; - // int xxx; - // "); - // import tern.typecons.common : Nullable, nullable; - // import parsing.treegen.scopeParser; - // import parsing.tokenizer.make_tokens; - // size_t index = 0; - // auto scope_ = tokens.parseMultilineScope(index, nullable!ScopeData(null)); - // import std.stdio; - // scope_.declaredVariables.writeln; + size_t index = 0; + + auto newScope = parseMultilineScope(FUNCTION_SCOPE_PARSE, " + + + + string axolotl, frog = `Hello world` * 2 + 1; + int constant = 69 /* nice!!! */ ; + ".tokenizeText(), index, nullable!ScopeData(null)); + foreach (instruction; newScope.instructions) + { + instruction.tree; + } + "\n\nDeclared variables: ".writeln; + foreach (var; newScope.declaredVariables) + { + var.writeln; + } } diff --git a/source/parsing/treegen/astTypes.d b/source/parsing/treegen/astTypes.d index 1a5c1e3..32177fc 100644 --- a/source/parsing/treegen/astTypes.d +++ b/source/parsing/treegen/astTypes.d @@ -203,7 +203,8 @@ class AstNode } sink("}"); } - + void tree() => tree(-1); + void tree(size_t tabCount) { import std.stdio; diff --git a/source/parsing/treegen/expressionParser.d b/source/parsing/treegen/expressionParser.d index 9d1d280..fdfca1e 100644 --- a/source/parsing/treegen/expressionParser.d +++ b/source/parsing/treegen/expressionParser.d @@ -64,7 +64,7 @@ public AstNode[] phaseOne(Token[] tokens) if (old_index != index) index--; } - else if (token.tokenVariety == TokenType.Number) + else if (token.tokenVariety == TokenType.Number || token.tokenVariety == TokenType.Quotation) { tokenToBeParsedLater.action = AstAction.LiteralUnit; tokenToBeParsedLater.literalUnitCompenents = [token];