mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
feat: runtime boolean
This commit is contained in:
@ -93,7 +93,7 @@ class Parser:
|
||||
return self.current_token["type"]
|
||||
|
||||
def _is_literal(self):
|
||||
return self.current_token["type"] in ["NUMBER", "STRING", "FLOAT"]
|
||||
return self.current_token["type"] in ["NUMBER", "STRING", "FLOAT", "true", "false"]
|
||||
|
||||
# variable
|
||||
def variable_statement(self):
|
||||
@ -126,6 +126,8 @@ class Parser:
|
||||
|
||||
def literal(self):
|
||||
token_type = self.current_token["type"]
|
||||
if token_type == "true" or token_type == "false":
|
||||
return self.boolean_literal()
|
||||
if token_type == "NUMBER":
|
||||
return self.numberic_literal()
|
||||
if token_type == "STRING":
|
||||
@ -134,6 +136,18 @@ class Parser:
|
||||
return self.float_literal()
|
||||
raise Exception("Unexpected token: " + token_type)
|
||||
|
||||
def boolean_literal(self):
|
||||
if self.token_type() == "true":
|
||||
self.eat('true')
|
||||
value = "True"
|
||||
else:
|
||||
self.eat("false")
|
||||
value = "False"
|
||||
return {
|
||||
"type": 'BooleanLiteral',
|
||||
"value": value,
|
||||
}
|
||||
|
||||
def numberic_literal(self):
|
||||
token = self.eat('NUMBER')
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user