greg
d804efdc5e
Use BinOp type instead of strings
2017-09-19 22:10:59 -07:00
greg
5911a07f4f
Inline parsing of lambdas like half-works
2017-09-19 22:10:59 -07:00
greg
26bc6e90f3
Lamba calls partially work
2017-09-19 22:10:59 -07:00
greg
b0655d7cab
need to flush stdout for printing
2017-09-19 22:10:59 -07:00
greg
a46ede9395
Made evaluation-printing more sophisticated
2017-09-19 22:10:59 -07:00
greg
9b74527618
Control printing eval steps with flags
2017-09-19 22:10:59 -07:00
greg
298194c42d
Finish support for assignment operators
2017-09-19 22:10:59 -07:00
greg
23d2209d8b
Implementing a few more operators
...
WIP - not done
2017-09-19 22:10:59 -07:00
greg
4cf165b408
Use buffered reader for stdout
...
Not sure ifthis is actually helping
2017-09-19 22:10:59 -07:00
greg
154839979b
Add nicer handle_builtin method
2017-09-19 22:10:59 -07:00
greg
538f0b18f4
Evaluate while loop
2017-09-19 22:10:59 -07:00
greg
dc81d237c5
Reduce re-allocations in eval
2017-09-19 22:10:58 -07:00
greg
e888e82404
Remove some unnecessary destructurings of Rc<String>
2017-09-19 22:10:58 -07:00
greg
328ec4ba87
Convertd like half the Strings to RC
...
-still need to eliminate some clones in eval, parse
+ fix all the tests
2017-09-19 22:10:58 -07:00
greg
8ebf1b3056
Add parser support for while statements
2017-09-19 22:10:58 -07:00
greg
905431b33c
Change name: ASTNode -> Statement
2017-09-19 22:10:58 -07:00
greg
2996198eff
lookup_binding only needs &str
2017-09-19 22:10:58 -07:00
greg
06771979df
Function bodies can contain statements now
2017-09-19 22:10:58 -07:00
greg
f158b6c712
Converted to multiple-evaluator logic
...
Now I have (basically) full single-step evaluation and it works fine
2017-09-19 22:10:58 -07:00
greg
872e9ce7ee
Make function binding a SideEffect
2017-09-19 22:10:58 -07:00
greg
edf342e65a
Add == operator
2017-09-19 22:10:58 -07:00
greg
6794d22f1d
Run rustfmt on eval.rs, parser.rs
2017-09-19 22:10:58 -07:00
greg
1858d26638
Add comparison operators
...
+ make operator evaluation more concise
2017-09-19 22:10:58 -07:00
greg
84fbe73cf6
Add Lambda type
...
And change name FuncNode -> FuncDefNode
Now function definition nodes reduce to a Lambda, which is not
reducible.
2017-09-19 22:10:58 -07:00
greg
82c52ede48
Finish evaluating conditionals
2017-09-19 22:10:57 -07:00
greg
7f52b20d97
Conditional eval partway implemented
...
Need to change the AST representation to support compound statements I
think
2017-09-19 22:10:57 -07:00
greg
12fee6158c
Vector'd expressions don't need to be boxed
2017-09-19 22:10:57 -07:00
greg
9cc9c5977d
Fixed evaluation of function calls
...
This bit still isn't quite small-step but maybe that's okay for
functions
2017-09-19 22:10:57 -07:00
greg
ed9d1312d1
Change representation of variables
2017-09-19 22:10:57 -07:00
greg
29d9e50311
All environment changes represented explicitly
...
Start the work of rewriting the evluator to be a true small-step
evaluator - that is, all state changes are represented explicitly as
SideEffect types, and not as methods called on the evaluator, except at
the very top of the evaluation loop
2017-09-19 22:10:57 -07:00
greg
af45004afa
Run rustfmt on some files
2017-09-19 22:10:57 -07:00
greg
db52f9b716
Package compilation context into one struct
2017-09-19 22:10:57 -07:00
greg
a01b6c874e
Small-step function arg evaluation
2017-09-19 22:10:57 -07:00
greg
907af38f44
Evaluate printing
2017-09-19 22:10:57 -07:00
greg
8528c912bd
Added side effect framework
2017-09-19 22:10:57 -07:00
greg
0e3aaa8b08
Add conditional expression support
2017-09-19 22:10:56 -07:00
greg
f33cfdadfe
Fix variable lookup order
...
Evaluator uses frames as a stack, so to find the most-recent variable
binding we have to iterate through it the reverse way. This fixes a bug
manifested by:
fn a(x)
x + 20
end
fn b(x)
a(x) + 20
end
2017-09-19 22:10:56 -07:00
greg
f014c1a9d9
Kill compiler warnings
2017-09-19 22:10:56 -07:00
greg
c36bc3377e
Fix lookup_binding in function call case
2017-09-19 22:10:56 -07:00
greg
5eba222679
Variable binding in fucntion call work
2017-09-19 22:10:56 -07:00
greg
dcf89aa429
Move lookup_function back onto Evaluator
...
THe problem was that we were borrowing the output of the inner HashMap,
if we clone it we don't borrow anything
2017-09-19 22:10:56 -07:00
greg
1ffbeb6472
Return last value out of function
2017-09-19 22:10:56 -07:00
greg
f8a521fc9b
Start making function calls work
...
This commit isn't fully done yet
2017-09-19 22:10:56 -07:00
greg
77f72806be
Add support for multiple frames
2017-09-19 22:10:56 -07:00
greg
dcde5d6018
Start function call reduction
...
Move the varmap and funcmap functions to the Evaluator, to mkae it
easier to facilitate separate frames
2017-09-19 22:10:56 -07:00
greg
6bb227d052
Rename methods
...
make reduce() the entry point to evaluation
2017-09-19 22:10:56 -07:00
greg
29d4cb53a4
Add infrastructure to do function evaluation
...
Right now you can successfully evaluate a function definition (returning
Null), but cannot call a function
2017-09-19 22:10:56 -07:00
greg
3915c1f035
Remove println from reduction
2017-09-19 22:10:56 -07:00
greg
b400796e4d
Get rid of test variable input
2017-09-19 22:10:56 -07:00
greg
96e6a87f64
Add string concat
2017-09-19 22:10:56 -07:00