Author: bernhard
Date: Thu Feb  8 11:13:36 2007
New Revision: 16926

Modified:
   trunk/languages/PIR/lib/pir.pg
   trunk/languages/PIR/t/assign.t

Log:
[languages/PIR]
* added optional "utf8:" encoding specifier (according to docs/imcc/syntax.pod)
* fixed support for binary and hex. numbers
* added test for these changes. 

Courtesy of Klaas Jan Stol


Modified: trunk/languages/PIR/lib/pir.pg
==============================================================================
--- trunk/languages/PIR/lib/pir.pg      (original)
+++ trunk/languages/PIR/lib/pir.pg      Thu Feb  8 11:13:36 2007
@@ -703,19 +703,17 @@
 #
 
 token int_constant {
-    [-]? \d+
-  | <binary_constant>
+    <binary_constant>
   | <hex_constant>
+  | [-]? \d+
 }
 
-# FIXTHIS
-regex hex_constant {
-  \d+
+token hex_constant {
+  0x\d+
 }
 
-# FIXTHIS
-regex binary_constant {
-  \d+
+token binary_constant {
+  0b\d+
 }
 
 token float_constant {
@@ -724,10 +722,13 @@
 
 
 rule string_constant {
-  <charset_specifier>? 
+       [ <encoding_specifier>? <charset_specifier> ]?
   [ <stringdouble> | <stringsingle> ]
 }
 
+rule encoding_specifier {
+       <'utf8:'>
+}
 
 rule charset_specifier {
   [ <'ascii:'> | <'binary:'> | <'unicode:'> | <'iso-8859-1:'> ]  

Modified: trunk/languages/PIR/t/assign.t
==============================================================================
--- trunk/languages/PIR/t/assign.t      (original)
+++ trunk/languages/PIR/t/assign.t      Thu Feb  8 11:13:36 2007
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use lib qw(t . lib ../lib ../../lib ../../../lib);
-use Parrot::Test tests => 6;
+use Parrot::Test tests => 7;
 use Test::More;
 
 language_output_is( 'PIR_PGE', <<'CODE', <<'OUT', 'simple assignments' );
@@ -18,6 +18,16 @@
 Parse successful!
 OUT
 
+language_output_is( 'PIR_PGE', <<'CODE', <<'OUT', 'int/hex/bin' );
+.sub main                      
+       a = 10
+       b = 0b10
+       c = 0x10        
+.end
+CODE
+"parse" => PMC 'PIRGrammar' { ... }
+Parse successful!
+OUT
 
 language_output_is( 'PIR_PGE', <<'CODE', <<'OUT', 'get keyed assignments' );
 .sub main                      
@@ -93,6 +103,7 @@
        s = binary:"Hello WOrld"
        s = unicode:"Hello world"
        s = iso-8859-1:"Hello world"             
+       s = utf8:unicode:"Hello World"
 .end
 CODE
 "parse" => PMC 'PIRGrammar' { ... }

Reply via email to