added structure & interpreter & lexer & first ast stucture

This commit is contained in:
edraft
2020-05-22 22:08:37 +02:00
commit ed97118df0
22 changed files with 481 additions and 0 deletions

54
src/Interpreter/Repo.py Normal file
View 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')