Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Parse::RecDescent - Any Way to do a Negation?

by ajwans (Scribe)
on Mar 14, 2002 at 02:52 UTC ( [id://151585]=note: print w/replies, xml ) Need Help??


in reply to Parse::RecDescent - Any Way to do a Negation?

Masem is correct, use the reject keyword.

XXX: YYY | 'something' 'else' | 'a' <reject> | 'this string' <reject> | ZZZ <reject> YYY: 'some string' ZZZ: 'ww' | 'xx' | 'yy' | 'zz'
This will cause the parse to fail for this branch, be careful that your grammar is not set up so that there are alternate paths to parse the string and your
$parser->start ($string);
will fail.

"Don't you hate it when people quote themselves?" - me

Replies are listed 'Best First'.
Re: Re: Parse::RecDescent - Any Way to do a Negation?
by Incognito (Pilgrim) on Mar 14, 2002 at 03:46 UTC
    I'll give it a try, but we're actually trying to do this:
    YYY && ! ('a' | 'b' | ZZZ) | 'something else'
    So shouldn't this be the syntax?
    XXX: YYY ('a' | 'b' | ZZZ) <reject> | 'something' 'else' YYY: 'some string' ZZZ: 'ww' | 'xx' | 'yy' | 'zz'
    I'm not really sure if this is valid but I'll give it a try for now.

    It's pretty confusing actually, because another Production I'd like to write is:

    NonTerminator: SourceCharacter but not LineTerminator
    So this is my first attempt:
    NonTerminator: SourceCharacter | SourceCharacter LineTerminator <reject>
    Anyone think this is correct? or is it:
    NonTerminator: SourceCharacter LineTerminator <reject>
    somehow I do not think the second one is correct...

    Does the <reject> apply to the entire line or just the item that it follows?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://151585]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found