Permalink
Browse files

[feature] opa,syntax: numbers with underscore

CHANGELOG Possibility to use underscore inside numbers
  • Loading branch information...
OpaOnWindowsNow committed Apr 3, 2012
1 parent 227e038 commit 1353f361af1a003723d34d8087b25d0324ea92cc
Showing with 32 additions and 15 deletions.
  1. +9 −7 opalang/classic_syntax/opa_lexer.trx
  2. +23 −8 opalang/js_syntax/opa_lexer.trx
@@ -122,20 +122,22 @@ utf8char <- [\000-\127]:i1 {{ Cactutf.one_byte (Char.code i1) }}
# Numbers # Numbers
# #
/* integer */ /* integer */
decimal_number <- [0-9]+ $ decimal_number <- [0-9][0-9_]* $
binary_number <- [01]+ $ binary_number <- [01][01_]* $
octal_number <- [0-7]+ $ octal_number <- [0-7][0-7_]* $
hexadecimal_number <- hexa+ $ hexadecimal_number <- hexa (hexa/[_])* $
strint <- [-]? ([0] [bB] binary_number $ strint <- [-]? ([0] [bB] binary_number $
/[0] [oO] octal_number $ /[0] [oO] octal_number $
/[0] [xX] hexadecimal_number $ /[0] [xX] hexadecimal_number $
/decimal_number $) $_ /decimal_number $) $_
/* float */ /* float */
exponent <- 'e'~ '-'? decimal_number $
strfloat <- strfloat <-
/ [-]? [.] [0-9]+ ('e'~ '-'? [0-9]+)? $_ / [-]? decimal_number [.] decimal_number? exponent? $_
/ [-]? [0-9]+ [.] [0-9]* ('e'~ '-'? [0-9]+)? $_ / [-]? [.] decimal_number exponent? $_
/ [-]? [0-9]+ 'e'~ '-'? [0-9]+ $_ / [-]? decimal_number exponent $_
int <- Opa_parser.pos:pos strint:s {{ try int_of_string s with Failure "int_of_string" -> error_int_overflow pos }} int <- Opa_parser.pos:pos strint:s {{ try int_of_string s with Failure "int_of_string" -> error_int_overflow pos }}
float <- strfloat {{ float_of_string __1 }} float <- strfloat {{ float_of_string __1 }}
@@ -1,5 +1,5 @@
(* (*
Copyright © 2011 MLstate Copyright © 2011, 2012 MLstate
This file is part of OPA. This file is part of OPA.
@@ -125,20 +125,35 @@ utf8char <- [\000-\127]:i1 {{ Cactutf.one_byte (Char.code i1) }}
# Numbers # Numbers
# #
/* integer */ /* integer */
decimal_number <- [0-9]+ $ decimal_number <- [0-9][0-9_]* $
binary_number <- [01]+ $ binary_number <- [01][01_]* $
octal_number <- [0-7]+ $ octal_number <- [0-7][0-7_]* $
hexadecimal_number <- hexa+ $ hexadecimal_number <- hexa (hexa/[_])* $
strint <- [-]? ([0] [bB] binary_number $ strint <- [-]? ([0] [bB] binary_number $
/[0] [oO] octal_number $ /[0] [oO] octal_number $
/[0] [xX] hexadecimal_number $ /[0] [xX] hexadecimal_number $
/decimal_number $) $_ /decimal_number $) $_
/* float */ /* float */
exponent <- 'e'~ '-'? decimal_number $
strfloat <- strfloat <-
/ [-]? [.] [0-9]+ ('e'~ '-'? [0-9]+)? $_ / [-]? decimal_number [.] decimal_number? exponent? $_
/ [-]? [0-9]+ [.] [0-9]* ('e'~ '-'? [0-9]+)? $_ / [-]? [.] decimal_number exponent? $_
/ [-]? [0-9]+ 'e'~ '-'? [0-9]+ $_ / [-]? decimal_number exponent $_
strint <- [-]? ([0] [bB] binary_number $
/[0] [oO] octal_number $
/[0] [xX] hexadecimal_number $
/decimal_number $) $_
/* float */
exponent <- 'e'~ '-'? decimal_number $
strfloat <-
/ [-]? decimal_number [.] decimal_number? exponent? $_
/ [-]? [.] decimal_number exponent? $_
/ [-]? decimal_number exponent $_
int <- Opa_parser.pos:pos strint:s {{ try int_of_string s with Failure "int_of_string" -> error_int_overflow pos }} int <- Opa_parser.pos:pos strint:s {{ try int_of_string s with Failure "int_of_string" -> error_int_overflow pos }}
float <- strfloat {{ float_of_string __1 }} float <- strfloat {{ float_of_string __1 }}

0 comments on commit 1353f36

Please sign in to comment.