Skip to content

Commit

Permalink
Support 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 67bfa0e commit 52879c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions data/test-cases
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ saus (tomaat, zout) en water
saus (tomaat, zout) en pasta, water
p (a, b), q(c)
p (a, b (r)), q(c)
p (E123/E124)
p: a, b. q: c
p: a, b. q: c.
p: e123i-E124
Expand Down
16 changes: 11 additions & 5 deletions lib/food_ingredient_parser/strict/grammar/list.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ module FoodIngredientParser::Strict::Grammar
include Ingredient

rule list
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> /
contains:(ingredient ( ws* '.' ws* ingredient )+ ( ws+ and ws+ ingredient )? ) <ListNode> /
contains:(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> /
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>
end
end
end

0 comments on commit 52879c9

Please sign in to comment.