
George Petasis wrote:
Actually, xpressive throws an exception:
xpressive error: error_stack: There was insufficient memory to determine whether the regular expression could match the specified character sequence. (12)
Any ideas on that? can I increase the stack size under windows?
That's some grammar! I'm amazed you actually got it to compile. :-P As you've already figured out, you're blowing your stack. I can see some ways to simplify your grammar, but I think your best bet would be to switch to a parser generator like Boost.Spirit. Xpressive's exhaustive backtracking behavior makes it use stack space more greedily than Spirit. If you want to try sticking with Xpressive, here are some things to try: - Increasing your program's stack size. You're using MSVC? See the /STACK switch for the linker. - Avoid using by_ref(a_sregex) where it's not really necessary. For instance, you have lots of regexes like this:
s_scl__com_ = (as_xpr(","));
s_scl__pvl_ = (as_xpr("-"));
s_scl__sls_ = (as_xpr("/"));
Embedded regexes use more stack space and incur a perf hit that you wouldn't get if you had used ordinary strings for this instead. - Use keep() for the parts of your grammar that do not need exhaustive backtracking semantics. keep(<some regex>) matches <some regex> and then reclaims the stack space used by <some regex>. But then <some regex> can only match in one way, and no alternatives are tried. - If you have patterns like (string1 | string2 | string3 ...) where stringN are simple string literals, you're better off using a symbol parser (assuming you're using xpressive 2.0). See http://tinyurl.com/2rd5d7. Best of luck! -- Eric Niebler Boost Consulting www.boost-consulting.com