clarity-pattern-parser 11.5.3 → 11.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/architecture.md +300 -0
- package/dist/grammar/Grammar.d.ts +24 -25
- package/dist/grammar/patterns/grammar.d.ts +99 -0
- package/dist/grammar/patterns/grammar.test.d.ts +1 -0
- package/dist/index.browser.js +2270 -2536
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +2270 -2536
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2270 -2536
- package/dist/index.js.map +1 -1
- package/dist/patterns/Expression.d.ts +3 -2
- package/grammar-guide.md +836 -0
- package/package.json +1 -1
- package/src/grammar/Grammar.test.ts +418 -0
- package/src/grammar/Grammar.ts +483 -515
- package/src/grammar/patterns/grammar.test.ts +276 -0
- package/src/grammar/patterns/grammar.ts +113 -37
- package/src/grammar/patterns.ts +6 -6
- package/src/patterns/Expression.ts +28 -13
- package/src/grammar/patterns/anonymousPattern.ts +0 -23
- package/src/grammar/patterns/body.ts +0 -22
- package/src/grammar/patterns/comment.ts +0 -4
- package/src/grammar/patterns/decoratorStatement.ts +0 -85
- package/src/grammar/patterns/import.ts +0 -88
- package/src/grammar/patterns/literal.ts +0 -4
- package/src/grammar/patterns/literals.ts +0 -21
- package/src/grammar/patterns/name.ts +0 -3
- package/src/grammar/patterns/optionsLiteral.ts +0 -25
- package/src/grammar/patterns/pattern.ts +0 -29
- package/src/grammar/patterns/regexLiteral.ts +0 -5
- package/src/grammar/patterns/repeatLiteral.ts +0 -71
- package/src/grammar/patterns/sequenceLiteral.ts +0 -24
- package/src/grammar/patterns/spaces.ts +0 -16
- package/src/grammar/patterns/statement.ts +0 -22
- package/src/grammar/patterns/takeUtilLiteral.ts +0 -20
- package/src/grammar/spec.md +0 -331
- package/src/grammar_v2/patterns/Grammar.ts +0 -170
- package/src/grammar_v2/patterns/patterns/cpat.cpat +0 -91
- package/src/grammar_v2/patterns/patterns/grammar.test.ts +0 -218
- package/src/grammar_v2/patterns/patterns/grammar.ts +0 -103
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { Literal } from "../../patterns/Literal";
|
|
2
|
-
import { Optional } from "../../patterns/Optional";
|
|
3
|
-
import { Options } from "../../patterns/Options";
|
|
4
|
-
import { Reference } from "../../patterns/Reference";
|
|
5
|
-
import { Regex } from "../../patterns/Regex";
|
|
6
|
-
import { Repeat } from "../../patterns/Repeat";
|
|
7
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
8
|
-
import { name } from "./name";
|
|
9
|
-
import { allSpaces } from "./spaces";
|
|
10
|
-
|
|
11
|
-
const colon = new Literal("colon", ":");
|
|
12
|
-
const comma = new Regex("comma", "\\s*,\\s*");
|
|
13
|
-
const openBracket = new Literal("open-bracket", "{");
|
|
14
|
-
const closeBracket = new Literal("close-bracket", "}");
|
|
15
|
-
const openSquareBracket = new Literal("open-square-bracket", "[");
|
|
16
|
-
const closeSquareBracket = new Literal("close-square-bracket", "]");
|
|
17
|
-
const optionalAllSpaces = new Optional("optional-all-spaces", allSpaces);
|
|
18
|
-
|
|
19
|
-
const stringLiteral = new Regex("string-literal", '"(?:\\\\.|[^"\\\\])*"');
|
|
20
|
-
const numberLiteral = new Regex("number-literal", '[+-]?\\d+(\\.\\d+)?([eE][+-]?\\d+)?');
|
|
21
|
-
const nullLiteral = new Literal("null-literal", "null");
|
|
22
|
-
const trueLiteral = new Literal("true-literal", "true");
|
|
23
|
-
const falseLiteral = new Literal("false-literal", "false");
|
|
24
|
-
const booleanLiteral = new Options("", [trueLiteral, falseLiteral]);
|
|
25
|
-
|
|
26
|
-
const objectKey = stringLiteral.clone("object-key");
|
|
27
|
-
const objectProperty = new Sequence("object-property", [
|
|
28
|
-
objectKey,
|
|
29
|
-
optionalAllSpaces,
|
|
30
|
-
colon,
|
|
31
|
-
optionalAllSpaces,
|
|
32
|
-
new Reference("literal"),
|
|
33
|
-
]);
|
|
34
|
-
const objectProperies = new Repeat("object-properties", objectProperty, { divider: comma });
|
|
35
|
-
const objectLiteral = new Sequence("object-literal", [
|
|
36
|
-
openBracket,
|
|
37
|
-
optionalAllSpaces,
|
|
38
|
-
new Optional("optional-object-properties", objectProperies),
|
|
39
|
-
optionalAllSpaces,
|
|
40
|
-
closeBracket
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
const arrayItems = new Repeat("array-items", new Reference("literal"), { divider: comma });
|
|
44
|
-
const arrayLiteral = new Sequence("array-literal", [
|
|
45
|
-
openSquareBracket,
|
|
46
|
-
optionalAllSpaces,
|
|
47
|
-
new Optional("optional-array-items", arrayItems),
|
|
48
|
-
optionalAllSpaces,
|
|
49
|
-
closeSquareBracket,
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
const literal = new Options("literal", [
|
|
53
|
-
objectLiteral,
|
|
54
|
-
arrayLiteral,
|
|
55
|
-
stringLiteral,
|
|
56
|
-
booleanLiteral,
|
|
57
|
-
nullLiteral,
|
|
58
|
-
numberLiteral,
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
const decoratorPrefix = new Literal("decorator-prefix", "@");
|
|
62
|
-
const decoratorName = name.clone("decorator-name");
|
|
63
|
-
const openParen = new Literal("open-paren", "(");
|
|
64
|
-
const closeParen = new Literal("close-paren", ")");
|
|
65
|
-
|
|
66
|
-
const methodDecoration = new Sequence("method-decorator", [
|
|
67
|
-
decoratorPrefix,
|
|
68
|
-
decoratorName,
|
|
69
|
-
optionalAllSpaces,
|
|
70
|
-
openParen,
|
|
71
|
-
optionalAllSpaces,
|
|
72
|
-
new Optional("optional-args", literal),
|
|
73
|
-
optionalAllSpaces,
|
|
74
|
-
closeParen
|
|
75
|
-
]);
|
|
76
|
-
|
|
77
|
-
const nameDecoration = new Sequence("name-decorator", [
|
|
78
|
-
decoratorPrefix,
|
|
79
|
-
decoratorName,
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
export const decoratorStatement = new Options("decorator-statement", [
|
|
83
|
-
methodDecoration,
|
|
84
|
-
nameDecoration,
|
|
85
|
-
]);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
2
|
-
import { Repeat } from "../../patterns/Repeat";
|
|
3
|
-
import { Literal } from "../../patterns/Literal";
|
|
4
|
-
import { Regex } from "../../patterns/Regex";
|
|
5
|
-
import { literal } from "./literal";
|
|
6
|
-
import { Options } from "../../patterns/Options";
|
|
7
|
-
import { body } from "./body";
|
|
8
|
-
import { allSpaces, lineSpaces } from "./spaces";
|
|
9
|
-
import { Optional } from "../../patterns/Optional";
|
|
10
|
-
|
|
11
|
-
const optionalSpaces = new Optional("optional-spaces", allSpaces);
|
|
12
|
-
const optionalLineSpaces = new Optional("optional-line-spaces", lineSpaces);
|
|
13
|
-
|
|
14
|
-
const importNameDivider = new Regex("import-name-divider", "(\\s+)?,(\\s+)?");
|
|
15
|
-
importNameDivider.setTokens([", "]);
|
|
16
|
-
|
|
17
|
-
const name = new Regex("import-name", "[^}\\s,]+");
|
|
18
|
-
name.setTokens(["[IMPORT_NAME]"]);
|
|
19
|
-
|
|
20
|
-
const importKeyword = new Literal("import", "import");
|
|
21
|
-
const useParamsKeyword = new Literal("use-params", "use params");
|
|
22
|
-
const asKeyword = new Literal("as", "as");
|
|
23
|
-
const fromKeyword = new Literal("from", "from");
|
|
24
|
-
const openBracket = new Literal("open-bracket", "{");
|
|
25
|
-
const closeBracket = new Literal("close-bracket", "}");
|
|
26
|
-
const equal = new Literal("equal", "=");
|
|
27
|
-
|
|
28
|
-
const importNameAlias = name.clone("import-name-alias");
|
|
29
|
-
const importAlias = new Sequence("import-alias", [name, lineSpaces, asKeyword, lineSpaces, importNameAlias]);
|
|
30
|
-
const importedNames = new Repeat("imported-names", new Options("import-names", [importAlias, name]), { divider: importNameDivider });
|
|
31
|
-
const paramName = name.clone("param-name");
|
|
32
|
-
const defaultParamName = name.clone("default-param-name");
|
|
33
|
-
|
|
34
|
-
const paramNameWithDefault = new Sequence("param-name-with-default-value", [
|
|
35
|
-
paramName,
|
|
36
|
-
new Optional("optional-param-default", new Sequence("param-default", [
|
|
37
|
-
optionalLineSpaces,
|
|
38
|
-
equal,
|
|
39
|
-
optionalLineSpaces,
|
|
40
|
-
defaultParamName,
|
|
41
|
-
])),
|
|
42
|
-
]);
|
|
43
|
-
const paramNames = new Repeat("param-names", paramNameWithDefault, { divider: importNameDivider });
|
|
44
|
-
const resource = literal.clone("resource");
|
|
45
|
-
|
|
46
|
-
const useParams = new Sequence("import-params", [
|
|
47
|
-
useParamsKeyword,
|
|
48
|
-
optionalLineSpaces,
|
|
49
|
-
openBracket,
|
|
50
|
-
optionalSpaces,
|
|
51
|
-
paramNames,
|
|
52
|
-
optionalSpaces,
|
|
53
|
-
closeBracket
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
const withParamsKeyword = new Literal("with-params", "with params");
|
|
57
|
-
const withParamsStatement = new Optional("optional-with-params-statement", new Sequence("with-params-statement", [
|
|
58
|
-
withParamsKeyword,
|
|
59
|
-
optionalLineSpaces,
|
|
60
|
-
openBracket,
|
|
61
|
-
optionalSpaces,
|
|
62
|
-
body,
|
|
63
|
-
optionalSpaces,
|
|
64
|
-
closeBracket
|
|
65
|
-
]));
|
|
66
|
-
|
|
67
|
-
const importFromStatement = new Sequence("import-from", [
|
|
68
|
-
importKeyword,
|
|
69
|
-
optionalLineSpaces,
|
|
70
|
-
openBracket,
|
|
71
|
-
optionalSpaces,
|
|
72
|
-
importedNames,
|
|
73
|
-
optionalSpaces,
|
|
74
|
-
closeBracket,
|
|
75
|
-
optionalLineSpaces,
|
|
76
|
-
fromKeyword,
|
|
77
|
-
optionalLineSpaces,
|
|
78
|
-
resource,
|
|
79
|
-
optionalLineSpaces,
|
|
80
|
-
withParamsStatement
|
|
81
|
-
]);
|
|
82
|
-
|
|
83
|
-
export const importStatement = new Options("import-statement", [
|
|
84
|
-
useParams,
|
|
85
|
-
importFromStatement
|
|
86
|
-
]);
|
|
87
|
-
|
|
88
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Options } from "../../patterns/Options";
|
|
2
|
-
import { Reference } from "../../patterns/Reference";
|
|
3
|
-
import { literal } from "./literal";
|
|
4
|
-
import { name } from "./name";
|
|
5
|
-
import { regexLiteral } from "./regexLiteral";
|
|
6
|
-
|
|
7
|
-
const patternName = name.clone("pattern-name");
|
|
8
|
-
|
|
9
|
-
export const anonymousLiterals = new Options("anonymous-literals", [
|
|
10
|
-
literal,
|
|
11
|
-
regexLiteral,
|
|
12
|
-
patternName,
|
|
13
|
-
new Reference("repeat-literal"),
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
export const anonymousWrappedLiterals = new Options("anonymous-wrapped-literals", [
|
|
17
|
-
new Reference("take-until-literal"),
|
|
18
|
-
new Reference("options-literal"),
|
|
19
|
-
new Reference("sequence-literal"),
|
|
20
|
-
new Reference("complex-anonymous-pattern")
|
|
21
|
-
]);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Repeat } from "../../patterns/Repeat";
|
|
2
|
-
import { Regex } from "../../patterns/Regex";
|
|
3
|
-
import { name } from "./name";
|
|
4
|
-
import { anonymousPattern } from "./anonymousPattern";
|
|
5
|
-
import { Options } from "../../patterns/Options";
|
|
6
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
7
|
-
import { Optional } from "../../patterns/Optional";
|
|
8
|
-
import { Literal } from "../../patterns/Literal";
|
|
9
|
-
|
|
10
|
-
const patternName = name.clone("pattern-name");
|
|
11
|
-
patternName.setTokens(["[PATTERN_NAME]"]);
|
|
12
|
-
|
|
13
|
-
const patterns = new Sequence("patterns", [
|
|
14
|
-
new Options("options-patterns", [patternName, anonymousPattern]),
|
|
15
|
-
new Optional("optional-right-associated", new Literal("right-associated", " right"))
|
|
16
|
-
]);
|
|
17
|
-
const defaultDivider = new Regex("default-divider", "\\s*[|]\\s*");
|
|
18
|
-
defaultDivider.setTokens(["|"]);
|
|
19
|
-
|
|
20
|
-
const greedyDivider = new Regex("greedy-divider", "\\s*[<][|][>]\\s*");
|
|
21
|
-
greedyDivider.setTokens(["<|>"]);
|
|
22
|
-
|
|
23
|
-
const divider = new Options("options-divider", [defaultDivider, greedyDivider]);
|
|
24
|
-
|
|
25
|
-
export const optionsLiteral = new Repeat("options-literal", patterns, { divider, min: 2, trimDivider: true });
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Options } from "../../patterns/Options";
|
|
2
|
-
import { literal } from "./literal";
|
|
3
|
-
import { regexLiteral } from "./regexLiteral";
|
|
4
|
-
import { repeatLiteral } from "./repeatLiteral";
|
|
5
|
-
import { sequenceLiteral } from "./sequenceLiteral";
|
|
6
|
-
import { optionsLiteral } from "./optionsLiteral";
|
|
7
|
-
import { anonymousPattern } from "./anonymousPattern";
|
|
8
|
-
import { takeUntilLiteral } from "./takeUtilLiteral";
|
|
9
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
10
|
-
import { Literal } from "../../patterns/Literal";
|
|
11
|
-
import { name } from "./name";
|
|
12
|
-
import { Optional } from "../../patterns/Optional";
|
|
13
|
-
|
|
14
|
-
const aliasLiteral = name.clone("alias-literal");
|
|
15
|
-
aliasLiteral.setTokens(["[ALIAS_LITERAL]"]);
|
|
16
|
-
|
|
17
|
-
const optionalIsOptional = new Optional("optional-flag", new Literal("is-optional", "?"));
|
|
18
|
-
const configurableAnonymousPattern = new Sequence("configurable-anonymous-pattern", [anonymousPattern, optionalIsOptional]);
|
|
19
|
-
|
|
20
|
-
export const pattern = new Options("pattern", [
|
|
21
|
-
literal,
|
|
22
|
-
regexLiteral,
|
|
23
|
-
repeatLiteral,
|
|
24
|
-
takeUntilLiteral,
|
|
25
|
-
aliasLiteral,
|
|
26
|
-
optionsLiteral,
|
|
27
|
-
sequenceLiteral,
|
|
28
|
-
configurableAnonymousPattern,
|
|
29
|
-
], true);
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
2
|
-
import { Literal } from "../../patterns/Literal";
|
|
3
|
-
import { Options } from "../../patterns/Options";
|
|
4
|
-
import { Regex } from "../../patterns/Regex";
|
|
5
|
-
import { anonymousPattern } from "./anonymousPattern";
|
|
6
|
-
import { name } from "./name";
|
|
7
|
-
import { lineSpaces, spaces } from "./spaces";
|
|
8
|
-
import { Optional } from "../../patterns/Optional";
|
|
9
|
-
|
|
10
|
-
const optionalSpaces = new Optional("optional-spaces", spaces);
|
|
11
|
-
const openBracket = new Literal("repeat-open-bracket", "{");
|
|
12
|
-
const closeBracket = new Literal("repeat-close-bracket", "}");
|
|
13
|
-
const comma = new Literal("comma", ",");
|
|
14
|
-
|
|
15
|
-
const integer = new Regex("integer", "([1-9][0-9]*)|0");
|
|
16
|
-
integer.setTokens(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]);
|
|
17
|
-
|
|
18
|
-
const min = new Optional("optional-min", integer.clone("min"));
|
|
19
|
-
const max = new Optional("optional-max", integer.clone("max"));
|
|
20
|
-
const trimKeyword = new Literal("trim-keyword", "trim");
|
|
21
|
-
const trimFlag = new Optional("optional-trim-flag", new Sequence("trim-flag", [lineSpaces, trimKeyword]));
|
|
22
|
-
|
|
23
|
-
const bounds = new Sequence("bounds", [
|
|
24
|
-
openBracket,
|
|
25
|
-
optionalSpaces,
|
|
26
|
-
min,
|
|
27
|
-
optionalSpaces,
|
|
28
|
-
comma,
|
|
29
|
-
optionalSpaces,
|
|
30
|
-
max,
|
|
31
|
-
closeBracket
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
const exactCount = new Sequence("exact-count", [
|
|
35
|
-
openBracket,
|
|
36
|
-
optionalSpaces,
|
|
37
|
-
integer,
|
|
38
|
-
optionalSpaces,
|
|
39
|
-
closeBracket,
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
const quantifierShorthand = new Regex("quantifier-shorthand", "\\*|\\+");
|
|
43
|
-
quantifierShorthand.setTokens(["*", "+"]);
|
|
44
|
-
|
|
45
|
-
const quantifier = new Options("quantifier", [
|
|
46
|
-
quantifierShorthand,
|
|
47
|
-
exactCount,
|
|
48
|
-
bounds
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
const openParen = new Literal("repeat-open-paren", "(");
|
|
52
|
-
const closeParen = new Literal("repeat-close-paren", ")");
|
|
53
|
-
const dividerComma = new Regex("divider-comma", "\\s*,\\s*");
|
|
54
|
-
dividerComma.setTokens([", "]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const patternName = name.clone("pattern-name");
|
|
58
|
-
const repeatPattern = new Options("repeat-pattern", [patternName, anonymousPattern]);
|
|
59
|
-
const repeatDividerPattern = repeatPattern.clone("repeat-divider-pattern");
|
|
60
|
-
const repeatDividerSection = new Sequence("repeat-divider-section", [dividerComma, repeatDividerPattern, trimFlag]);
|
|
61
|
-
const repeatOptionalDividerSection = new Optional("repeat-optional-divider-section", repeatDividerSection);
|
|
62
|
-
|
|
63
|
-
export const repeatLiteral = new Sequence("repeat-literal", [
|
|
64
|
-
openParen,
|
|
65
|
-
optionalSpaces,
|
|
66
|
-
repeatPattern,
|
|
67
|
-
repeatOptionalDividerSection,
|
|
68
|
-
optionalSpaces,
|
|
69
|
-
closeParen,
|
|
70
|
-
new Sequence("quantifier-section", [quantifier]),
|
|
71
|
-
]);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Repeat } from "../../patterns/Repeat";
|
|
2
|
-
import { Regex } from "../../patterns/Regex";
|
|
3
|
-
import { name } from "./name";
|
|
4
|
-
import { anonymousPattern } from "./anonymousPattern";
|
|
5
|
-
import { Options } from "../../patterns/Options";
|
|
6
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
7
|
-
import { Literal } from "../../patterns/Literal";
|
|
8
|
-
import { Optional } from "../../patterns/Optional";
|
|
9
|
-
|
|
10
|
-
const optionalNot = new Optional("optional-not", new Literal("not", "!"));
|
|
11
|
-
const optionalIsOptional = new Optional("optional-is-optional", new Literal("is-optional", "?"));
|
|
12
|
-
const patternName = name.clone("pattern-name");
|
|
13
|
-
const patterns = new Options("sequence-patterns", [patternName, anonymousPattern]);
|
|
14
|
-
|
|
15
|
-
export const pattern = new Sequence("sequence-child-pattern", [
|
|
16
|
-
optionalNot,
|
|
17
|
-
patterns,
|
|
18
|
-
optionalIsOptional,
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
const divider = new Regex("sequence-divider", "\\s*[+]\\s*");
|
|
22
|
-
divider.setTokens([" + "]);
|
|
23
|
-
|
|
24
|
-
export const sequenceLiteral = new Repeat("sequence-literal", pattern, { divider, min: 2, trimDivider: true });
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Options } from "../../patterns/Options";
|
|
2
|
-
import { Regex } from "../../patterns/Regex";
|
|
3
|
-
import { Repeat } from "../../patterns/Repeat";
|
|
4
|
-
|
|
5
|
-
export const tabs = new Regex("tabs", "\\t+");
|
|
6
|
-
tabs.setTokens(["\t"]);
|
|
7
|
-
|
|
8
|
-
export const spaces = new Regex("spaces", "[ ]+");
|
|
9
|
-
spaces.setTokens([" "]);
|
|
10
|
-
|
|
11
|
-
export const newLine = new Regex("new-line", "(\\r?\\n)+");
|
|
12
|
-
newLine.setTokens(["\n"]);
|
|
13
|
-
|
|
14
|
-
export const lineSpaces = new Repeat("line-spaces", new Options("line-space", [tabs, spaces]));
|
|
15
|
-
export const allSpaces = new Regex("all-spaces", "\\s+");
|
|
16
|
-
allSpaces.setTokens([" "]);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
2
|
-
import { Literal } from "../../patterns/Literal";
|
|
3
|
-
import { Options } from "../../patterns/Options";
|
|
4
|
-
import { name } from "./name";
|
|
5
|
-
import { spaces } from "./spaces";
|
|
6
|
-
import { pattern } from "./pattern";
|
|
7
|
-
import { Optional } from "../../patterns/Optional";
|
|
8
|
-
import {decoratorStatement} from './decoratorStatement';
|
|
9
|
-
|
|
10
|
-
const optionalSpaces = new Optional("optional-spaces", spaces);
|
|
11
|
-
const assignOperator = new Literal("assign-operator", "=");
|
|
12
|
-
|
|
13
|
-
const assignStatement = new Sequence("assign-statement", [
|
|
14
|
-
optionalSpaces,
|
|
15
|
-
name,
|
|
16
|
-
optionalSpaces,
|
|
17
|
-
assignOperator,
|
|
18
|
-
optionalSpaces,
|
|
19
|
-
pattern,
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
export const statement = new Options("statement", [decoratorStatement, assignStatement, name.clone("export-name")]);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Literal } from "../../patterns/Literal"
|
|
2
|
-
import { Optional } from "../../patterns/Optional";
|
|
3
|
-
import { Sequence } from "../../patterns/Sequence";
|
|
4
|
-
import { lineSpaces } from "./spaces";
|
|
5
|
-
import { Reference } from "../../patterns/Reference";
|
|
6
|
-
|
|
7
|
-
const anyChar = new Literal("any-char", "?");
|
|
8
|
-
const upTo = new Literal("up-to", "->");
|
|
9
|
-
const wall = new Literal("wall", "|");
|
|
10
|
-
const optionalLineSpaces = new Optional("optional-line-spaces", lineSpaces);
|
|
11
|
-
|
|
12
|
-
export const takeUntilLiteral = new Sequence("take-until-literal", [
|
|
13
|
-
anyChar,
|
|
14
|
-
optionalLineSpaces,
|
|
15
|
-
upTo,
|
|
16
|
-
optionalLineSpaces,
|
|
17
|
-
wall,
|
|
18
|
-
optionalLineSpaces,
|
|
19
|
-
new Reference("pattern")
|
|
20
|
-
]);
|