From 9bf03dfb582a75385e72c4a2a5cfbfa4c1d1be20 Mon Sep 17 00:00:00 2001 From: pmichaud Date: Tue, 16 Feb 2010 09:11:33 -0600 Subject: [PATCH] Add \c[nn,nn,nn] form of character specification. --- src/HLL/Actions.pm | 12 +++++++++++- t/nqp/46-charspec.t | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/HLL/Actions.pm b/src/HLL/Actions.pm index c2a0386..a5e4f67 100644 --- a/src/HLL/Actions.pm +++ b/src/HLL/Actions.pm @@ -168,6 +168,16 @@ method quote_escape:sym($/) { make $.ast; } +method charname($/) { + make pir::chr($.ast); +} + +method charnames($/) { + my $str := ''; + for $ { $str := $str ~ $_.ast; } + make $str; +} + method charspec($/) { - make pir::chr(string_to_int( $/, 10 )); + make $ ?? $.ast !! pir::chr(string_to_int( $/, 10 )); } diff --git a/t/nqp/46-charspec.t b/t/nqp/46-charspec.t index a0d08eb..18d57cd 100644 --- a/t/nqp/46-charspec.t +++ b/t/nqp/46-charspec.t @@ -2,6 +2,7 @@ # check literals -say('1..1'); +say('1..2'); say("\c111\c107 \c49"); +say("\c[111,107,32,50]");