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

Commit

Permalink
Add \c[nn,nn,nn] form of character specification.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Feb 16, 2010
1 parent 7db921a commit 9bf03df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/HLL/Actions.pm
Expand Up @@ -168,6 +168,16 @@ method quote_escape:sym<chr>($/) {
make $<charspec>.ast;
}

method charname($/) {
make pir::chr($<integer>.ast);
}

method charnames($/) {
my $str := '';
for $<charname> { $str := $str ~ $_.ast; }
make $str;
}

method charspec($/) {
make pir::chr(string_to_int( $/, 10 ));
make $<charnames> ?? $<charnames>.ast !! pir::chr(string_to_int( $/, 10 ));
}
3 changes: 2 additions & 1 deletion t/nqp/46-charspec.t
Expand Up @@ -2,6 +2,7 @@

# check literals

say('1..1');
say('1..2');

say("\c111\c107 \c49");
say("\c[111,107,32,50]");

0 comments on commit 9bf03df

Please sign in to comment.