Simple (shit) working lexer via nlTokStream
Currently only tested on strings but its highly extendable if you modify the getTokType mapping of chars to their nlTokType
This commit is contained in:
parent
edf164df90
commit
3ce9390be4
8 changed files with 224 additions and 185 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import noether/lexer/tok
|
||||
import noether/lexer/tokstream
|
||||
|
||||
when isMainModule:
|
||||
|
|
@ -7,7 +8,10 @@ when isMainModule:
|
|||
if paramCount() > 0:
|
||||
let filename = paramStr(1)
|
||||
var tokStream = newTokStream(filename, isFile=true)
|
||||
for tok in toks(tokStream):
|
||||
|
||||
var tok: nlTok
|
||||
while tokStream.nextTok(tok):
|
||||
echo tok
|
||||
|
||||
else:
|
||||
echo "usage: nlx filename"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue