feat: runtime boolean

This commit is contained in:
Dan Chen
2024-03-21 16:59:35 +08:00
parent 5e2d68230b
commit 0c34fd260f
6 changed files with 86 additions and 11 deletions

View File

@ -7,10 +7,25 @@ specs = (
# Comments:
(re.compile(r"^//.*"), None),
# Symbols:
(re.compile(r"^\("), "("),
(re.compile(r"^\)"), ")"),
(re.compile(r"^\,"), ","),
(re.compile(r"^\{"), "{"),
(re.compile(r"^\}"), "}"),
(re.compile(r"^;"), ";"),
# Keywords:
(re.compile(r"^\blet\b"), "let"),
(re.compile(r"^\breturn\b"), "return"),
(re.compile(r"^;"), ";"),
(re.compile(r"^\bif\b"), "if"),
(re.compile(r"^\belse\b"), "else"),
(re.compile(r"^\bwhile\b"), "while"),
(re.compile(r"^\bfor\b"), "for"),
(re.compile(r"^\def\b"), "def"),
(re.compile(r"^\btrue\b"), "true"),
(re.compile(r"^\bfalse\b"), "false"),
# Floats:
(re.compile(r"^[-+]?[0-9]+\.[0-9]+"), "FLOAT"),
@ -27,13 +42,6 @@ specs = (
# Double-quoted strings
(re.compile(r"^\"[^\"]*\""), "STRING"),
# Symbols:
(re.compile(r"^\("), "("),
(re.compile(r"^\)"), ")"),
(re.compile(r"^\,"), ","),
(re.compile(r"^\{"), "{"),
(re.compile(r"^\}"), "}"),
)
class Tokenizer: