From 8e6c0bbbfc6cd312530e5bea5e2d9ef209e8b28d Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Thu, 19 Jun 2025 02:33:13 +1000 Subject: [PATCH] Fixed StrLit + ChrLit matching beyond EOL, also greed excludes satisfier --- src/noether/parser/parser.nim | 8 +++----- src/noether/parser/parseutil.nim | 8 +++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/noether/parser/parser.nim b/src/noether/parser/parser.nim index dcdcc06..7da349f 100644 --- a/src/noether/parser/parser.nim +++ b/src/noether/parser/parser.nim @@ -15,16 +15,14 @@ proc parseMatchLine(parser: var nlParser, matchType: nlTokKind): nlParseStat = ) proc parseStrLit(parser: var nlParser): nlParseStat = - result = parser.parseMatch(tkDQUO) + result = parser.parseMatchLine(tkDQUO) proc parseChrLit(parser: var nlParser): nlParseStat = - result = parser.parseMatch(tkSQUO) + result = parser.parseMatchLine(tkSQUO) proc parseStmt(parser: var nlParser): nlParseStat = - # initialise build node as none just for the hell of it - while parser.stream.progress(): - echo "Current Token: ", parser.stream.currTok + echo "----- Current Token: ", parser.stream.currTok case parser.stream.currTok.tKind of tkDQUO: # Attempt to parse string literal diff --git a/src/noether/parser/parseutil.nim b/src/noether/parser/parseutil.nim index 386b03a..8b9ef20 100644 --- a/src/noether/parser/parseutil.nim +++ b/src/noether/parser/parseutil.nim @@ -50,18 +50,20 @@ proc newParser*(tokStream: var nlTokStream): nlParser = proc greed(parser: var nlParser, satisfy: proc(tok: nlTok): bool): nlParseStat = while parser.stream.progress(): - parser.bnode.addTok(parser.stream.currTok) if satisfy(parser.stream.currTok): return nlParseStat.OK + # NOTE: the matched token is currently excluded + parser.bnode.addTok(parser.stream.currTok) result = nlParseStat.UNMATCHED proc greedLine(parser: var nlParser, satisfy: proc(tok: nlTok): bool): nlParseStat = while parser.stream.progress(): - parser.bnode.addTok(parser.stream.currTok) if satisfy(parser.stream.currTok): return nlParseStat.OK - elif parser.stream.currTok.tKind == tkEOL: + # NOTE: the matched token is currently excluded + parser.bnode.addTok(parser.stream.currTok) + if parser.stream.currTok.tKind == tkEOL: return nlParseStat.UNMATCHED result = nlParseStat.UNMATCHED