From 4a8f44d23f17a628a96efc438fcc3eaa8cb72b93 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Thu, 19 Jun 2025 02:23:54 +1000 Subject: [PATCH] Fixed parseStmt called on uninitialized nlParser.ast Also parseStmt now discards nlTokKind.tkEOL (this shouldn't be left in long term, just a temporary solution) --- src/noether.nim | 2 +- src/noether/parser/nodes.nim | 2 -- src/noether/parser/parser.nim | 15 +++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/noether.nim b/src/noether.nim index 509b123..83c2b1b 100644 --- a/src/noether.nim +++ b/src/noether.nim @@ -2,4 +2,4 @@ # uses this file as the main entry point of the application. when isMainModule: - echo "Noether Lang" + echo "Noether Lang v0.1.0" diff --git a/src/noether/parser/nodes.nim b/src/noether/parser/nodes.nim index a50eee0..bd737c6 100644 --- a/src/noether/parser/nodes.nim +++ b/src/noether/parser/nodes.nim @@ -42,6 +42,4 @@ proc newBiNode*(nKind: nlNodeKind): nlNode = # Short-hand way of appending a token to a node's token sequence proc addTok*(node: nlNode, tok: nlTok) = - echo node[] - echo node.toks node.toks.add(tok) diff --git a/src/noether/parser/parser.nim b/src/noether/parser/parser.nim index 4654fb3..dcdcc06 100644 --- a/src/noether/parser/parser.nim +++ b/src/noether/parser/parser.nim @@ -24,28 +24,31 @@ proc parseStmt(parser: var nlParser): nlParseStat = # initialise build node as none just for the hell of it while parser.stream.progress(): - echo parser.stream.currTok + echo "Current Token: ", parser.stream.currTok case parser.stream.currTok.tKind of tkDQUO: # Attempt to parse string literal if parser.parseStrLit() != nlParseStat.OK: echo "Unmatched Double Quotation! Malformed String Literal" echo parser.stream.line - echo repeat(" ", parser.stream.currTok.startPos), '^' + echo repeat(" ", parser.stream.currTok.startPos), '^', '\n' else: echo "Parsed String Literal" - echo parser.bnode[] + echo parser.bnode[], '\n' of tkSQUO: # Attempt to parse string literal if parser.parseChrLit() != nlParseStat.OK: echo "Unmatched Single Quotation! Malformed Character Literal" echo parser.stream.line - echo repeat(" ", parser.stream.currTok.startPos), '^' + echo repeat(" ", parser.stream.currTok.startPos), '^', '\n' else: echo "Parsed Character Literal" - echo parser.bnode[] + echo parser.bnode[], '\n' + of tkEOL: + # TODO: handle this case, don't just discard + discard else: - echo "blah blah unhandled case" + echo "blah blah unhandled case\n" result = nlParseStat.OK # Attempt to parse nlAST from nlTokStream