Skip to content

Commit

Permalink
Improve support for slash as separator with e-numbers (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Jun 13, 2024
1 parent 52879c9 commit 993da0e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions data/test-cases
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ o, p: a/b//d
o, p: a(r)
o, p: a/b (r)
o, p: e123-E124a
o, p: E123/E124
p\na, b\n\nq\nc
# amounts
tomaat (30%)
Expand Down
8 changes: 2 additions & 6 deletions lib/food_ingredient_parser/strict/grammar/list.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ module FoodIngredientParser::Strict::Grammar
contains:(ingredient ( ws* ';' ws* ingredient )+ ( ws+ and ws+ ingredient )? ) <ListNode> /
contains:(ingredient ( ws* ',' ws* ingredient )+ ( ws+ and ws+ ingredient )? ) <ListNode> /
contains:(ingredient ( ws* '.' ws* ingredient )+ ( ws+ and ws+ ingredient )? ) <ListNode> /
list_e_number /
contains:(ingredient ( ws+ and ws+ ingredient )? ) <ListNode>
end

rule list_e_number
contains:(ingredient_simple_e_number ( ws* '/' ws* ingredient_simple_e_number )+ ) <ListNode> /
contains:(ingredient_simple_e_number ( ws* dash ws* ingredient_simple_e_number )+ ) <ListNode>
contains:(ingredient_simple_e_number ( ws* dash ws* ingredient_simple_e_number )+ ) <ListNode> /
contains:(ingredient ( ws+ and ws+ ingredient )? ) <ListNode>
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module FoodIngredientParser::Strict::Grammar
end

rule list_coloned_inner_list
contains:( ingredient_simple_e_number ( ws* '/' ws* ingredient_simple_e_number )+ ) <ListNode> /
contains:( ingredient_simple_e_number ( ws* dash ws* ingredient_simple_e_number )+ ) <ListNode> /
contains:( ingredient ( ws* ',' ws* ingredient )* ) <ListNode>
end
Expand Down

0 comments on commit 993da0e

Please sign in to comment.