Implement extern
#130
Labels
Looking for assignee
Looking to contribute? Browse these.
required feature
Feature or behavior in OQ3 spec, needs implementation
For example this fails to parse without errors, although it is valid OQ3.
extern f(int x);
Implementing
extern
requires several steps, as do most or all language features. However there is a model that you can follow closely at every step.AST
Add
Extern
to this (alphabetized) listopenqasm3_parser/crates/oq3_syntax/openqasm3.ungram
Line 74 in ea3ab9c
Make an entry like the following for
Extern
openqasm3_parser/crates/oq3_syntax/openqasm3.ungram
Lines 155 to 158 in ea3ab9c
It will be just about the same as the entry for
Def
, but of course, the block will be absent.Add
EXTERN
to ast_src.rs in the same list whereDEF
appears:openqasm3_parser/crates/oq3_syntax/src/tests/ast_src.rs
Line 149 in ea3ab9c
Generate code with
If this fails, you might ask in this issue for help.
Def
:openqasm3_parser/crates/oq3_syntax/src/ast/generated/nodes.rs
Lines 150 to 167 in ea3ab9c
These methods will be called from
syntax_to_semantics.rs
to translate the AST to ASG.openqasm3_parser/crates/oq3_parser/src/grammar/items.rs
Line 92 in ea3ab9c
substituting
extern
fordef
. Andopenqasm3_parser/crates/oq3_parser/src/grammar/items.rs
Lines 339 to 357 in ea3ab9c
ASG
Follow this model:
openqasm3_parser/crates/oq3_semantics/src/asg.rs
Line 180 in ea3ab9c
openqasm3_parser/crates/oq3_semantics/src/asg.rs
Lines 622 to 628 in ea3ab9c
AST -> ASG
Follow this model:
openqasm3_parser/crates/oq3_semantics/src/syntax_to_semantics.rs
Lines 368 to 390 in ea3ab9c
Done
And it's as easy as that! Now enjoy parsing
extern
statements !The text was updated successfully, but these errors were encountered: