Skip to content

Commit

Permalink
organize things. add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltasar Sánchez E committed May 7, 2023
1 parent 89bb18a commit bf4507b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
README

...tumbleweed...


runs on python

```sh
python plox/plox.py
```
6 changes: 4 additions & 2 deletions exp.lox
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(13 > (5 * 3 + 9));
123 != 12312 + (2.3 == 123) * 9.12
123 != 12312 + (2.3 == 123) * 9.12;
// asf asf
1+2-3*4/5 // saywha
print 1+2-3*4/5 ;// saywha
var X = 1 == 2 ? "help" : "we cool, no help";
print (10 + (true ? 5 : - 5));
File renamed without changes.
11 changes: 11 additions & 0 deletions interpreter.py → plox/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ def visitBinary(self, expr):
return l == r
#unreachable "return None"

def visitTernary(self, expr):
# assert isinstance(expr.comparison, ??? and somehow assert it's boolean
assert isinstance(expr.left, Expr)
assert isinstance(expr.right, Expr)

if self.evaluate(expr.comparison):
return self.evaluate(expr.left)
else:
return self.evaluate(expr.right)
# this feels a bit silly


def visit(self, expr):
print(f"\t!!Guessing what to do with {expr.__class__.__name__}")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion src.lox
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ var test =


"strings";
123;
print 123;
123.1233; // sample, should write a real program.
print 123+123;

0 comments on commit bf4507b

Please sign in to comment.