Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support empty binaries

  • Loading branch information...
commit 143e3525ea190d518501c3a5dbf198fed8586144 1 parent 6c82df2
Eric Merritt ericbmerritt authored
Showing with 23 additions and 17 deletions.
  1. +20 −16 src/jxa_parser.erl
  2. +3 −1 test/jxat_parser_proper.erl
36 src/jxa_parser.erl
View
@@ -33,7 +33,7 @@
-export([file/1, parse/1]).
%% for testing purposes
--export([intermediate_parse/1]).
+-export([intermediate_parse/1, p_charclass/1]).
-include_lib("joxa/include/joxa.hrl").
@@ -276,22 +276,26 @@ digit(Input, Index) ->
-spec binary(binary(), index()) -> intermediate_ast().
binary(Input, Index) ->
p(Input, Index, binary,
- p_seq([p_string(<<"<<">>),
- fun ignorable/2,
- p_choose([fun integer/2,
- fun char/2,
- fun ident/2,
- fun list/2]),
- p_zero_or_more(p_seq([fun ignorable/2,
- p_choose([fun integer/2,
- fun char/2,
- fun ident/2,
- fun list/2])])),
- fun ignorable/2,
- p_string(<<">>">>)]),
-
+ p_choose([p_seq([p_string(<<"<<">>),
+ fun ignorable/2,
+ p_choose([fun integer/2,
+ fun char/2,
+ fun ident/2,
+ fun list/2]),
+ p_zero_or_more(p_seq([fun ignorable/2,
+ p_choose([fun integer/2,
+ fun char/2,
+ fun ident/2,
+ fun list/2])])),
+ fun ignorable/2,
+ p_string(<<">>">>)]),
+ p_seq([p_string(<<"<<">>),
+ fun ignorable/2,
+ p_string(<<">>">>)])]),
fun([_, _, H, T, _, _], Idx) ->
- {binary, lists:flatten([H, T]), Idx}
+ {binary, lists:flatten([H, T]), Idx};
+ ([_, _, _], Idx) ->
+ {binary, [], Idx}
end).
-spec tuple(binary(), index()) -> intermediate_ast().
4 test/jxat_parser_proper.erl
View
@@ -137,7 +137,7 @@ ident() ->
character() ->
?LET(Char, string_character(),
- {char, list_to_binary([Char]), 0}).
+ {char, Char, 0}).
jxa_int() ->
{integer, integer(), 0}.
@@ -185,6 +185,8 @@ bitstring_body() ->
{list, [{ident, 'unsigned', 0},
{ident, 'big', 0}], 0}], 0}.
+jxa_binary(0) ->
+ {binary, [], 0};
jxa_binary(Size) ->
{binary, jxa_bitstring(Size), 0}.
Please sign in to comment.
Something went wrong with that request. Please try again.