<abstract> new Parser(grammar)
Creates a parser; only used by subclass to set .grammar.
Parameters:
| Name | Type | Description |
|---|---|---|
grammar |
module:Base~Factory | represents grammar. |
- Source:
Properties:
| Name | Type | Argument | Description |
|---|---|---|---|
grammar |
module:Base~Factory | represents the grammar, counts errors; concurrent recognition will trash error counting. |
|
actions |
Object |
<nullable> |
maps rule names to action methods during recognition. |
Methods
-
act(name, result)
-
Calls an action method. Checks argument count unless
grammar.config.noargsis set or the method expects no arguments, i.e., has a rest parameter.Parameters:
Name Type Description namestring rule name to match.
resultArray list of arguments.
Returns:
action method result or unchanged
result. -
call(target, method, args)
-
Checks if argument and parameter count of a method match unless the method expects no parameters, or has a rest parameter or
grammar.config.noargsis true.Parameters:
Name Type Argument Description targetobject to apply method to.
methodfunction to check.
argsObject <repeatable>
arguments to pass.
Returns:
method result.
- Type
- Object
Example
super.method(arg1, .. argn)
this.parser.call(this, super.method, arg1, .. argn)
-
parse( [actions], arg)
-
Only used by subclass to set
.actions; resets.errorsfor the grammar. Should recognize an input sentence.Parameters:
Name Type Argument Description actionsfunction | Object <optional>
a function is assumed to be a class and a singleton is created with
thisas constructor argument. The object maps rule names to action methods.argObject <repeatable>
used as further constructor arguments.