Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[generate-ceval-switch] GH-98831: "Generate" the interpreter (GH-98830) #65

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Tools/cases_generator/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def to_text(tkns: list[Token], dedent: int = 0) -> str:
return ''.join(res)


if __name__ == "__main__":
def main():
import sys
filename = sys.argv[1]
if filename == "-c":
Expand All @@ -255,3 +255,7 @@ def to_text(tkns: list[Token], dedent: int = 0) -> str:
# print(to_text(tokenize(src)))
for tkn in tokenize(src, filename=filename):
print(tkn)


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion Tools/cases_generator/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def members(self):
return None


if __name__ == "__main__":
def main():
import sys
filename = sys.argv[1]
with open(filename) as f:
Expand All @@ -146,3 +146,7 @@ def members(self):
parser = Parser(src, filename)
x = parser.inst_def()
print(x)


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion Tools/cases_generator/plexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def make_syntax_error(self, message: str, tkn: Token|None = None) -> SyntaxError
self.filename, tkn.line, tkn.column, self.extract_line(tkn.line))


if __name__ == "__main__":
def main():
import sys
if sys.argv[1:]:
filename = sys.argv[1]
Expand All @@ -102,3 +102,7 @@ def make_syntax_error(self, message: str, tkn: Token|None = None) -> SyntaxError
left = repr(tok)
right = lx.to_text([tok]).rstrip()
print(f"{left:40.40} {right}")


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion Tools/cases_generator/sparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def decl(self, type: Node):
return VarDecl(type, name, None)


if __name__ == "__main__":
def main():
import sys
if sys.argv[1:]:
filename = sys.argv[1]
Expand Down Expand Up @@ -333,3 +333,7 @@ def decl(self, type: Node):
print(x)
print("=== === ===")
print("OK")


if __name__ == "__main__":
main()