feat: runtime boolean

This commit is contained in:
Dan Chen
2024-03-21 16:59:35 +08:00
parent 5e2d68230b
commit 0c34fd260f
6 changed files with 86 additions and 11 deletions

View File

@ -69,12 +69,14 @@ class Runtime:
return int(ast.get("value"))
elif ast.get("type") == "FloatLiteral":
return float(ast.get("value"))
elif ast.get("type") == "BooleanLiteral":
return bool(ast.get("value"))
def _is_identifier(self, ast):
return ast["type"] == "Identifier"
def _is_literal(self, ast):
return ast["type"] in ["NumericLiteral", "StringLiteral", "FloatLiteral"]
return ast["type"] in ["NumericLiteral", "StringLiteral", "FloatLiteral", "BooleanLiteral"]
def exec_return(self, ast):
v = ast.get("value")