Subject: [boost] [spirit] scan_keyword: scan an InputIterator for a keyword.
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-11-28 16:45:31
for chrono input I'm using a scan_keyword function that adapted from
libc++ library (you can find the code in).
Next follows the interface:
// Scans [b, e) until a match is found in the basic_strings range
// [kb, ke) or until it can be shown that there is no match in [kb, ke).
// b will be incremented (visibly), consuming CharT until a match is found
// or proved to not exist. A keyword may be "", in which will match
// If one keyword is a prefix of another, and the next CharT in the input
// might match another keyword, the algorithm will attempt to find the
// matching keyword. If the longer matching keyword ends up not
// no keyword match is found. If no keyword match is found, ke is returned
// and failbit is set in err.
// Else an iterator pointing to the matching keyword is found. If more
// one keyword matches, an iterator to the first matching keyword is
// If on exit b == e, eofbit is set in err.
// Keywords: "a", "abb"
// If the input is "a", the first keyword matches and eofbit is set.
// If the input is "abc", no match is found and "ab" are consumed.
template <class InputIterator, class ForwardIterator>
scan_keyword(InputIterator& b, InputIterator e,
ForwardIterator kb, ForwardIterator ke,
What is the better way to do that (or something similar) with Spirit/Lexer?
Can we hope that the Spirit solution could perform much better?
What about if the strings to parse are know at compile-time?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk