Commits

Anonymous committed 79ac09b

Begin the shift to Python 3.x, octals now start with '0o'.

  • Participants
  • Parent commits f9d030c

Comments (0)

Files changed (4)

File Lib/test/parrot/grammar.py

 else: print 'success: hex int'
 
 print 'test: octal int'
-if 0377 != 255:
+if 0o377 != 255:
     print 'failure: octal int ['
     print "test_grammar.py:44:FAIL test expected 255, not",
-    print 0377
+    print 0o377
     print "]"
 else: print 'success: octal int'

File Lib/test/parrot/literals.py

 
 
 print 'test: octal literals'
-01
-02
-03
-04
-05
-06
-07
+0o1
+0o2
+0o3
+0o4
+0o5
+0o6
+0o7
 print 'success: octal literals'
 
 

File src/parser/actions.nqp

 }
 
 method integer($/, $key) {
-    my $str;
-    if $key eq 'octal' {
-        PIR q<  $P0 = find_lex '$/'   >;
-        PIR q<  $S0 = $P0             >;
-        PIR q<  $S1 = substr $S0, 1 >;
-        PIR q<  $S2 = '0o' . $S1 >;
-        PIR q<  $P1 = new 'String'  >;
-        PIR q<  assign $P1, $S2       >;
-        PIR q<  store_lex '$str', $P1 >;
-
-        make PAST::Val.new( :value( ~$str ), :returns('Integer'), :node($/) );
-    }
-    else {
-        make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node($/) );
-    }
+    make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node($/) );
 }
 
 method floatnumber($/) {

File src/parser/grammar.pg

 }
 
 token integer {
-    | [ '0' <[0..7]>+ ] {*}                              #= octal
+    | [ '0' <[oO]> <[0..7]>+ ] {*}                       #= octal
     | [ '0' <[xX]> [ \d | <[a..f]> | <[A..F]> ]+ ] {*}   #= hex
     | [ <[1..9]> \d* | '0' ] {*}                         #= dec
 }