Skip to content
Browse files

Richard O'Keefe's whole float DFA

  • Loading branch information...
1 parent c754ad9 commit 2673dc0bf4a70fd377933d3f0015739933d5b263 Chris Anderson committed Jul 30, 2008
Showing with 12 additions and 6 deletions.
  1. BIN json_eep.beam
  2. BIN json_grammar.beam
  3. BIN json_lex2.beam
  4. +6 −3 json_lex2.erl
  5. +6 −3 json_lex2.xrl
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)];

0 comments on commit 2673dc0

Please sign in to comment.
Something went wrong with that request. Please try again.