added block expression
This commit is contained in:
@@ -91,7 +91,7 @@ class VariableUsage:
|
||||
|
||||
@dataclass
|
||||
class Expression:
|
||||
expression: Union[LiteralInt, LiteralFloat, FunctionCall, VariableUsage, Operation]
|
||||
expression: Union[LiteralInt, LiteralFloat, FunctionCall, "Block", VariableUsage, Operation]
|
||||
type: TypeUsage
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ boring_grammar = r"""
|
||||
| variable_usage
|
||||
| function_call
|
||||
| "(" expression ")"
|
||||
| block
|
||||
|
||||
let_statement : "let" identifier "=" expression ";"
|
||||
| "let" identifier ":" type_usage "=" expression ";"
|
||||
|
||||
@@ -139,6 +139,10 @@ class TypeChecker:
|
||||
if self.with_function_call(env, type_env, subexpression):
|
||||
changed = True
|
||||
return changed
|
||||
if isinstance(subexpression, parse.Block):
|
||||
if self.with_block(env, type_env, subexpression):
|
||||
changed = True
|
||||
return changed
|
||||
if isinstance(subexpression, parse.VariableUsage):
|
||||
if self.with_variable_usage(env, type_env, subexpression):
|
||||
changed = True
|
||||
|
||||
Reference in New Issue
Block a user