Match a Complex Regexp

20 views
Skip to first unread message

Ronald

unread,
Aug 23, 2011, 10:58:04 PM8/23/11
to Treetop Development
Hi all,

I need check use the follow Regexp in my grammar:

^( [^a]|a[^q]|aq[^u]|aqu[^i])+

But when I use like:

rule test
[^( [^a]|a[^q]|aq[^u]|aqu[^i])+]
end

I got the errror: `ruby_source_from_string': Expected one of +, *,
#, .., ?, / at line 20 etc.

How can I use this ?


thanks

Christian Rishøj Jensen

unread,
Aug 25, 2011, 5:06:18 AM8/25/11
to treet...@googlegroups.com

On Aug 24, 2011, at 4:58 AM, Ronald wrote:

> I need check use the follow Regexp in my grammar:
>
> ^( [^a]|a[^q]|aq[^u]|aqu[^i])+
>
> But when I use like:
>
> rule test
> [^( [^a]|a[^q]|aq[^u]|aqu[^i])+]
> end
>
> I got the errror: `ruby_source_from_string': Expected one of +, *,
> #, .., ?, / at line 20 etc.

The square brackets in treetop are used to introduce a character class (see http://www.regular-expressions.info/charclass.html).

It seems you are trying to fit a whole regular expression in there.

Try something along the lines of:

rule test


( [^a] "|a" [^q] "|aq" [^u] "|aqu" [^i] )+
end

(Note: Not tested)

Christian

Reply all
Reply to author
Forward
0 new messages