Changeset 468 for cpp


Ignore:
Timestamp:
02/08/16 21:15:53 (9 years ago)
Author:
Maciej Komosinski
Message:

More sophisticated and accurate parsing of numbers

Location:
cpp/frams/vm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/vm/framscript.l

    r394 r468  
    2323%%
    2424
    25 \$[0-9a-fA-F]+ {int i; sscanf(yytext+1,"%x",&i); framscriptlval.setInt(i); return CONSTANT;}
    26 0x[0-9a-fA-F]+ {int i; sscanf(yytext+2,"%x",&i); framscriptlval.setInt(i); return CONSTANT;}
    27 [0-9]+\.[0-9]*    {framscriptlval.setDouble(atof(yytext)); return CONSTANT;}
    28 [0-9]+            {framscriptlval.setInt(atoi(yytext)); return CONSTANT;}
    29 [0-9]+\.[0-9]*[eE][+-]?[0-9]+    {framscriptlval.setDouble(atof(yytext)); return CONSTANT;}
    30 [0-9]+*[eE][+-]?[0-9]+           {framscriptlval.setDouble(atof(yytext)); return CONSTANT;}
     25[0-9]+\.[0-9]*                   |
     26[0-9]+\.[0-9]*[eE][+-]?[0-9]+    |
     27[0-9]+*[eE][+-]?[0-9]+           {if (framscriptlval.parseNumber(yytext,TDouble)==(yytext+yyleng)) return CONSTANT; else { trctx.err->printf("Invalid floating point number: '%s', ",SString(yytext,yyleng).c_str()); return INVALID_NUMBER;} }
     28
     29[0-9]+                |
     300x[0-9a-fA-F]+        {if (framscriptlval.parseNumber(yytext,TInt)==(yytext+yyleng)) return CONSTANT; else { trctx.err->printf("Invalid integer: '%s', ",SString(yytext,yyleng).c_str()); return INVALID_NUMBER;} }
     31
    3132"null"            {framscriptlval.setEmpty(); return CONSTANT;}
    3233\"([^\\\"]|\\.)*\" {framscriptlval.setString(SString(yytext+1,yyleng-2));return CONSTANT;}
  • cpp/frams/vm/framscript.y

    r466 r468  
    3737
    3838%token CONSTANT
     39%token INVALID_NUMBER
    3940
    4041%nonassoc ASSIGN_ADD ASSIGN_SUB ASSIGN_MUL ASSIGN_DIV ASSIGN_MOD
Note: See TracChangeset for help on using the changeset viewer.