Skip to content

Commit

Permalink
Add ⁇ ‼ operator
Browse files Browse the repository at this point in the history
  • Loading branch information
FCO committed Mar 2, 2017
1 parent 9d497e9 commit eac7181
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Perl6/Grammar.nqp
Expand Up @@ -1783,6 +1783,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token term:sym<value> { <value> }
token term:sym<unquote> { '{{{' <?{ $*IN_QUASI }> <statementlist> '}}}' }
token term:sym<!!> { '!!' <?before \s> } # actual error produced inside infix:<?? !!>
token term:sym<> { '‼' <?before \s> } # actual error produced inside infix:<⁇ ‼>
token term:sym<> { <sym> }

token term:sym<::?IDENT> {
Expand Down Expand Up @@ -4249,8 +4250,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token prefix:sym<-> { <sym> <O(|%symbolic_unary)> }
token prefix:sym<> { <sym> <O(|%symbolic_unary)> }
token prefix:sym<??> { <sym> <.dupprefix('??')> <O(|%symbolic_unary)> }
token prefix:sym<?> { <sym> <!before '??'> <O(|%symbolic_unary)> }
token prefix:sym<!> { <sym> <!before '!!'> <O(|%symbolic_unary)> }
token prefix:sym<?> { <sym> <!before '⁇' || '??'> <O(|%symbolic_unary)> }
token prefix:sym<> { <sym> <.dupprefix('')> <O(|%symbolic_unary)> }
token prefix:sym<!> { <sym> <!before '‼' || '!!'> <O(|%symbolic_unary)> }
token prefix:sym<|> { <sym> <O(|%symbolic_unary)> }
token prefix:sym<+^> { <sym> <O(|%symbolic_unary)> }
token prefix:sym<~^> { <sym> <O(|%symbolic_unary)> }
Expand Down Expand Up @@ -4406,6 +4408,22 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
<O(|%conditional, :reducecheck<ternary>, :pasttype<if>)>
}

token infix:sym<⁇ ‼> {
:my $*GOAL := '‼';
$<sym>='⁇'
<.ws>
<EXPR('i=')>
[ '‼'
|| <?before '::' <.-[=]>> { self.typed_panic: "X::Syntax::ConditionalOperator::SecondPartInvalid", second-part => "::" }
|| <?before ':' <.-[=\w]>> { self.typed_panic: "X::Syntax::ConditionalOperator::SecondPartInvalid", second-part => ":" }
|| <infixish> { self.typed_panic: "X::Syntax::ConditionalOperator::PrecedenceTooLoose", operator => ~$<infixish> }
|| <?{ ~$<EXPR> ~~ / '‼' / }> { self.typed_panic: "X::Syntax::ConditionalOperator::SecondPartGobbled" }
|| <?before \N*? [\n\N*?]? '‼'> { self.typed_panic: "X::Syntax::Confused", reason => "Confused: Bogus code found before the ‼ of conditional operator" }
|| { self.typed_panic: "X::Syntax::Confused", reason => "Confused: Found ⁇ but no ‼" }
]
<O(|%conditional, :reducecheck<ternary>, :pasttype<if>)>
}

token infix_prefix_meta_operator:sym<!> {
<sym> <![!]> {} [ <infixish('neg')> || <.panic: "Negation metaoperator not followed by valid infix"> ]
[
Expand Down

0 comments on commit eac7181

Please sign in to comment.