new Scanner(factory, skip [, terminals])
Creates the pattern used to tokenize a string;
see factory method grammar.scanner().
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
factory |
module:Base~Factory | supplies literals and tokens;
unused terminals and |
|
skip |
RegExp | a pattern to define ignorable character sequences,
must not accept empty input, must not use |
|
terminals |
Array.<T> |
<optional> |
ordered list corresponding to |
- Source:
Properties:
| Name | Type | Description |
|---|---|---|
assert |
function | bound to |
tuple |
function | bound to |
terminals |
Array.<module:Base~T> | ordered for pattern; first tokens ordered by ascending name then literals ordered by decreasing length. |
skip |
RegExp | a pattern to define ignorable character sequences,
should not accept empty input, should not use flags, should not be anchored,
should use |
pattern |
RegExp | read-only, concatenates capture groups
with |
Methods
-
escape(s)
-
Escapes most characters by
\.or\x..or\u..... Similar toTuple.escape().Parameters:
Name Type Description sstring string to escape.
Returns:
escaped string. escape(null) // will crash escape('a') // [alphanumerics] returns string containing a escape('\b') // [controls] returns string containing \b escape('s') // [specials] returns string containing \s escape('x') // [other] returns string containing \x## or \u####
- Type
- string
-
scan(input)
-
Tokenizes a string.
Parameters:
Name Type Description inputstring to be divided into literals and tokens.
Returns:
a list of literals and tokens. The list contains one
Tuplewith anullterminal for each character sequence which is neither ignorable nor a literal or a token.- Type
- Array.<module:Base~Tuple>