You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since with lark-generated parser, it seems difficult to obtain a satisfactory AST without manually-crafted classes, this generated a bit of redundancy in #868.
Specifically, the Q1ASM instructions are listed twice: in the grammar,
However, the AST classes are more powerful, since they can even host metadata (e.g. storing documentation), that could be useful in runtime usage (e.g. declared clock cycles).
So, at this point, it seems to be worth to resolve the redundancy the other way round: generate the grammar from the classes.
This could be done by loading the string with placeholders, and replacing the placeholders at runtime from the generated classes.
It is only needed during parser creation. So, it's not going to be limiting even when parsing many scripts (if ever), since it will be done once (it could have been done even at "compile time", if Python had a compilation process - but it's not worth to introduce something like a compilation step just for the sake of this, as it would considerably affect the workflow).
The text was updated successfully, but these errors were encountered:
Since with lark-generated parser, it seems difficult to obtain a satisfactory AST without manually-crafted classes, this generated a bit of redundancy in #868.
Specifically, the Q1ASM instructions are listed twice: in the grammar,
qibolab/src/qibolab/_core/instruments/qblox/q1asm.lark
Lines 15 to 18 in 906da93
and in the AST classes
qibolab/src/qibolab/_core/instruments/qblox/ast_.py
Lines 52 to 71 in 906da93
However, the AST classes are more powerful, since they can even host metadata (e.g. storing documentation), that could be useful in runtime usage (e.g. declared clock cycles).
So, at this point, it seems to be worth to resolve the redundancy the other way round: generate the grammar from the classes.
This could be done by loading the string with placeholders, and replacing the placeholders at runtime from the generated classes.
It is only needed during parser creation. So, it's not going to be limiting even when parsing many scripts (if ever), since it will be done once (it could have been done even at "compile time", if Python had a compilation process - but it's not worth to introduce something like a compilation step just for the sake of this, as it would considerably affect the workflow).
The text was updated successfully, but these errors were encountered: