(ebnf->gen ebnf)
(ebnf->gen ctx ebnf)
Takes an EBNF grammar, parser, file, or text string and returns a test.check generator. If the start is specified then this the name of the rule to use as the starting rule of the grmmar. If start is not specified then the first rule in the grammar file is used as the starting rule.
Takes an EBNF grammar, parser, file, or text string and returns a test.check generator. If the start is specified then this the name of the rule to use as the starting rule of the grmmar. If start is not specified then the first rule in the grammar file is used as the starting rule.
(grammar->generator-obj {:keys [start] :as ctx} grammar)
Return a a new generator object based on the context and instacheck grammar object.
Return a a new generator object based on the context and instacheck grammar object.
(instacheck check-fn ebnf & [qc-opts])
Instacheck a function with EBNF defined test cases. The check-fn will be called repeatedly with random strings that conform to the ebnf definition. The function should perform a test based on the string and return a nil or false if fails the test or any other value to indicate that it passes the test. If a failure is detected then the shrinking process will performed. The return value is the quick-check return status.
The optional qc-opts parameter can be used to specify the following quick-check options:
Instacheck a function with EBNF defined test cases. The check-fn will be called repeatedly with random strings that conform to the ebnf definition. The function should perform a test based on the string and return a nil or false if fails the test or any other value to indicate that it passes the test. If a failure is detected then the shrinking process will performed. The return value is the quick-check return status. The optional qc-opts parameter can be used to specify the following quick-check options: - iterations: number of iterations to check before success. - seed: starting seed for generating test cases - max-size: maximum size for all internal generators. - report-fn: function to call with a report after each iteration
(parse parser text & [location])
Use parser to parse text. On success returns the parsed AST. On error, throws an ex-info object with a friendly error location string and a info map containing the :failure (instaparse Failure object), :text (the original text), and :location (optional location parameter).
Use parser to parse text. On success returns the parsed AST. On error, throws an ex-info object with a friendly error location string and a info map containing the :failure (instaparse Failure object), :text (the original text), and :location (optional location parameter).
(parse-wtrek parser text & [id])
Uses parser to parse a text string and returns a map with the parsed tree (:parsed) and a path-log wtrek from the parse (:wtrek). The wtrek weights are set to the number of times each path in the grammar was followed/used to parse the text.
Uses parser to parse a text string and returns a map with the parsed tree (:parsed) and a path-log wtrek from the parse (:wtrek). The wtrek weights are set to the number of times each path in the grammar was followed/used to parse the text.
(parse-wtreks parser texts-ids)
Takes a sequence of [text id] pairs and uses parse-wtrek to generator the following structure:
{:parts [{:id ID
:parsed PARSED
:wtrek {PATH WEIGHT ...}}
...]
:full {PATH WEIGHT ...}}
The :parts value is a vector of the parse-wtrek result for each texts-ids. The :full-wtrek has merged weight counts from all :parts :wtrek values.
Takes a sequence of [text id] pairs and uses parse-wtrek to generator the following structure: {:parts [{:id ID :parsed PARSED :wtrek {PATH WEIGHT ...}} ...] :full {PATH WEIGHT ...}} The :parts value is a vector of the parse-wtrek result for each texts-ids. The :full-wtrek has merged weight counts from all :parts :wtrek values.
(quick-check opts gen-to-check check-fn report-fn)
Run quick-check against a generator (gen-to-check) using a check function (check-fn) and reporter functon (report-fn). Execution options (opts) supported are :iterations (default: 10), :max-size (default: 200), and :seed.
Run quick-check against a generator (gen-to-check) using a check function (check-fn) and reporter functon (report-fn). Execution options (opts) supported are :iterations (default: 10), :max-size (default: 200), and :seed.
(update-generator-obj obj {:keys [weights start]})
Return a new generator object with runtime properties adjusted (those that don't require eval of the function source again). Only weights and start rule are supported currently.
Return a new generator object with runtime properties adjusted (those that don't require eval of the function source again). Only weights and start rule are supported currently.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close