added structure & interpreter & lexer & first ast stucture
This commit is contained in:
54
src/Interpreter/Repo.py
Normal file
54
src/Interpreter/Repo.py
Normal file
@@ -0,0 +1,54 @@
|
||||
class Repo:
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.debug = True
|
||||
|
||||
# interpreter
|
||||
self.keywords = [
|
||||
# define keys
|
||||
'lib',
|
||||
'class',
|
||||
'func',
|
||||
# builtin functions
|
||||
'output',
|
||||
'input',
|
||||
'length',
|
||||
'range',
|
||||
# normal keywords
|
||||
'if',
|
||||
'elseif',
|
||||
'else',
|
||||
'pass',
|
||||
'in',
|
||||
# loops
|
||||
'while',
|
||||
'for',
|
||||
# access
|
||||
'public'
|
||||
]
|
||||
self.types = [
|
||||
'number',
|
||||
'string',
|
||||
'bool',
|
||||
'list',
|
||||
'dict',
|
||||
'emptyType',
|
||||
'void'
|
||||
]
|
||||
self.expr_chars = ['+', '-', '*', '/', '=']
|
||||
self.bool_expr_chars = ['<', '>', '!', '!=', '==', '>=', '<=']
|
||||
self.bool_values = ['true', 'false']
|
||||
self.format_chars = ['{', '}', '(', ')', ';', ':', ',']
|
||||
|
||||
# runtime
|
||||
self.error = None
|
||||
|
||||
def output_tokens(self, toks: list) -> None:
|
||||
if self.debug and len(toks) > 0:
|
||||
# outp_toks = []
|
||||
for tok in toks:
|
||||
# outp_toks.append({tok.value: tok.type})
|
||||
print({tok.value: tok.type})
|
||||
|
||||
# print(outp_toks)
|
||||
print('\n')
|
Reference in New Issue
Block a user