mw-parser.flow
A very simple parser which parses flow rules.
flow-grammar
Grammar for flow rules.
My initial conception of this would be that production rules (if-then rules) and flow rules (flow-from-to rules) would be entirely separate, presented to the parser as separate text files, and parsed and compiled by different chains of functions.
This appears not to be necessary. Flow rules are easy to parse with the same parser as production rules – a lot of the grammar is intentionally common – and the rules are easily discriminated at the compilation (‘generate’) stage.
The basic rule I want to be able to compile at this stage is the ‘mutual aid’ rule:
flow 1 food from house having food > 1 to house with least food within 2
parse-flow
Parse the argument, assumed to be a string in the correct syntax, and return a parse tree.