3 Production expressions
(require yaragg/base/production-expression) | |
package: yaragg |
A production expression is a pattern of symbols and tokens in a grammar. Production expressions are used by production rules to describe what pattern of tokens a symbol corresponds to. Production expressions come in a few variants:
A group expression matches a group of subexpressions in series.
A choice expression tries subexpressions one at a time and selects the first matching subexpression.
A repetition expression matches a single subexpression multiple times in series.
A cut expression matches a subexpression but omits the match from the parse tree.
A terminal symbol, which matches a single token in the input stream.
A nonterminal symbol, which refers to other production expressions as defined by the production rules of the grammar.
procedure
v : any/c
procedure
(group-expression? v) → boolean?
v : any/c
procedure
(group-expression subexpressions) → group-expression?
subexpressions : (sequence/c production-expression?)
procedure
(choice-expression? v) → boolean?
v : any/c
procedure
(choice-expression choices) → choice-expression?
choices : (sequence/c (or/c production-expression? grammar-symbol?))
procedure
v : any/c
procedure
(repetition-expression subexpression [ #:min-count min-count #:max-count max-count]) → repetition-expression? subexpression : (or/c production-expression? grammar-symbol?) min-count : exact-nonnegative-integer? = 0 max-count : (or/c exact-nonnegative-integer? +inf.0) = +inf.0
procedure
(cut-expression? v) → boolean?
v : any/c
procedure
(cut-expression subexpression) → cut-expression?
subexpression : (or/c production-expression? grammar-symbol?)
procedure
(grammar-symbol? v) → boolean?
v : any/c
procedure
(atom-symbol? v) → boolean?
v : any/c
procedure
(atom-symbol type) → atom-symbol?
type : symbol?
procedure
(punctuation-symbol? v) → boolean?
v : any/c
procedure
str : string?
procedure
(nonterminal-symbol? v) → boolean?
v : any/c
procedure
key : any/c