« Return to Thread: Grammar for parsing regular expression

Re: Grammar for parsing regular expression

by Randall Schulz :: Rate this Message:

Reply to Author | View in Thread

On Wednesday April 15 2009, Krzysztof Langner wrote:
> Yes you are right. I forgot that in java you put regex in strings. In
> action script RE syntax is:
>
> myVariable = /abc/i
>
> So even this syntax is valid:
> myVariable = /"/

As in Groovy.


> The problem is that it is similar to math expressions like 2/3/4.
> Because of it I can't define it as TOKEN (and have problems with
> strings too).

You will never, ever be able to write a lexeme / token definition (a
regular expression) to recognize the syntax of regular expressions.
Parsing regular expressions requires a push-down automata, owing to the
balanced, nestable constructs such as parentheses and (in certain
dialects) character classes and its use of infix operators (i.e.,
alternation).

So you can save yourself time and energy by accepting the fundamental
fact that REs cannot be parsed by REs.


> ...
>
> Thank you
> Krzysztof


Randall Schulz

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Grammar for parsing regular expression