From 8ff0e0a21533ec555b234c18a7a989e6d64ba794 Mon Sep 17 00:00:00 2001 From: Stephen Weeks Date: Thu, 14 May 2009 22:32:12 -0600 Subject: [PATCH] Add support for defining circumfix operators. --- src/parser/actions.pm | 1 + src/parser/grammar.pg | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/parser/actions.pm b/src/parser/actions.pm index 3f92bddf12b..5f31719f8d9 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -3120,6 +3120,7 @@ sub add_optoken($block, $match) { my $equiv := 'infix:+'; if $category eq 'prefix' { $equiv := 'prefix:+' } elsif $category eq 'postfix' { $equiv := 'postfix:++' } + elsif $category eq 'circumfix' { $equiv := 'term:' } my $past := PAST::Op.new( :name('newtok'), :pasttype('callmethod'), PAST::Op.new( :inline(" %r = get_hll_global ['Perl6';'Grammar'], '$optable'") diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index e8164b117b5..d2fbe08b505 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -873,14 +873,14 @@ token subshortname { + } -token category { 'infix' | 'prefix' | 'postfix' | 'trait_auxiliary' } +token category { 'infix' | 'prefix' | 'postfix' | 'circumfix' | 'trait_auxiliary' } ## used internally to convert p6 opnames to internal ones regex opname { ':' - [ '<<' \s* [ (\S+) \s* ] '>>' - | '«' \s* [ (\S+) \s* ] '»' - | '<' \s* [ (\S+) \s* ] '>' + [ '<<' \s* [ ([\S+]**[\s+]) \s* ] '>>' + | '«' \s* [ ([\S+]**[\s+]) \s* ] '»' + | '<' \s* [ ([\S+]**[\s+]) \s* ] '>' ] }