This namespace contains Instaparse CFG (or PEG) grammars (and parsers derived
therefrom) that are used by TeGere. The primary grammar is feature-prsr
,
which describes Gherkin feature files. However, PSGs are also used to parse the
tag expressions that may be passed at the command line, hence:
tag-expression-cli-prsr
and old-style-tag-expr-prsr
.
Note that the outputs of these grammars typically require post-processing in
order to arrive at specification-compliant Clojure data structures. For that
post-processing work, see the tegere.parser
ns.
Final note: the grammars here could all be defined in one go as single def
statements. The present convention of breaking the grammars up into smaller
sub-grammars is in part a vestige of how they were developed, viz., iteratively
and via the REPL.
This namespace contains Instaparse CFG (or PEG) grammars (and parsers derived therefrom) that are used by TeGere. The primary grammar is ``feature-prsr``, which describes Gherkin feature files. However, PSGs are also used to parse the tag expressions that may be passed at the command line, hence: ``tag-expression-cli-prsr`` and ``old-style-tag-expr-prsr``. Note that the outputs of these grammars typically require post-processing in order to arrive at specification-compliant Clojure data structures. For that post-processing work, see the ``tegere.parser`` ns. Final note: the grammars here could all be defined in one go as single ``def`` statements. The present convention of breaking the grammars up into smaller sub-grammars is in part a vestige of how they were developed, viz., iteratively and via the REPL.
(feature-prsr input)
Parses a Gherkin feature file string into a Hiccup data format. Cheats a little by suffixing a newline if one is not present.
Parses a Gherkin feature file string into a Hiccup data format. Cheats a little by suffixing a newline if one is not present.
This should parse old-style tag expression strings, like '@dog,~@cat', into raw tags, negated tag vectors, or vectors of disjoined tag expressions. The @ sign before tags is optional and whitespace between tags is removed. Examples:
cat => (cat)
@cat => (cat)
~@cat => ([:NEG cat])
cat,~@dog,cow,~bunny => ([:DISJ cat [:NEG dog] cow [:NEG bunny]])
cat , ~@dog,cow , ~bunny => ([:DISJ cat [:NEG dog] cow [:NEG bunny]])
This should parse old-style tag expression strings, like '@dog,~@cat', into raw tags, negated tag vectors, or vectors of disjoined tag expressions. The @ sign before tags is optional and whitespace between tags is removed. Examples: cat => (cat) @cat => (cat) ~@cat => ([:NEG cat]) cat,~@dog,cow,~bunny => ([:DISJ cat [:NEG dog] cow [:NEG bunny]]) cat , ~@dog,cow , ~bunny => ([:DISJ cat [:NEG dog] cow [:NEG bunny]])
This grammar uses the PEG extensions of Instaparse in order to simulate the Shunting-yard algorithm. It will parse ambiguous boolean grammars such that (minimally) the example at https://github.com/cucumber/cucumber/tree/master/tag-expressions is correct::
(= (parser/parse-tag-expression-with-fallback
not @a or @b and not @c or not @d or @e and @f)
'(or (or (or (not a) (and b (not c))) (not d)) (and e f)))
This is accomplished via strategic use of the 'ordered choice' operator '/'.
This grammar uses the PEG extensions of Instaparse in order to simulate the Shunting-yard algorithm. It will parse ambiguous boolean grammars such that (minimally) the example at https://github.com/cucumber/cucumber/tree/master/tag-expressions is correct:: (= (parser/parse-tag-expression-with-fallback not @a or @b and not @c or not @d or @e and @f) '(or (or (or (not a) (and b (not c))) (not d)) (and e f))) This is accomplished via strategic use of the 'ordered choice' operator '/'.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close