I want to implement color highlighting of input string that is being fed to given spirit grammar. Is there an easy (or any, if not easy) way to map given character from input into rule/ast type that it matches? Preferable in form of array/vector of rule/ast types where index is index of character of input string. Or maybe better - iterator rages to ast types.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Correctly parse PDF paragraphs with Python
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- How do I get from a type to the TryParse method?
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
Of course there is. Several answers on this site demonstrate similar things. You'll have to decide how you want to treat subrules.
A random example using
on_success
:Live On Coliru
Prints
Uncommenting the extra
You get: Live On Coliru
More
A more funky example would be How to provider user with autocomplete suggestions for given boost::spirit grammar? - where
string_view
orstring_ref
is being used instead ofiterator_range
. Also, that "collapses" adjacent ranges to result in more usable ranges.Other related examples: