Commit (unimplemented) parser & AST

This commit is contained in:
Emile Clark-Boman 2025-06-17 14:00:58 +10:00
parent f3c604631b
commit 12c200b13f
6 changed files with 30 additions and 3 deletions

View file

@ -0,0 +1 @@
rename nlTok.tokType to nlTok.tType

View file

@ -1,7 +1,7 @@
import std/streams
import std/options
include tokens
include tok
type
# Character streaming for the nlTokStream

View file

@ -23,6 +23,7 @@ type
SQUO, # ' Single Quotation Marking
DQUO, # " Double Quotation Marking
GRVA, # ` Grave Accent
HASH, # # Number Sign (Hashtag)
nlTok = object
tokType*: nlTokType
@ -92,5 +93,7 @@ proc getTokType(c: char): nlTokType =
result = nlTokType.DQUO
of '`':
result = nlTokType.GRVA
of '#':
result = nlTokType.HASH
else:
result = nlTokType.WORD

View file

@ -1,7 +1,5 @@
include lstream
import os # TEMP import
type
# Provides a stream-like interface for lexing nlToks
# Internally reliant on the functionality of nlLStream

View file

@ -0,0 +1,7 @@
# Attempt to form an nlAST from a nlTokStream
proc arborise(tokStream: nlTokStream): nlNode =
for tok in toks(tokStream):
case tok.tokType:
of nlTokType.DQUO:
# Attempt to parse string literal
parse_strl()

View file

@ -0,0 +1,18 @@
from ../lexer/tok import nlTok
from ../lexer/tokstraem import
type
# NOTE: by the end of parsing NO nodes should
# NOTE: have nlNodeType.NONE
nlNodeType = enum
NONE, # Placeholder Value
TERM, # Indicates the tree has terminated
STRL, # String Literal
CHRL, # Character Literal
nlNode {.acyclic.} = ref object of RootObj
nType: nlNodeType
toks: seq[nlTok] # nodes store the tokens that build them
left, right: nlNode
proc parse()