Added support for various nlTokTypes and added multiple demos
This commit is contained in:
parent
e49b1d659b
commit
dff40e6b27
8 changed files with 43 additions and 13 deletions
1
README
1
README
|
|
@ -7,6 +7,7 @@ A personal little MATLAB alternative I suppose :)
|
||||||
In future I'd love to start using a developed TUI library like [textual](https://github.com/Textualize/textual?tab=readme-ov-file),
|
In future I'd love to start using a developed TUI library like [textual](https://github.com/Textualize/textual?tab=readme-ov-file),
|
||||||
but for now everything is just a custom ANSI wrapper thing.
|
but for now everything is just a custom ANSI wrapper thing.
|
||||||
|
|
||||||
|
Noether can compile to C or Nim via their respective backends.
|
||||||
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
|
|
|
||||||
3
lang/NOTES
Normal file
3
lang/NOTES
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Todo:
|
||||||
|
- [ ] Not currently sure how the lexer will interpret non-latin characters (make sure it handles all unicode)
|
||||||
|
- [ ] The lexer currently only handles a limited number of escape codes / whitespace characters
|
||||||
2
lang/demo/loop-space.no
Normal file
2
lang/demo/loop-space.no
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
loop:
|
||||||
|
print("Goodbye world!")
|
||||||
2
lang/demo/loop-tab-crlf.no
Normal file
2
lang/demo/loop-tab-crlf.no
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
loop:
|
||||||
|
print("Goodbye world!")
|
||||||
2
lang/demo/loop-tab.no
Normal file
2
lang/demo/loop-tab.no
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
loop:
|
||||||
|
print("Goodbye world!")
|
||||||
3
lang/demo/string.no
Normal file
3
lang/demo/string.no
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
"Goodbye World!"
|
||||||
|
'a'
|
||||||
|
'abc' # ERROR
|
||||||
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import noether/lex
|
import noether/lex
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
echo "Noether Lang - Extras"
|
echo "Noether Lang Extras v0.1.0 - nlx"
|
||||||
|
|
||||||
if paramCount() > 0:
|
if paramCount() > 0:
|
||||||
let filename = paramStr(1)
|
let filename = paramStr(1)
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,19 @@ type
|
||||||
TERM, # String \0 terminator
|
TERM, # String \0 terminator
|
||||||
WORD, # Alphanumeric token
|
WORD, # Alphanumeric token
|
||||||
SYMB, # Symbolic token
|
SYMB, # Symbolic token
|
||||||
LNFD, # Line-Feed
|
LNFD, # \r \n Line-Feed
|
||||||
WTSP, # Whitespace
|
WTSP, # ' ' \t Whitespace
|
||||||
LPAR, # (
|
LPAR, # ( Left Parenthesis
|
||||||
RPAR, # )
|
RPAR, # ) Right Parenthesis
|
||||||
LBRA, # {
|
LBRA, # { Left Brace
|
||||||
RBRA, # }
|
RBRA, # } Right Brace
|
||||||
LSQB, # [
|
LSQB, # [ Left Square Bracket
|
||||||
RSQB, # ]
|
RSQB, # ] Right Square Bracket
|
||||||
LANB, # <
|
# LANB, # < Left Angle Bracket
|
||||||
RANB, # >
|
# RANB, # > Right Angle Bracket
|
||||||
|
SQUO, # ' Single Quotation Marking
|
||||||
|
DQUO, # " Double Quotation Marking
|
||||||
|
GRVA, # ` Grave Accent
|
||||||
|
|
||||||
nlTok = object
|
nlTok = object
|
||||||
tokType*: nlTokType
|
tokType*: nlTokType
|
||||||
|
|
@ -67,13 +70,27 @@ proc getTokType(c: char): nlTokType =
|
||||||
case c:
|
case c:
|
||||||
of '\0':
|
of '\0':
|
||||||
result = nlTokType.TERM
|
result = nlTokType.TERM
|
||||||
of '\n':
|
of '\r', '\n':
|
||||||
result = nlTokType.LNFD
|
result = nlTokType.LNFD
|
||||||
of ' ':
|
of ' ', '\t':
|
||||||
result = nlTokType.WTSP
|
result = nlTokType.WTSP
|
||||||
of '(':
|
of '(':
|
||||||
result = nlTokType.LPAR
|
result = nlTokType.LPAR
|
||||||
of ')':
|
of ')':
|
||||||
result = nlTokType.RPAR
|
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:
|
else:
|
||||||
result = nlTokType.WORD
|
result = nlTokType.WORD
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue