Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Richard O'Keefe's whole float DFA

  • Loading branch information...
commit 2673dc0bf4a70fd377933d3f0015739933d5b263 1 parent c754ad9
Chris Anderson authored
View
BIN  json_eep.beam
Binary file not shown
View
BIN  json_grammar.beam
Binary file not shown
View
BIN  json_lex2.beam
Binary file not shown
View
9 json_lex2.erl
@@ -20,9 +20,12 @@
strip(TokenChars,TokenLen) -> lists:sublist(TokenChars, 2, TokenLen - 2).
-whole_float(TokenChars) ->
- {ok, NowFloat, 1 } = regexp:sub(TokenChars,"e",".0e"),
- list_to_float(NowFloat).
+whole_float(Token_Chars) ->
+ list_to_float(insert_point_zero(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)].
unescape([$\\,$\"|Cs]) -> [$\"|unescape(Cs)];
unescape([$\\,$\\|Cs]) -> [$\\|unescape(Cs)];
View
9 json_lex2.xrl
@@ -43,9 +43,12 @@ Erlang code.
strip(TokenChars,TokenLen) -> lists:sublist(TokenChars, 2, TokenLen - 2).
-whole_float(TokenChars) ->
- {ok, NowFloat, 1 } = regexp:sub(TokenChars,"e",".0e"),
- list_to_float(NowFloat).
+whole_float(Token_Chars) ->
+ list_to_float(insert_point_zero(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)].
unescape([$\\,$\"|Cs]) -> [$\"|unescape(Cs)];
unescape([$\\,$\\|Cs]) -> [$\\|unescape(Cs)];
Please sign in to comment.
Something went wrong with that request. Please try again.