module FoodIngredientParser::Strict::Grammar

grammar Amount
  include Common

  rule amount
    '(' ws* amount:amount_simple ws* ')' <AmountNode> /
    '[' ws* amount:amount_simple ws* ']' <AmountNode> /
    '{' ws* amount:amount_simple ws* '}' <AmountNode> /
    amount:amount_simple                 <AmountNode>
  end

  rule amount_simple_percent
    amount:(amount_simple_number ws* percent) <AmountNode>
  end

  rule amount_simple
    ( (
      'of which'i / 'at least'i / 'minimal'i / 'maximal'i / 'less than'i / 'more than'i /
      'waarvan'i / 'ten minste'i / 'tenminste'i / 'minimaal'i / 'maximaal'i / 'minder dan'i / 'meer dan'i /
      'min.'i / 'min'i / 'max.'i / 'max'i / 'c.a.'i / 'ca.'i / 'ca'i
    ) ws* )?
    amount_simple_quantity
    ( ws+ (
      'of a'i / 'of'i / 'or less of'i / 'or more of'i /
      'van een'i / 'minimaal'i / 'minimum'i / 'van het uitlekgewicht'i / 'van het geheel'i /
      'min.'i / 'min'i / 'max.'i / 'max'i
    ) )?
  end

  rule amount_simple_quantity
    amount_simple_number ( ws* amount_simple_unit? ws* dash ws* amount_simple_number )? ( ws* amount_simple_unit )?
  end

  rule amount_simple_number
    ( amount_simple_comparator ws* )? number
  end

  rule amount_simple_comparator
    '=' ws* [<>] /
    [<>] ws* ( '=' / 'of gelijk aan'i !char / 'or equal to'i !char ) /
    [±∓~∼∽≂≃≈≲≤<>≥≳] / '+/-' / '-/+'
  end

  rule amount_simple_unit
    ( percent / ( ( 'procent' / 'percent' / 'gram'i / 'ml'i / 'mg'i / 'gr'i / 'g'i / 'ppm'i ) !char ) )
    ( ws 'vol'i ( !char / '.' ) )?
    ( ws* '℮' )?
  end
end

end