SmaCC: Returning annotation from a production #4103
-
|
Is it possible to return That is, I would like to return |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 7 replies
-
|
@j-brant Please correct my understanding... There's no returning just That is, each token in a production becomes a field. The only control I can exercise here is to annotated the tokens and name the AST node ( |
Beta Was this translation helpful? Give feedback.
-
|
If |
Beta Was this translation helpful? Give feedback.
-
|
Why return tokens like brackets, comma, etc. from a production? |
Beta Was this translation helpful? Give feedback.
-
|
You can return anything from a production. For example, you can return |
Beta Was this translation helpful? Give feedback.
-
|
If you don't name the token, then they are excluded by default from being AST node. The code blocks are explained somewhat here: https://books.pharo.org/booklet-Smacc/ |
Beta Was this translation helpful? Give feedback.
-
|
I thought that tokens would be excluded but... results in Shouldn't P.S. I'm not using |
Beta Was this translation helpful? Give feedback.
-
|
Can you post your grammar? It works for me: This generates a |
Beta Was this translation helpful? Give feedback.
-
|
By the way, I tried removing the repo cloning it after restarting GT. I still get the extra token instance variables. |
Beta Was this translation helpful? Give feedback.
-
|
I started with a fresh copy of GT and cloned my repo. I still get the extra tokens as instance variables. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.


Your grammar has
%annotate_tokens;