|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
'Expansion within (..)* can be matched by empty string' problemHey guys,
I am working on a parser for a mini version of Java. Anyways, I get this error rather often : "Expansion within (..)* can be matched by empty string ". I would like to know why. Does Javacc not accept For the below code, it generates the error at (stm=Stm())*. I can't see what's wrong with this. String StmList(): { String output = ""; String stm = ""; } { output = "{" (stm = Stm())* "}" { output += stm ; } { return output; } } String Stm(): { String output=""; } { ( LOOKAHEAD ( "while" "(" Exp() ")" PriStm() ) output = WhileStm() | LOOKAHEAD ("if" "(" Exp() ")" PriStm() "else" PriStm() ) output = IfElseStm() | output = PriStm() ) { return output; } } Thanks for the help! ![]() |
|
|
Re: 'Expansion within (..)* can be matched by empty string' problemThe fact that the effective RegExp looks like (a*)* such that an input of 'b' would match blank an infinite number of times is what it's complaining about I think.
On Fri, Aug 14, 2009 at 10:43 PM, happYboi <ber_lim25@...> wrote:
-- - J.Chris Findlay (c: |
|
|
Re: 'Expansion within (..)* can be matched by empty string' problemThanks for the reply,
Maybe you could show what you mean through a simple example? As I do not really get what you were trying to say. Thanks
|
|
|
Re: 'Expansion within (..)* can be matched by empty string' problemThe error is that the ()* expansion, meaning zero or more of its contents, contains something that can be matched by the blank string, which means zero or more potentially zero length strings, which is impossible to resolve as there are an infinite number of ways to make it match, and searching for the longest match would result in an infinite loop.
Examine the expression inside the ()* and make sure it can't be matched by blank. On Sun, Aug 16, 2009 at 8:18 PM, happYboi <ber_lim25@...> wrote:
-- - J.Chris Findlay (c: |
|
|
Re: 'Expansion within (..)* can be matched by empty string' problemThanks a lot for the explanation. Everything is working now.
|
| Free embeddable forum powered by Nabble | Forum Help |