Explorar o código

Float constants of the form .5 and 5. are now allowed by the lexer

Taddeus Kroes %!s(int64=12) %!d(string=hai) anos
pai
achega
c373abd89b
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      lexer.mll

+ 2 - 1
lexer.mll

@@ -81,7 +81,8 @@ rule token = parse
   | "true"    { BOOL_CONST true }
   | "false"   { BOOL_CONST false }
   | ['0'-'9']+ as i              { INT_CONST (int_of_string i) }
-  | ['0'-'9']+'.'['0'-'9']+ as f { FLOAT_CONST (float_of_string f) }
+  | ['0'-'9']+'.'['0'-'9']* as f { FLOAT_CONST (float_of_string f) }
+  | ['0'-'9']*'.'['0'-'9']+ as f { FLOAT_CONST (float_of_string f) }
   | ['A'-'Z''a'-'z']['A'-'Z''a'-'z''0'-'9''_']* as id { ID id }
 
   | '\r' | '\n' | "\r\n"  { next_line lexbuf; token lexbuf }