[erlang-questions] fast JSON parser in C

Richard A. O'Keefe ok@REDACTED
Wed Jul 30 05:24:35 CEST 2008

In json_lex2.xrl we find

     whole_float(TokenChars) ->
         {ok, NowFloat, 1} = regexp:sub(TokenChars, "e", ".0e"),

I note that the Leex pattern for the token string
allows capital E, but this regular expression doesn't seem to.


I therefore suggest

     whole_float(Token_Chars) ->

     insert_point_zero([$e|Cs]) -> ".0e" ++ Cs;
     insert_point_zero([$E|Cs]) -> ".0e" ++ Cs;
     insert_point_zero([C |Cs]) -> [C | insert_point_zero(Cs)].

which also avoids the overheads of regular expressions.

More information about the erlang-questions mailing list