dot is not expr.expr, it's expr.ident

This commit is contained in:
Michael Zhang 2021-06-09 02:48:37 -05:00
parent 5dd92c99fe
commit ac37c8d491
2 changed files with 8 additions and 4 deletions

View file

@ -29,6 +29,7 @@ class Equation:
def __init__(self, lhs: Expr, rhs: Expr):
self.lhs = lhs
self.rhs = rhs
def __repr__(self) -> str: return f"{self.lhs} = {self.rhs}"
class Variant:
def __init__(self, prod: List[Sym], equations: List[Equation]):
@ -43,7 +44,7 @@ class Node(Decl):
self.variants = variants
class ExprDot(Expr):
def __init__(self, left: Expr, right: Expr):
def __init__(self, left: Expr, right: str):
self.left = left
self.right = right
def __repr__(self) -> str: return f"{self.left}.{self.right}"
@ -101,7 +102,7 @@ class Parser(Transformer[List[Decl]]):
def equation(self, items: List[Expr]) -> Equation: return Equation(items[0], items[1])
# expr
def expr_dot(self, items: List[Expr]) -> Expr:
def expr_dot(self, items: List[Any]) -> Expr:
[left, right] = items
return ExprDot(left, right)
def expr_add(self, items: List[Expr]) -> Expr:
@ -112,7 +113,10 @@ class Parser(Transformer[List[Decl]]):
return ExprMul(left, right)
def expr_call(self, items: List[Expr]) -> Expr:
[func, args] = items
return ExprMul(func, args)
# TODO: args should be a list of exprs -_ -
return ExprCall(func, [args])
def expr_name(self, items: List[str]) -> Expr:
return ExprName(items[0])
def sep_trail(self, items: List[Tree]) -> List[T]:
return list(map(lambda it: cast(T, it), items))

View file

@ -29,7 +29,7 @@ equation_: equation ";"
// called lvalue, and should NOT include literals
equation: expr "=" expr
expr: expr_dot
?expr: expr_dot
| expr_add
| expr_mul
| expr_call