Navigation Menu

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

Commit

Permalink
More quoting escapes, better handling of quote constructs.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 20, 2009
1 parent 725c893 commit 86d5495
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/HLL/Actions.pm
Expand Up @@ -82,9 +82,13 @@ method quote_delimited($/) {
method quote_atom($/) {
make $<escape> ?? $<escape>.ast !! ~$/;
}

method escape:sym<backslash>($/) { make "\\"; }
method escape:sym<stopper>($/) { make ~$<stopper> }

method escape:sym<nl>($/) { make "\n"; }
method escape:sym<bs>($/) { make "\b"; }
method escape:sym<bs>($/) { make "\b"; }
method escape:sym<nl>($/) { make "\n"; }
method escape:sym<cr>($/) { make "\r"; }
method escape:sym<tab>($/) { make "\t"; }

method escape:sym<hex>($/) {
Expand All @@ -95,7 +99,6 @@ method escape:sym<oct>($/) {
make ints_to_string( $<octint> ?? $<octint> !! $<octints><octint> );
}


sub string_to_int($src, $base) {
Q:PIR {
.local pmc src
Expand Down
24 changes: 16 additions & 8 deletions src/HLL/Grammar.pm
Expand Up @@ -56,14 +56,22 @@ grammar HLL::Grammar;
}

proto token escape { <...> }
token escape:sym<backslash> { \\ \\ }
token escape:sym<bs> { \\ b }
token escape:sym<oct> { \\ o [ <octint> | '[' <octints> ']' ] }
token escape:sym<hex> { \\ x [ <hexint> | '[' <hexints> ']' ] }
token escape:sym<chr> { \\ c <charspec> }
token escape:sym<nl> { \\ n }
token escape:sym<cr> { \\ r }
token escape:sym<tab> { \\ t }
token escape:sym<backslash> { \\ \\ <?quotemod_check('q')> }
token escape:sym<stopper> { \\ <?quotemod_check('q')> <stopper> }

token escape:sym<bs> { \\ b <?quotemod_check('b')> }
token escape:sym<nl> { \\ n <?quotemod_check('b')> }
token escape:sym<cr> { \\ r <?quotemod_check('b')> }
token escape:sym<tab> { \\ t <?quotemod_check('b')> }
token escape:sym<hex> {
\\ x <?quotemod_check('b')>
[ <hexint> | '[' <hexints> ']' ]
}
token escape:sym<oct> {
\\ o <?quotemod_check('b')>
[ <octint> | '[' <octints> ']' ]
}
token escape:sym<chr> { \\ c <?quotemod_check('b')> <charspec> }

token charname {
|| <integer>
Expand Down

0 comments on commit 86d5495

Please sign in to comment.