refactor(parser): use one rule for every glued parenthesis #171
3 changed files with 8 additions and 14 deletions
|
|
@ -157,9 +157,12 @@ GRAM {
|
||||||
// first word) and the braces leaked into prose -- merging distinct ingredients.
|
// first word) and the braces leaked into prose -- merging distinct ingredients.
|
||||||
// Each "-- malformed" branch below turns that into a readable error instead.
|
// Each "-- malformed" branch below turns that into a readable error instead.
|
||||||
malformedBraces = "{" (~("}" | nl) any)* ("}" | &nl | end)
|
malformedBraces = "{" (~("}" | nl) any)* ("}" | &nl | end)
|
||||||
// On one line: an unclosed `(` is prose, never the start of a preparation
|
// The parenthesis glued to an element: an ingredient's or a tool's
|
||||||
// that would run to the next `)` further down the recipe, over blank lines
|
// preparation, a composite parent's, a temperature's note (and the sensory
|
||||||
// and section headers.
|
// checkpoints' to come). Every rule using it is lexical, so it touches what
|
||||||
|
// comes before it. On one line: an unclosed `(` is prose, never the start
|
||||||
|
// of a preparation that would run to the next `)` further down the recipe,
|
||||||
|
// over blank lines and section headers.
|
||||||
preparation = "(" (~(")" | nl) any)* ")"
|
preparation = "(" (~(")" | nl) any)* ")"
|
||||||
// `modifier*` mirrors simpleIngredient: a composite parent is an ingredient
|
// `modifier*` mirrors simpleIngredient: a composite parent is an ingredient
|
||||||
// reference like any other, and authors (and AI importers) write `<@&parent`
|
// reference like any other, and authors (and AI importers) write `<@&parent`
|
||||||
|
|
@ -212,13 +215,7 @@ GRAM {
|
||||||
// start with a space, as it could when the rule was syntactic: `^ {180°C}`
|
// start with a space, as it could when the rule was syntactic: `^ {180°C}`
|
||||||
// and `^oven {180°C}` read as before (`clean` drops the space). The note
|
// and `^oven {180°C}` read as before (`clean` drops the space). The note
|
||||||
// since 1.5.0.
|
// since 1.5.0.
|
||||||
temperature = "^" name? (ingredientQuantity | textQuantity) gluedNote?
|
temperature = "^" name? (ingredientQuantity | textQuantity) preparation?
|
||||||
|
|
||||||
// A note glued to an element's closing brace, on one line: an unclosed
|
|
||||||
// `(` is prose, never the start of a note that would run to the next `)`
|
|
||||||
// further down the recipe. Meant to be shared by the elements to come
|
|
||||||
// (the sensory checkpoints).
|
|
||||||
gluedNote = "(" (~(")" | nl) any)* ")"
|
|
||||||
|
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -595,9 +595,6 @@ semantics.addOperation("toAST", {
|
||||||
preparation(_lp, text, _rp): string {
|
preparation(_lp, text, _rp): string {
|
||||||
return clean(text.sourceString);
|
return clean(text.sourceString);
|
||||||
},
|
},
|
||||||
gluedNote(_lp, text, _rp): string {
|
|
||||||
return clean(text.sourceString);
|
|
||||||
},
|
|
||||||
unit(name): string {
|
unit(name): string {
|
||||||
return clean(name.sourceString);
|
return clean(name.sourceString);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue