kabel/kabel.py

76 lines
1.6 KiB
Python

#!/usr/bin/env python3
import sys, enum
class ModuleType(enum.Enum):
Basic =
Thruster = enum.auto()
Hub = enum.auto()
class TokenType(enum.Enum):
Declarator = enum.auto()
Arithmetic = enum.auto()
Literal = enum.auto()
Variable = enum.auto()
KEYWORDS = [
"if", # if
"to", # function definition
"using", # arg introducers
"by", # "
"with", # "
"foreach", # for
"it" # iterator
]
STATEMENT_CLASSIFIERS = [
"if",
"to",
"foreach"
]
KEYWORDS_ACCEPT = {
"if":
}
mem = {
"w": [], # Current word being processed
"stno": 0, # Number of statement being processed
"next": 0,
"if":
"cvl": 0, # Convolution level (paren depth)
}
program = []
with open(sys.argv[1]) as f:
prg = f.read().split(";")
def lexer(prg):
for statement in prg: # For statement in program
mem["stno"] = 0
mem["w"] = ""
for char in list(statement):
if char == " " && !mem[""]:
# On spaces or new lines, begin a new word
mem["w"] = ""
continue
else if char == "(":
cvl
else:
mem["w"] += char
#match mem["w"]:
# case "if":
# # Now parsing an if statement
# mem["if"]["active"] = True
# case
if mem["w"] in STATEMENT_CLASSIFIERS:
# Activate mode specified by word
# If mem["w"] is 'if', enable if mode
mem[mem["w"]]["active"] = True