Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl 6 - How to combine two negates charachter classes in a grammar

by holli (Monsignor)
on Mar 24, 2010 at 12:57 UTC ( #830548=perlquestion: print w/ replies, xml ) Need Help??
holli has asked for the wisdom of the Perl Monks concerning the following question:

Suppose I have
use v6; grammar G { token not_a { <-[ a ]> } token not_b { <-[ b ]> } }
How do i implement a token neither_a_nor_b
as a composition of not_a
and not_b
?


holli

You can lead your users to water, but alas, you cannot drown them.

Comment on Perl 6 - How to combine two negates charachter classes in a grammar
Select or Download Code
Replies are listed 'Best First'.
Re: Perl 6 - How to combine two negates charachter classes in a grammar
by moritz (Cardinal) on Mar 24, 2010 at 13:17 UTC

    Just like in Perl 5 you can use look-aheads:

    token neither_a_nor_b { <?before <not_a>> <?before <not_b>> . }

    If you define your define your character classes positively, you can also combine them directly:

    token a { <[ a ]> } token b { <[ b ]> } token neither_a_nor_b { <-a-b> }

    (don't know if anybody implements that, though.

    Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://830548]
Approved by rovf
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-07-30 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls