-
Notifications
You must be signed in to change notification settings - Fork 3
Migration: Remove translator and directly interpret Python AST (#51) #65
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
Draft
lucasnyc
wants to merge
12
commits into
main
Choose a base branch
from
migration/remove_translator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7dcd393
to
3d82c5c
Compare
* Updated index.ts with runPyAST (Python AST -> CSE) * py_interpreter.ts in CSE (to replace interpreter.ts in the future) * PyRunCSEMachine in pyRunner.ts * added local.test.ts to gitignore * naming convention for files/functions to replace old logic will start with "Py" -- to be renamed after full migration
3d82c5c
to
5a3f1ac
Compare
* new files: py_visitor, py_utils, py_operators - to support needs for py_visitor for now, usage of any for loose type checks for now * py-interpreter - replaced dummy with PyVisitor * py_visitor - rework visit*expr to work with ExprNS and FileInputStmt * py_utils - reworked operandTranslator to work with TokenType * py_operators - reworked to change es.UnaryOperator to TokenType
* Updated compilerOptions in tsconfig.json - target: es2016 -> es2020 Reason: support for bigInt(0n) * stash.ts - Reintroduce Value to be passed to visitors in pyvisitor Updates: Failed lol, major changes that affects stdlib in src Temp solution: fallback to Value : any in /cse-machine/stash.ts for now * py_operators.ts - introduce bool for integers, string, None (evaluteUnaryExpression) * py_operator.ts refactored {evaluateBinaryExpression} - cleaner sequence Operands: String -> Complex -> Mixed Float&/Int (arithmetic -> comparisons) -> Integers only * py_visitor.ts: added visitComplexExpr
* tokenizer.ts - bug fix for TokenType.NOT to prevent crash * py-visitor.ts - Added visitCompareExpr, visitBoolOpExpr, visitVariableExpr and visitNoneExpr * py-operators.ts - refined not oprator logic to handle truthiness - added specific errors for module and power operators with to handle lhs or rhs operand of 0
* super small commit haha * conductor/runner/types/PyEvaluator.ts - Updated with PyRunInContext, no change to the rest * index.ts - Introduced PyRunInContext that is replacement for runInContext * a small reminder: frigging initialise the PyEvaluator (UNCOMMENT) for local testingssssss
…[6] * New Files: py_context.ts, py_control.ts, py_instrCreator.ts, py_types.ts Note: No logic change, only adaptation of pynodes and instr * index.ts, pyrunner - Adjusted execution path and adaptaion of pycontext, pycontrol * py_interpreter - Overhauled to support control and instr * changes 1
* py_types -added BoolOpInstr * py_instrcreator - added boolOpInstr * py_interpreter - added handler for boolop, none, variable,
* tsconfig.json: added ignoreDeprecations to for backward compatibility with moduleresolution * new files: py_environment * Introduced for simple handling of variable declarations TODO: undeclared variable error
d5b7e4f
to
6bd1db6
Compare
* src/types.ts - updated Representation as call toPythonString is redundant * py_interpreter - removed mapOperatorToPyOperator, update binary and compare * py_operators - updated evaluateUnaryExpression, evaluateBinaryExpression, PyCompare * minor fix for the pythonMod, pyGetVariable
* minor fix for integer division on bigints
* new files: errors/ - py_errors, py_runtimeSourceError * replace temporary error handlign with propery runtimeHandler * moved interpreter core functions * TODO: other errors as needed when new handlers are introduced *
ff60494
to
5de0365
Compare
* removed translator.ts, not used anymore * removed regression.test, the test is mainly for translator * removed py_visitor - failed attempt for migration
5de0365
to
c8cb9fb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR begins work on Issue #51 removing the translator layer and directly interpreting Python AST in the CSE machine.
Currently, the interpreter converts Python AST into an intermediate JavaScript AST before evaluation. While functional, this extra step increases complexity and diverges from how a Python interpreter normally behaves.
Goals:
estree
library