|
Boost : |
Subject: Re: [boost] [spirit] scan_keyword: scan an InputIterator for a keyword.
From: Joel de Guzman (joel_at_[hidden])
Date: 2011-11-28 18:47:31
On 11/29/2011 5:45 AM, Vicente J. Botet Escriba wrote:
> Hi,
>
> for chrono input I'm using a scan_keyword function that adapted from libc++ library (you
> can find the code in[1]).
> Next follows the interface:
>
[snip]
>
> 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?
>
> [1] https://svn.boost.org/svn/boost/trunk/boost/chrono/detail/scan_keyword.hpp
The symbol parser seems to be your friend here. http://tinyurl.com/7vue9nu
The search is O(log n+k) using a TST.
Spirit parses at runtime, not compile time. I've seen a compile time
parser for compile-time strings posted somewhere in this list, but
I don't recall exactly.
Regards,
-- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk