Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generalize quote escapes to include starter
This means that q< \< > parses and correcly produces " < "
(Whereas q< < > is a parse error due to unmatched openers and closers,
 and whereas q< \< > used to produce " \\< ")
  • Loading branch information
Mouq committed Apr 19, 2014
1 parent 612d0f0 commit 17f4ee3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -7046,7 +7046,7 @@ class Perl6::QActions is HLL::Actions does STDActions {
method escape:sym<\\>($/) { make $<item>.ast; }
method backslash:sym<qq>($/) { make $<quote>.ast; }
method backslash:sym<\\>($/) { make $<text>.Str; }
method backslash:sym<stopper>($/) { make $<text>.Str; }
method backslash:delim ($/) { make $<text>.Str; }
method backslash:sym<miscq>($/) { make '\\' ~ ~$/; }
method backslash:sym<misc>($/) { make ~$/; }

Expand Down
9 changes: 6 additions & 3 deletions src/Perl6/Grammar.nqp
Expand Up @@ -3995,7 +3995,7 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
token escape:sym<\\> { <sym> {} <item=.backslash> }
token backslash:sym<qq> { <?[q]> <quote=.LANG('MAIN','quote')> }
token backslash:sym<\\> { <text=.sym> }
token backslash:sym<stopper> { <text=.stopper> }
token backslash:delim { <text=.starter> | <text=.stopper> }
token backslash:sym<a> { <sym> }
token backslash:sym<b> { <sym> }
token backslash:sym<c> { <sym> <charspec> }
Expand Down Expand Up @@ -4124,13 +4124,14 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
}

role q {
token starter { \' }
token stopper { \' }

token escape:sym<\\> { <sym> <item=.backslash> }

token backslash:sym<qq> { <?[q]> <quote=.LANG('MAIN','quote')> }
token backslash:sym<\\> { <text=.sym> }
token backslash:sym<stopper> { <text=.stopper> }
token backslash:delim { <text=.starter> | <text=.stopper> }

token backslash:sym<miscq> { {} . }

Expand All @@ -4139,6 +4140,7 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
}

role qq does b1 does c1 does s1 does a1 does h1 does f1 {
token starter { \" }
token stopper { \" }
token backslash:sym<unrec> { {} (\w) { self.throw_unrecog_backslash_seq: $/[0].Str } }
token backslash:sym<misc> { \W }
Expand Down Expand Up @@ -4197,6 +4199,7 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
}

role cc {
token starter { \' }
token stopper { \' }

method ccstate ($s) {
Expand Down Expand Up @@ -4228,7 +4231,7 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
}
token escape:ch { $<ch> = [\S] <.ccstate($<ch>.Str)> }

token backslash:stopper { <text=.stopper> }
token backslash:delim { <text=.starter>|<text=.stopper> }
token backslash:a { :i <sym> }
token backslash:b { :i <sym> }
token backslash:c { :i <sym> <charspec> }
Expand Down

0 comments on commit 17f4ee3

Please sign in to comment.