Crate shopping_parser

Crate shopping_parser 

Source
Expand description

§Grammar Rules Documentation

§Rules Overview

  • WHITESPACE - matches spaces or tabs.
  • product_name - matches a product name in the format Product name: <name>.
  • category - matches a category in the format Category: <category>.
  • price - matches a price in the format Price: <amount> <currency>/<unit>.
  • calories - matches the caloric content in the format Calories: <calories> cal.
  • proteins - matches the protein content in grams in the format Proteins: <amount> g.
  • carbohydrates - matches the carbohydrate content in grams in the format Carbohydrates: <amount> g.
  • fats - matches the fat content in grams in the format Fats: <amount> g.
  • currency_amount - matches an amount with an optional decimal part.
  • currency - supported currencies: UAH, USD, EUR.
  • unit - supported units: kg, l, ml, pcs, g.
  • name - represents the name of a product, consisting of alphabetic characters and allowing multiple words separated by spaces.
  • product - matches a single product entry with all properties.
  • products - matches a list of products, each separated by a blank line.
  • shopping_item - matches a single shopping item in the format <name> <quantity> <unit>.
  • shopping_list - matches a shopping list with multiple items separated by commas.

Structs§

Grammar
Product
ShoppingItem

Enums§

Rule

Functions§

load_products_from_json
parse_products_file
parse_shopping_list
save_products_to_json