main+lexer: add support for single-line comments
This commit is contained in:
parent
3f84890b52
commit
ab7ee592c3
2 changed files with 2 additions and 1 deletions
|
|
@ -38,7 +38,7 @@ def main():
|
||||||
print("Source:\n", data)
|
print("Source:\n", data)
|
||||||
tokens = Lexer(data)
|
tokens = Lexer(data)
|
||||||
|
|
||||||
tokens = [token for token in tokens if token.kind not in [Tokens.Blank, Tokens.Newline]]
|
tokens = [token for token in tokens if token.kind not in [Tokens.Blank, Tokens.Newline, Tokens.Comment]]
|
||||||
if rootLogger.level <= LogLevel.Debug:
|
if rootLogger.level <= LogLevel.Debug:
|
||||||
pprint(tokens)
|
pprint(tokens)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ class Tokens(enum.Enum):
|
||||||
Colon = re.compile(r":")
|
Colon = re.compile(r":")
|
||||||
Semicolon = re.compile(r";")
|
Semicolon = re.compile(r";")
|
||||||
Comma = re.compile(r",")
|
Comma = re.compile(r",")
|
||||||
|
Comment = re.compile(r"//.*")
|
||||||
|
|
||||||
Newline = re.compile(r"\n", flags=re.MULTILINE)
|
Newline = re.compile(r"\n", flags=re.MULTILINE)
|
||||||
EOF = re.compile(r"\Z")
|
EOF = re.compile(r"\Z")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue