diff --git a/grammar.lark b/grammar.lark new file mode 100644 index 0000000000000000000000000000000000000000..88d46c94eab4b667ea08918ee63544bd727a7136 --- /dev/null +++ b/grammar.lark @@ -0,0 +1,63 @@ +// Author: Liam Esteban Prince +// Description: EBNF context free grammar for cooking recipe + +%ignore " " +%import common.NUMBER + +ambiguator: ("<" | ">" | "less than" | "more than") + +// amount: quantity of an ingredient +// eg: 10 - 20 g of pasta +amount: ambiguator* NUMBER+ ("-" | "/" | "to")? NUMBER* + +// UNIT: unit of measure +// recognises synonyms or shorthand +// eg: "cup", "grams", "pinch". shorthand: "g", "gr" +UNIT: ("gr" | "g") + +// ingredient: +ingredient: modifier* ingredient (modifier ",")* + +// modifier: a word or phrase that modifies the ingredient +// eg: "pears, chopped", "chopped pears", "chicken, skin on" +// usually ends in "ed" +modifier: verb | ingredient adverb + +adverb: + +// UTENSIL: an auxiliary object used by the action +// eg: "bowl", "pan" +UTENSIL: ("bowl" | "pan") + +// instruction: a verb applied to one or more ingredients +// does not apply to gerunds like "stirring constantly" +// eg: "mix the bell pepper with the chicken" +instruction: verb ( PREPOSITION ( verb )? PREPOSITION? ( ingredient* | UTENSIL | mixture ) ) PREPOSITION+ UTENSIL + +verb: + +// mixture: a way to refer to multiple previous ingredients +// usually as a result of a previous step in the method +// eg: "spices", "dry ingredients" +mixture: + +// PREPOSITION: word used to link nouns, pronouns, or phrases to other words within a sentence +PREPOSITION: ("with" | "to" | "in" | "of" | "at" | "for" | "off" | "on" | "over" | "under" | "until") + +// ARTICLE: word used with a noun to specify grammatical definiteness +ARTICLE: ("a" | "an" | "the") + +// CONJUNCTION: word used to connect words, phrases, clauses, or sentences +CONJUNCTION: ("and" | "or" | "but") + +// ADJECTIVE: +ADJECTIVE: ("red" | "fast") + +// ADVERB: +ADVERB: ("quickly") + +// PUNCTUATION +// Ignore punctuation +PUNCTUATION: "." + +!start: ADVERB PUNCTUATION+ CONJUNCTION