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)
This commit is contained in:
parent
2af3000c2e
commit
4a8f44d23f
3 changed files with 10 additions and 9 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue