Closed pierrewtLanca closed 2 years ago
There are some some differences between the AST generated by this parser and the AST in Python proper. Concerning the Compare
objects, it groups the ops
and comparators
together into one field comparators
, but has no ops
field. Here is the relevant portion of code if that is of any help:
class Compare(pos: Int, left: Expression, comparators: Array[(BinOp.Value, Expression)])
When I wrote the parser I clearly had error checking in mind and did not bother to generate an AST that is fully compatible with Python's—after all, Python already delivered that, anyway. In other words, generating a compliant AST was never a goal of the project.
Context: TigerPython is used in a Vue project. I am calling the parser to get the python AST of some small code portions.
When the parser finds a comparison, the returned expression object contains a
left
property that I can access. However, thecomparators
andops
properties cannot be accessed, because I get the following error : "Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.r"