Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Allow hyphen and single-quotes in NQP identifiers.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Jun 24, 2010
1 parent 9157c78 commit f0bed9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/NQP/Grammar.pm
Expand Up @@ -14,7 +14,7 @@ method TOP() {

## Lexer stuff

token identifier { <ident> }
token identifier { <.ident> [ <[\-']> <.ident> ]* }

token name { <identifier> ** '::' }

Expand Down Expand Up @@ -582,7 +582,7 @@ grammar NQP::Regex is Regex::P6Regex::Grammar {
}

token assertion:sym<name> {
$<longname>=[\w+]
<longname=.identifier>
[
| <?before '>'>
| '=' <assertion>
Expand Down
9 changes: 6 additions & 3 deletions t/nqp/31-grammar.t
Expand Up @@ -2,11 +2,13 @@

# Test grammars and regexes

plan(4);
plan(6);

grammar ABC {
token TOP { ok ' ' <integer> }
token integer { \d+ }
token TOP2 { ok ' ' <int-num> }
token int-num { \d+ }
}

my $match := ABC.parse('not ok');
Expand All @@ -19,6 +21,7 @@ ok( ?$match, 'parse method works on positive match');

ok( $match<integer> == 123, 'captured $<integer>');

$match := ABC.parse('ok 123', :rule<TOP2> );
ok( ?$match, 'parse method works with :rule');



ok( $match<int-num> == 123, 'captured $<int-num>');

0 comments on commit f0bed9b

Please sign in to comment.