Kaynağa Gözat

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

Taddeus Kroes 12 yıl önce
ebeveyn
işleme
c373abd89b
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  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 }