-
Given a rule like this: Is there an easy way to have string<...> discarded from the input from input.string()?
This would make building up an AST quite a bit easier. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The usual trick is to apply the action only to the part you are interested in:
and then specialize your action for Does this work for you? |
Beta Was this translation helpful? Give feedback.
-
Good trick, I could have thought of that myself... ps: you have any plans for making building an AST more convenient, similar to the return values offered by bison? pps: great project. It's definitely more convenient to use PEGTL than to either wire up flex and bison with C++ and build management or to pull in the beast that is boost::spirit. |
Beta Was this translation helpful? Give feedback.
-
Glad it helped :) Re: ps: In fact we are planning on adding a generic AST builder to the PEGTL in the future, together with some other enhancements. I'm not sure which specific form it will take, so I can not compare it to Bison or anything else yet. It might take some time though, as we are currently busy finishing some new project (https://github.com/taocpp/json) which is using the PEGTL to parse JSON. And there are other things in the pipeline as well and, as usual, not enough time. Re: pps: Thank you! |
Beta Was this translation helpful? Give feedback.
The usual trick is to apply the action only to the part you are interested in:
and then specialize your action for
module_identifier
. The additionalstruct
is used to make sure the action is only applied for this case, not for other uses ofidentifier
.Does this work for you?