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

Commit

Permalink
Browse files Browse the repository at this point in the history
Add \e in quoted strings, refactor 46-charspec.t .
  • Loading branch information
pmichaud committed Jun 3, 2010
1 parent 38fc6e9 commit 5fb2d58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/HLL/Actions.pm
Expand Up @@ -186,6 +186,7 @@ method quote_escape:sym<nl>($/) { make "\n"; }
method quote_escape:sym<cr>($/) { make "\r"; }
method quote_escape:sym<tab>($/) { make "\t"; }
method quote_escape:sym<ff>($/) { make "\c[12]"; }
method quote_escape:sym<esc>($/) { make "\c[27]"; }

method quote_escape:sym<hex>($/) {
make ints_to_string( $<hexint> ?? $<hexint> !! $<hexints><hexint> );
Expand Down
1 change: 1 addition & 0 deletions src/HLL/Grammar.pm
Expand Up @@ -85,6 +85,7 @@ grammar HLL::Grammar;
token quote_escape:sym<cr> { \\ r <?quotemod_check('b')> }
token quote_escape:sym<tab> { \\ t <?quotemod_check('b')> }
token quote_escape:sym<ff> { \\ f <?quotemod_check('b')> }
token quote_escape:sym<esc> { \\ e <?quotemod_check('b')> }
token quote_escape:sym<hex> {
\\ x <?quotemod_check('b')>
[ <hexint> | '[' <hexints> ']' ]
Expand Down
10 changes: 6 additions & 4 deletions t/nqp/46-charspec.t
Expand Up @@ -2,8 +2,10 @@

# check literals

say('1..3');
plan(4);

say("\c111\c107 \c49");
say("\c[111,107,32,50]");
say("\c[LATIN SMALL LETTER O, LATIN SMALL LETTER K, SPACE, DIGIT THREE]");
ok("\c111\c107 \c49" eq 'ok 1', '\c###');
ok("\c[111,107,32,50]" eq 'ok 2', '\c[##,##,##]');
ok("\c[LATIN SMALL LETTER O, LATIN SMALL LETTER K, SPACE, DIGIT THREE]" eq 'ok 3', '\c[name,name]');

ok("\e" eq "\c[27]", '\e');

0 comments on commit 5fb2d58

Please sign in to comment.