Commit Graph

551 Commits

Author SHA1 Message Date
greg
f88f115567 Environment persistent across repl loop 2017-09-19 22:10:53 -07:00
greg
08f1092b69 Variable lookup works
Note this introduces a panic - if the AST node inserted into the
environment is not reduced, it throws an error when trying to look it up
2017-09-19 22:10:53 -07:00
greg
6ddea790c0 Beginning of variable lookup
everything is null
2017-09-19 22:10:53 -07:00
greg
6897eb1283 Implemented variable binding 2017-09-19 22:10:53 -07:00
greg
34fdf2be00 Add machinery for evaluation environments 2017-09-19 22:10:53 -07:00
greg
4ef93fafb5 Cause tokenize error for unclosed strings 2017-09-19 22:10:53 -07:00
greg
d2108f0f97 First pass at evaluation
Very incomplete
2017-09-19 22:10:52 -07:00
greg
2989ac338c Implemented binop parsing
Uses Operator-precedence parsing algorithm, which I don't fully
understand.
2017-09-19 22:10:52 -07:00
greg
8b6d54aec2 Fix let clause parsing
let a = x, x should be expression not just simple expression
2017-09-19 22:10:52 -07:00
greg
cdb47bb3b9 Add paren parsing 2017-09-19 22:10:52 -07:00
greg
9d6dc5a5f2 Tokenize periods separately 2017-09-19 22:10:52 -07:00
greg
71d2428e57 Update Grammar 2017-09-19 22:10:52 -07:00
greg
8f9bfbc5bd Rename rhs to simple_expression 2017-09-19 22:10:52 -07:00
greg
c9fdd5e83c Simplified statements-parsing
Still a little wonky wrt extraneous Separators, need to adjust grammar
to fix I think
2017-09-19 22:10:52 -07:00
greg
30eddf7737 while statements 2017-09-19 22:10:52 -07:00
greg
42719dc2f2 Change 'input' to 'tokens'
just to be consistent
2017-09-19 22:10:52 -07:00
greg
8fcc850d77 Added else clause to if parsing 2017-09-19 22:10:52 -07:00
greg
f421918945 basic if expression 2017-09-19 22:10:52 -07:00
greg
0e4469fa58 Filled out keyword tokenizing 2017-09-19 22:10:52 -07:00
greg
edf100b583 Starting to do if statement parsing 2017-09-19 22:10:52 -07:00
greg
169e662049 Collapse Separator tokens
only ever gonna be one in a row
2017-09-19 22:10:52 -07:00
greg
46999beabf Added skeleton of expression() parser 2017-09-19 22:10:52 -07:00
greg
1342a76786 Added support for interpreter directives 2017-09-19 22:10:52 -07:00
greg
05238bced3 rhs production 2017-09-19 22:10:52 -07:00
greg
a97cce184c Empty program is valid too 2017-09-19 22:10:52 -07:00
greg
1ae61287c1 Editing Grammar
to indicate what portion of it is now parsed
2017-09-19 22:10:52 -07:00
greg
329c521964 Parsing statement blocks works 2017-09-19 22:10:52 -07:00
greg
bfa16fd6fb Added Keyword lexical class 2017-09-19 22:10:52 -07:00
greg
25f5188d8c Move definition around 2017-09-19 22:10:52 -07:00
greg
5213dd327f Change type to peekable 2017-09-19 22:10:52 -07:00
greg
cea29094cd type alias for Tokens 2017-09-19 22:10:52 -07:00
greg
67eafba97a Put expect into early return macro 2017-09-19 22:10:52 -07:00
greg
1059a88ee6 Separate parsing into module 2017-09-19 22:10:52 -07:00
greg
429ace73bd Move tokenizing into separate module 2017-09-19 22:10:52 -07:00
greg
044e7a6a26 Rename ASTNode -> AST
saves typing
2017-09-19 22:10:52 -07:00
greg
dbdae42c1b Add string to AST 2017-09-19 22:10:52 -07:00
greg
fc3dcf792d Start writing recursive descent parser
I think I get the idea now
2017-09-19 22:10:52 -07:00
greg
02b34ca105 Wrote expect()
Hopefully correctly?
2017-09-19 22:10:52 -07:00
greg
1e9cd551a6 Add grammar of language to repo
Preliminary, work in progress
2017-09-19 22:10:52 -07:00
greg
9f4330889a Starting parsing work 2017-09-19 22:10:52 -07:00
greg
3058af4f05 Break on ctrl-D 2017-09-19 22:10:52 -07:00
greg
4f17d5a0dc Add number tokenizing 2017-09-19 22:10:52 -07:00
greg
8e3774ffca Comma as separate token 2017-09-19 22:10:52 -07:00
greg
c6059ada7d Separators and parens
Separator = ; or \n, they are equivalent
2017-09-19 22:10:52 -07:00
greg
b5ee45f639 null is also a keyword 2017-09-19 22:10:51 -07:00
greg
04f53b6beb Added some grammar sketch ideas to the readme 2017-09-19 22:10:51 -07:00
greg
2aaa600d53 More tokenizer stuff 2017-09-19 22:10:51 -07:00
greg
c6a92728ee Scaffolding for evaluation function 2017-09-19 22:10:51 -07:00
greg
b2e23bed86 Print tokens and parse 2017-09-19 22:10:51 -07:00
greg
3fdacf018e Basic repl 2017-09-19 22:10:51 -07:00