<abstract> new Factory()
- Source:
Properties:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object.<string, Object> | maps names to configurable values. Properties
|
||||||||||||||||||
lits |
Array.<module:Base~Lit> | list of unique literals, can be pushed. |
||||||||||||||||||
litsByName |
Object.<string, module:Base~Lit> | maps |
||||||||||||||||||
tokens |
Array.<module:Base~Token> | list of unique tokens, can be pushed. |
||||||||||||||||||
tokensByName |
Object.<string, module:Base~Token> | maps name to unique token. |
||||||||||||||||||
levels |
Array.<module:Base~Precedence> | list of precedence levels, can be pushed. |
||||||||||||||||||
nts |
Array.<module:Base~NT> | list of unique non-terminals, can be pushed. |
||||||||||||||||||
ntsByName |
Object.<string, module:Base~NT> | maps name to unique non-terminal. |
||||||||||||||||||
errors |
number | incremented by |
||||||||||||||||||
noargs |
boolean | don't check for argument count errors in |
Methods
-
add(item)
-
Adds a new symbol to the proper inventory or creates and adds new tokens. Must be called with a new, unique symbol or with a map of token names to patterns. Validates item names against
.config. Token patterns must not accept empty input, must not used,g, oryflag, should not be anchored, and should use(:? )rather than( )for grouping.Parameters:
Name Type Description itemSymbol | Object.<string, RegExp> to add to the proper inventory or create and add.
-
assert(condition, s)
-
Displays a message and throws an error if a condition is not met; primarily used for stronger argument typing.
Parameters:
Name Type Argument Description conditionboolean should be true.
sArray.<?object> <repeatable>
message, to be displayed; joined by blanks.
Throws:
-
message if condition is not met.
- Type
- string
-
-
dump( [a])
-
Displays an object as a string; in particular, nested arrays. This is useful because
console.debugonly reaches 3 levels.Parameters:
Name Type Argument Description aObject <optional>
the object to display; if omitted, returns an empty string.
Returns:
- Type
- string
-
error(s)
-
Displays a message and counts it as an error.
Parameters:
Name Type Argument Description sArray.<?object> <repeatable>
message, to be displayed; joined by blanks.
Returns:
the message.
- Type
- string
-
message(s)
-
Displays a message on the configured
.log.Parameters:
Name Type Argument Description sArray.<?object> <repeatable>
message, to be displayed; joined by blanks.
Returns:
the message.
- Type
- string
-
precedence(assoc, terminals)
-
Factory method to represent a list of terminals with equal precedence level and equal associativity. Creates a new
Precedenceobject, adds it to.levels, adds.prec.leveland.prec.assocto all terminals in the list, and checks for duplicates.Parameters:
Name Type Description assocstring associativity:
'%left','%right', or'%nonassoc'.terminalsArray.<?module:Base~T> to add,
nullelements are ignored; no duplicates.Returns:
representing the set, or
nullif there are no terminals. -
scanner( [skip] [, terminals])
-
Factory method to create a scanner.
Parameters:
Name Type Argument Description skipRegExp <optional>
a pattern to define ignorable character sequences, by default white space, must not accept empty input, must not use
d,g, oryflag, should not be anchored, should use(:? )rather than( )for grouping.terminalsArray.<T> <optional>
ordered list to create the lexical analysis pattern.
Returns:
the scanner.
- Type
- module:Base~Scanner
-
tuple(lineno, t [, value])
-
Factory method to create an element of a tokenized input stream.
Parameters:
Name Type Argument Default Description linenonumber input position.
tmodule:Base~T <nullable>
terminal, i.e., literal or token object;
scan()usesnullfor an illegal character.valuestring <optional>
<nullable>
null terminal's representation in the input.
Returns:
an element of a tokenized input stream.
- Type
- module:Base~Tuple