Initial commit - fix problems & refactor code
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from core.tokens import (
|
||||
SpecialForm,
|
||||
BinaryOperator,
|
||||
BinaryPredicate
|
||||
)
|
||||
from core.primitives.symbol import symbol
|
||||
|
||||
def parseToken(token: str):
|
||||
for en in [SpecialForm, BinaryOperator, BinaryPredicate]:
|
||||
if token in en:
|
||||
return en(token)
|
||||
if token in ['true', 'false']:
|
||||
return token == 'true'
|
||||
try:
|
||||
return int(token)
|
||||
except ValueError:
|
||||
if token == 'inf':
|
||||
return symbol(token)
|
||||
try:
|
||||
return float(token)
|
||||
except ValueError:
|
||||
return symbol(token)
|
||||
Reference in New Issue
Block a user