Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added indirection and typed exception for X::Backslash::UnrecognizedS…
…equence
  • Loading branch information
FROGGS committed Nov 27, 2012
1 parent e6e1585 commit aa635da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -3231,6 +3231,11 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
}

grammar Perl6::QGrammar is HLL::Grammar does STD {

method throw_unrecog_backslash_seq ($sequence) {
$*W.throw(self.MATCH(), <X Backslash UnrecognizedSequence>, :$sequence);
}

proto token escape {*}
proto token backslash {*}

Expand Down Expand Up @@ -3383,7 +3388,8 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {

role qq does b1 does c1 does s1 does a1 does h1 does f1 {
token stopper { \" }
token backslash:sym<misc> { {} [ (\W) | $<x>=(\w) <.sorry("Unrecognized backslash sequence: '\\" ~ $<x>.Str ~ "'")> ] }
token backslash:sym<unrec> { {} (\w) { self.throw_unrecog_backslash_seq: $/[0].Str } }
token backslash:sym<misc> { \W }

method tweak_q($v) { self.panic("Too late for :q") }
method tweak_qq($v) { self.panic("Too late for :qq") }
Expand Down
5 changes: 5 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -801,6 +801,11 @@ my class X::Sequence::Deduction is Exception {
method message() { 'Unable to deduce sequence' }
}

my class X::Backslash::UnrecognizedSequence does X::Syntax {
has $.sequence;
method message() { "Unrecognized backslash sequence: '\\$.sequence'" }
}

my class X::ControlFlow is Exception {
has $.illegal; # something like 'next'
has $.enclosing; # .... outside a loop
Expand Down

0 comments on commit aa635da

Please sign in to comment.