Added support for various nlTokTypes and added multiple demos

This commit is contained in:
Emile Clark-Boman 2025-06-17 13:08:21 +10:00
parent e49b1d659b
commit dff40e6b27
8 changed files with 43 additions and 13 deletions

View file

@ -2,7 +2,7 @@ import os
import noether/lex
when isMainModule:
echo "Noether Lang - Extras"
echo "Noether Lang Extras v0.1.0 - nlx"
if paramCount() > 0:
let filename = paramStr(1)

View file

@ -10,16 +10,19 @@ type
TERM, # String \0 terminator
WORD, # Alphanumeric token
SYMB, # Symbolic token
LNFD, # Line-Feed
WTSP, # Whitespace
LPAR, # (
RPAR, # )
LBRA, # {
RBRA, # }
LSQB, # [
RSQB, # ]
LANB, # <
RANB, # >
LNFD, # \r \n Line-Feed
WTSP, # ' ' \t Whitespace
LPAR, # ( Left Parenthesis
RPAR, # ) Right Parenthesis
LBRA, # { Left Brace
RBRA, # } Right Brace
LSQB, # [ Left Square Bracket
RSQB, # ] Right Square Bracket
# LANB, # < Left Angle Bracket
# RANB, # > Right Angle Bracket
SQUO, # ' Single Quotation Marking
DQUO, # " Double Quotation Marking
GRVA, # ` Grave Accent
nlTok = object
tokType*: nlTokType
@ -67,13 +70,27 @@ proc getTokType(c: char): nlTokType =
case c:
of '\0':
result = nlTokType.TERM
of '\n':
of '\r', '\n':
result = nlTokType.LNFD
of ' ':
of ' ', '\t':
result = nlTokType.WTSP
of '(':
result = nlTokType.LPAR
of ')':
result = nlTokType.RPAR
of '{':
result = nlTokType.LBRA
of '}':
result = nlTokType.RBRA
of '[':
result = nlTokType.LSQB
of ']':
result = nlTokType.RSQB
of '\'':
result = nlTokType.SQUO
of '\"':
result = nlTokType.DQUO
of '`':
result = nlTokType.GRVA
else:
result = nlTokType.WORD