mw-parser.declarative
A very simple parser which parses production rules.
build-parser
macro
(build-parser g)
Compose this grammar fragment g
with the common grammar fragments to make a complete grammar, and return a parser for that complete grammar.
compile-rule
(compile-rule rule-text return-tuple?)
(compile-rule rule-text)
Parse this rule-text
, a string conforming to the grammar of MicroWorld rules, into Clojure source, and then compile it into an anonymous function object, getting round the problem of binding mw-engine.utils in the compiling environment. If return-tuple?
is present and true, return a list comprising the anonymous function compiled, and the function from which it was compiled.
Throws an exception if parsing fails.
keywords-en
English language keyword literals used in rules - both in production rules (this namespace) and in flow rules (see mw-parser.flow).
It’s a long term aim that the rule language should be easy to internationalise; this isn’t a full solution but it’s a step towards a solution.
keywords-for-locale
(keywords-for-locale)
(keywords-for-locale _locale)
For now, just return keywords-en
; plan is to have resource files of keywords for different languages in a resource directory, but that isn’t done yet. It’s probably not going to work easily for languages that use non-latin alphabets, anyway.
parse-rule
Parse the argument, assumed to be a string in the correct syntax, and return a parse tree.
rule-grammar
Basic rule language grammar.
in order to simplify translation into other natural languages, all TOKENS within the parser should be unambiguou.