Skip to content

How to store information in a parse_tree::node #109

Answered by d-frey
mik30s asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, that should be possible. There are two options: First you could use the provided node class and simply store a different type in it. We do this here:

template<> struct selector< grammar::case_sensitive_string > : std::true_type
{
static void transform( std::unique_ptr< node >& n )
{
n = std::move( n->children.back() );
if( n->content().size() == 1 ) {
n->id = &typeid( one_tag );
}
else {
n->id = &typeid( string_tag );
}
}
};

That is the simple, but also limited way.

If you are looking for a more advanced solution, I recommend you write your …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by d-frey
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #109 on December 09, 2020 10:00.