Commit (unimplemented) parser & AST
This commit is contained in:
parent
f3c604631b
commit
12c200b13f
6 changed files with 30 additions and 3 deletions
1
src/TODO_READ_THIS_SHITRN_OMG
Normal file
1
src/TODO_READ_THIS_SHITRN_OMG
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
rename nlTok.tokType to nlTok.tType
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import std/streams
|
import std/streams
|
||||||
import std/options
|
import std/options
|
||||||
|
|
||||||
include tokens
|
include tok
|
||||||
|
|
||||||
type
|
type
|
||||||
# Character streaming for the nlTokStream
|
# Character streaming for the nlTokStream
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ type
|
||||||
SQUO, # ' Single Quotation Marking
|
SQUO, # ' Single Quotation Marking
|
||||||
DQUO, # " Double Quotation Marking
|
DQUO, # " Double Quotation Marking
|
||||||
GRVA, # ` Grave Accent
|
GRVA, # ` Grave Accent
|
||||||
|
HASH, # # Number Sign (Hashtag)
|
||||||
|
|
||||||
nlTok = object
|
nlTok = object
|
||||||
tokType*: nlTokType
|
tokType*: nlTokType
|
||||||
|
|
@ -92,5 +93,7 @@ proc getTokType(c: char): nlTokType =
|
||||||
result = nlTokType.DQUO
|
result = nlTokType.DQUO
|
||||||
of '`':
|
of '`':
|
||||||
result = nlTokType.GRVA
|
result = nlTokType.GRVA
|
||||||
|
of '#':
|
||||||
|
result = nlTokType.HASH
|
||||||
else:
|
else:
|
||||||
result = nlTokType.WORD
|
result = nlTokType.WORD
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
include lstream
|
include lstream
|
||||||
|
|
||||||
import os # TEMP import
|
|
||||||
|
|
||||||
type
|
type
|
||||||
# Provides a stream-like interface for lexing nlToks
|
# Provides a stream-like interface for lexing nlToks
|
||||||
# Internally reliant on the functionality of nlLStream
|
# Internally reliant on the functionality of nlLStream
|
||||||
|
|
|
||||||
7
src/noether/parser/arborist.nim
Normal file
7
src/noether/parser/arborist.nim
Normal 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()
|
||||||
18
src/noether/parser/nodes.nim
Normal file
18
src/noether/parser/nodes.nim
Normal 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()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue