clarity-pattern-parser 4.0.3 → 5.0.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/README.md +176 -1
- package/TODO.md +22 -2
- package/dist/ast/Node.d.ts +43 -11
- package/dist/ast/Visitor.d.ts +31 -31
- package/dist/index.browser.js +1248 -1495
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +12 -17
- package/dist/index.esm.js +1218 -1460
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1217 -1464
- package/dist/index.js.map +1 -1
- package/dist/patterns/And.d.ts +37 -24
- package/dist/patterns/Cursor.d.ts +35 -0
- package/dist/patterns/CursorHistory.d.ts +30 -0
- package/dist/patterns/Literal.d.ts +36 -19
- package/dist/patterns/Not.d.ts +26 -11
- package/dist/patterns/Or.d.ts +31 -22
- package/dist/patterns/ParseError.d.ts +6 -8
- package/dist/patterns/ParseResult.d.ts +6 -0
- package/dist/patterns/Pattern.d.ts +17 -26
- package/dist/patterns/Reference.d.ts +31 -12
- package/dist/patterns/Regex.d.ts +42 -21
- package/dist/patterns/Repeat.d.ts +38 -20
- package/dist/patterns/clonePatterns.d.ts +2 -0
- package/dist/patterns/filterOutNull.d.ts +2 -0
- package/dist/patterns/findPattern.d.ts +2 -0
- package/dist/patterns/getNextPattern.d.ts +2 -0
- package/jest.config.js +2 -1
- package/package.json +4 -5
- package/rollup.config.js +1 -1
- package/src/ast/Node.test.ts +254 -0
- package/src/ast/Node.ts +171 -23
- package/src/index.ts +11 -24
- package/src/intellisense/AutoComplete.test.ts +72 -0
- package/src/intellisense/AutoComplete.ts +146 -0
- package/src/intellisense/Suggestion.ts +13 -0
- package/src/intellisense/SuggestionOption.ts +4 -0
- package/src/{tests/cssPatterns → intellisense/css}/cssValue.ts +1 -1
- package/src/{tests/cssPatterns → intellisense/css}/divider.ts +2 -1
- package/src/intellisense/css/hex.ts +6 -0
- package/src/{tests/cssPatterns → intellisense/css}/method.ts +8 -9
- package/src/intellisense/css/name.ts +5 -0
- package/src/{tests/javascriptPatterns → intellisense/css}/number.ts +3 -3
- package/src/intellisense/css/spaces.ts +6 -0
- package/src/intellisense/css/unit.ts +10 -0
- package/src/{tests/cssPatterns → intellisense/css}/value.ts +1 -1
- package/src/{tests/cssPatterns → intellisense/css}/values.ts +1 -1
- package/src/intellisense/javascript/Javascript.test.ts +203 -0
- package/src/intellisense/javascript/arrayLiteral.ts +25 -0
- package/src/intellisense/javascript/deleteStatement.ts +14 -0
- package/src/intellisense/javascript/escapedCharacter.ts +50 -0
- package/src/intellisense/javascript/exponent.ts +26 -0
- package/src/intellisense/javascript/expression.ts +87 -0
- package/src/intellisense/javascript/expressionStatement.ts +29 -0
- package/src/intellisense/javascript/fraction.ts +13 -0
- package/src/intellisense/javascript/infixOperator.ts +36 -0
- package/src/intellisense/javascript/integer.ts +7 -0
- package/src/intellisense/javascript/invocation.ts +28 -0
- package/src/intellisense/javascript/literal.ts +14 -0
- package/src/intellisense/javascript/name.ts +3 -0
- package/src/intellisense/javascript/numberLiteral.ts +10 -0
- package/src/intellisense/javascript/objectLiteral.ts +30 -0
- package/src/intellisense/javascript/optionalSpaces.ts +3 -0
- package/src/intellisense/javascript/parameters.ts +20 -0
- package/src/intellisense/javascript/prefixOperator.ts +13 -0
- package/src/intellisense/javascript/propertyAccess.ts +23 -0
- package/src/intellisense/javascript/stringLiteral.ts +28 -0
- package/src/patterns/And.test.ts +299 -0
- package/src/patterns/And.ts +222 -119
- package/src/patterns/Cursor.test.ts +93 -0
- package/src/patterns/Cursor.ts +130 -0
- package/src/patterns/CursorHistory.test.ts +54 -0
- package/src/patterns/CursorHistory.ts +95 -0
- package/src/patterns/Literal.test.ts +134 -0
- package/src/patterns/Literal.ts +151 -61
- package/src/patterns/Not.test.ts +88 -0
- package/src/patterns/Not.ts +74 -33
- package/src/patterns/Or.test.ts +105 -0
- package/src/patterns/Or.ts +106 -98
- package/src/patterns/ParseError.ts +3 -7
- package/src/patterns/ParseResult.ts +7 -0
- package/src/patterns/Pattern.ts +18 -150
- package/src/patterns/Reference.test.ts +104 -0
- package/src/patterns/Reference.ts +94 -94
- package/src/patterns/Regex.test.ts +101 -0
- package/src/patterns/Regex.ts +129 -60
- package/src/patterns/Repeat.test.ts +196 -0
- package/src/patterns/Repeat.ts +208 -104
- package/src/patterns/clonePatterns.ts +5 -0
- package/src/patterns/filterOutNull.ts +13 -0
- package/src/patterns/findPattern.ts +25 -0
- package/src/patterns/getNextPattern.test.ts +39 -0
- package/src/patterns/getNextPattern.ts +18 -0
- package/src/Cursor.ts +0 -141
- package/src/CursorHistory.ts +0 -146
- package/src/TextSuggester.ts +0 -317
- package/src/ast/Visitor.ts +0 -271
- package/src/patterns/LookAhead.ts +0 -32
- package/src/patterns/Recursive.ts +0 -92
- package/src/tests/And.test.ts +0 -180
- package/src/tests/ComplexExamples.test.ts +0 -86
- package/src/tests/CssPatterns.test.ts +0 -90
- package/src/tests/CursorHistory.test.ts +0 -107
- package/src/tests/Cusor.test.ts +0 -174
- package/src/tests/HtmlPatterns.test.ts +0 -34
- package/src/tests/Literal.test.ts +0 -79
- package/src/tests/LookAhead.test.ts +0 -44
- package/src/tests/Not.test.ts +0 -51
- package/src/tests/Or.test.ts +0 -113
- package/src/tests/Pattern.test.ts +0 -290
- package/src/tests/Recursive.test.ts +0 -64
- package/src/tests/Reference.test.ts +0 -16
- package/src/tests/Repeat.test.ts +0 -75
- package/src/tests/SpeedTest.test.ts +0 -31
- package/src/tests/TextSuggester.test.ts +0 -297
- package/src/tests/Visitor.test.ts +0 -331
- package/src/tests/cssPatterns/hex.ts +0 -5
- package/src/tests/cssPatterns/name.ts +0 -5
- package/src/tests/cssPatterns/number.ts +0 -8
- package/src/tests/cssPatterns/spaces.ts +0 -5
- package/src/tests/cssPatterns/unit.ts +0 -8
- package/src/tests/htmlPatterns/element.ts +0 -49
- package/src/tests/javascriptPatterns/boolean.ts +0 -10
- package/src/tests/javascriptPatterns/json.ts +0 -67
- package/src/tests/javascriptPatterns/name.ts +0 -5
- package/src/tests/javascriptPatterns/objectLiteral.ts +0 -40
- package/src/tests/javascriptPatterns/string.ts +0 -84
- package/src/tests/javascriptPatterns/unit.ts +0 -8
- package/src/tests/javascriptPatterns/whitespace.ts +0 -44
- package/src/tests/naturalLanguage/filter.ts +0 -37
- package/src/tests/patterns/sentence.ts +0 -37
- /package/src/{tests/cssPatterns → intellisense/css}/optionalSpaces.ts +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Literal, And, Or, Regex, Repeat, Recursive } from "../../index";
|
|
2
|
-
|
|
3
|
-
const attributeName = new Regex("attribute-name", "[a-zA-Z_:]+[a-zA-Z0-9_]*");
|
|
4
|
-
|
|
5
|
-
const doubleQuote = new Literal("double-quote", '"');
|
|
6
|
-
const greaterThan = new Literal("greater-than", ">");
|
|
7
|
-
const lessThan = new Literal("less-than", "<");
|
|
8
|
-
const forwardSlash = new Literal("forward-slash", "/");
|
|
9
|
-
const equal = new Literal("equal", "=");
|
|
10
|
-
const spaces = new Regex(" ", "\\s+", true);
|
|
11
|
-
const optionalSpaces = spaces.clone("optional-spaces", true);
|
|
12
|
-
const value = new Regex("value", '[^"]+');
|
|
13
|
-
|
|
14
|
-
export const attribute = new And("attribute", [
|
|
15
|
-
attributeName,
|
|
16
|
-
equal,
|
|
17
|
-
doubleQuote,
|
|
18
|
-
value,
|
|
19
|
-
doubleQuote,
|
|
20
|
-
]);
|
|
21
|
-
const optionalAttributes = new Repeat("attributes", attribute, spaces, true);
|
|
22
|
-
|
|
23
|
-
const elementName = new Regex("element-name", "[a-zA-Z]+[a-zA-Z-]*");
|
|
24
|
-
const text = new Regex("text", "[^<>]+");
|
|
25
|
-
const recursiveElement = new Recursive("element");
|
|
26
|
-
|
|
27
|
-
const elementContent = new Repeat(
|
|
28
|
-
"children",
|
|
29
|
-
new Or("content", [text, recursiveElement]),
|
|
30
|
-
undefined,
|
|
31
|
-
true
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const element = new And("element", [
|
|
35
|
-
lessThan,
|
|
36
|
-
elementName.clone("open-element-name"),
|
|
37
|
-
optionalSpaces,
|
|
38
|
-
optionalAttributes,
|
|
39
|
-
optionalSpaces,
|
|
40
|
-
greaterThan,
|
|
41
|
-
elementContent,
|
|
42
|
-
lessThan,
|
|
43
|
-
forwardSlash,
|
|
44
|
-
elementName.clone("close-element-name"),
|
|
45
|
-
optionalSpaces,
|
|
46
|
-
greaterThan,
|
|
47
|
-
]);
|
|
48
|
-
|
|
49
|
-
export default element;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Literal, And, Repeat, Or, Recursive } from "../../index";
|
|
2
|
-
|
|
3
|
-
import string from "./string";
|
|
4
|
-
import number from "./number";
|
|
5
|
-
import boolean from "./boolean";
|
|
6
|
-
|
|
7
|
-
const openCurlyBracket = new Literal("open-curly-bracket", "{");
|
|
8
|
-
const closeCurlyBracket = new Literal("close-curly-bracket", "}");
|
|
9
|
-
const openSquareBracket = new Literal("open-square-bracket", "[");
|
|
10
|
-
const closeSquareBracket = new Literal("close-square-bracket", "]");
|
|
11
|
-
const colon = new Literal(":", ":");
|
|
12
|
-
const space = new Literal("space", " ");
|
|
13
|
-
const spaces = new Repeat("spaces", space);
|
|
14
|
-
const optionalSpaces = spaces.clone("optional-spaces", true);
|
|
15
|
-
const nullLiteral = new Literal("null", "null");
|
|
16
|
-
const comma = new Literal(",", ",");
|
|
17
|
-
|
|
18
|
-
const divider = new And("divider", [
|
|
19
|
-
optionalSpaces,
|
|
20
|
-
comma,
|
|
21
|
-
optionalSpaces,
|
|
22
|
-
]);
|
|
23
|
-
|
|
24
|
-
const arrayValues = new Repeat(
|
|
25
|
-
"values",
|
|
26
|
-
new Recursive("literals"),
|
|
27
|
-
divider
|
|
28
|
-
);
|
|
29
|
-
const optionalArrayValues = arrayValues.clone("optional-values", true);
|
|
30
|
-
|
|
31
|
-
const arrayLiteral = new And("array-literal", [
|
|
32
|
-
openSquareBracket,
|
|
33
|
-
optionalSpaces,
|
|
34
|
-
optionalArrayValues,
|
|
35
|
-
optionalSpaces,
|
|
36
|
-
closeSquareBracket,
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
const keyValue = new And("key-value", [
|
|
40
|
-
string,
|
|
41
|
-
optionalSpaces,
|
|
42
|
-
colon,
|
|
43
|
-
optionalSpaces,
|
|
44
|
-
new Recursive("literals"),
|
|
45
|
-
]);
|
|
46
|
-
|
|
47
|
-
const keyValues = new Repeat("key-values", keyValue, divider);
|
|
48
|
-
const optionalKeyValues = keyValues.clone("optional-key-values", true);
|
|
49
|
-
|
|
50
|
-
const objectLiteral = new And("object-literal", [
|
|
51
|
-
openCurlyBracket,
|
|
52
|
-
optionalSpaces,
|
|
53
|
-
optionalKeyValues,
|
|
54
|
-
optionalSpaces,
|
|
55
|
-
closeCurlyBracket,
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
|
-
const json = new Or("literals", [
|
|
59
|
-
number,
|
|
60
|
-
string,
|
|
61
|
-
boolean,
|
|
62
|
-
nullLiteral,
|
|
63
|
-
objectLiteral,
|
|
64
|
-
arrayLiteral,
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
export default json;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {Literal, And, Repeat, Or, Recursive} from "../../index";
|
|
2
|
-
import name from "./name";
|
|
3
|
-
import string from "./string";
|
|
4
|
-
import whitespace from "./whitespace";
|
|
5
|
-
|
|
6
|
-
const expression = new Recursive("expression");
|
|
7
|
-
const optionalWhitespace = whitespace.clone("optional-whitespaces", true);
|
|
8
|
-
const comma = new Literal(",", ",");
|
|
9
|
-
const colon = new Literal(":", ":");
|
|
10
|
-
|
|
11
|
-
const separator = new And("separator", [
|
|
12
|
-
optionalWhitespace,
|
|
13
|
-
comma,
|
|
14
|
-
optionalWhitespace,
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
const property = new Or("property", [name, string]);
|
|
18
|
-
|
|
19
|
-
const keyValue = new And("key-value", [
|
|
20
|
-
property,
|
|
21
|
-
optionalWhitespace,
|
|
22
|
-
colon,
|
|
23
|
-
optionalWhitespace,
|
|
24
|
-
expression,
|
|
25
|
-
]);
|
|
26
|
-
|
|
27
|
-
const keyValues = new Repeat("key-values", keyValue, separator);
|
|
28
|
-
const optionalKeyValues = keyValues.clone("optional-key-values", true);
|
|
29
|
-
const openBracket = new Literal("{", "}");
|
|
30
|
-
const closeBracket = new Literal("}", "}");
|
|
31
|
-
|
|
32
|
-
const objectLiteral = new And("object-literal", [
|
|
33
|
-
openBracket,
|
|
34
|
-
optionalWhitespace,
|
|
35
|
-
optionalKeyValues,
|
|
36
|
-
optionalWhitespace,
|
|
37
|
-
closeBracket,
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
|
-
export default objectLiteral;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { Literal, Not, Or, Repeat, And, Regex } from "../../index";
|
|
2
|
-
|
|
3
|
-
const singleQuote = new Literal("single-quote", "'");
|
|
4
|
-
const doubleQuote = new Literal("double-quote", '"');
|
|
5
|
-
const backslash = new Literal("double-quote", "\\");
|
|
6
|
-
|
|
7
|
-
const singleQuoteOrBackslash = new Or("single-quote-or-backslash", [
|
|
8
|
-
singleQuote,
|
|
9
|
-
backslash,
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
const doubleQuoteOrBackslash = new Or("single-quote-or-backslash", [
|
|
13
|
-
doubleQuote,
|
|
14
|
-
backslash,
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
const unescapedSingleCharacter = new Regex(
|
|
18
|
-
"unescaped-single-character",
|
|
19
|
-
"[^'\\\\]"
|
|
20
|
-
);
|
|
21
|
-
const unescapedDoubleCharacter = new Regex(
|
|
22
|
-
"unescaped-double-character",
|
|
23
|
-
`[^"\\\\]`
|
|
24
|
-
);
|
|
25
|
-
const escapedSingleQuote = new Literal("escaped-single-quote", "\\'");
|
|
26
|
-
const escapedDoubleQuote = new Literal("escaped-double-quote", '\\"');
|
|
27
|
-
const escapedBackslash = new Literal("escaped-backslash", "\\/");
|
|
28
|
-
const escapedSlash = new Literal("escaped-slash", "\\/");
|
|
29
|
-
const escapedBackspace = new Literal("escaped-backspace", "\\b");
|
|
30
|
-
const escapedformFeed = new Literal("escaped-form-feed", "\\f");
|
|
31
|
-
const escapedNewLine = new Literal("escaped-new-line", "\\n");
|
|
32
|
-
const escapedCarriageReturn = new Literal("escaped-carriage-return", "\\r");
|
|
33
|
-
const escapedTab = new Literal("escaped-tab", "\\t");
|
|
34
|
-
|
|
35
|
-
const singleQuoteCharacter = new Or("character", [
|
|
36
|
-
escapedSingleQuote,
|
|
37
|
-
escapedDoubleQuote,
|
|
38
|
-
escapedBackslash,
|
|
39
|
-
escapedSlash,
|
|
40
|
-
escapedBackspace,
|
|
41
|
-
escapedformFeed,
|
|
42
|
-
escapedNewLine,
|
|
43
|
-
escapedCarriageReturn,
|
|
44
|
-
escapedTab,
|
|
45
|
-
unescapedSingleCharacter,
|
|
46
|
-
]);
|
|
47
|
-
|
|
48
|
-
const doubleQuoteCharacter = new Or("character", [
|
|
49
|
-
escapedSingleQuote,
|
|
50
|
-
escapedDoubleQuote,
|
|
51
|
-
escapedBackslash,
|
|
52
|
-
escapedSlash,
|
|
53
|
-
escapedBackspace,
|
|
54
|
-
escapedformFeed,
|
|
55
|
-
escapedNewLine,
|
|
56
|
-
escapedCarriageReturn,
|
|
57
|
-
escapedTab,
|
|
58
|
-
unescapedDoubleCharacter,
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
const singleCharacterSequence = new Repeat(
|
|
62
|
-
"string-content",
|
|
63
|
-
singleQuoteCharacter
|
|
64
|
-
);
|
|
65
|
-
const doubleCharacterSequence = new Repeat(
|
|
66
|
-
"string-content",
|
|
67
|
-
doubleQuoteCharacter
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const singleQuoteString = new And("single-quote-string", [
|
|
71
|
-
singleQuote,
|
|
72
|
-
singleCharacterSequence,
|
|
73
|
-
singleQuote,
|
|
74
|
-
]);
|
|
75
|
-
|
|
76
|
-
const doubleQuoteString = new And("double-quote-string", [
|
|
77
|
-
doubleQuote,
|
|
78
|
-
doubleCharacterSequence,
|
|
79
|
-
doubleQuote,
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
const string = new Or("string", [singleQuoteString, doubleQuoteString]);
|
|
83
|
-
|
|
84
|
-
export default string;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Literal, Or, Repeat, And, Regex} from "../../index";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const space = new Literal("space", " ");
|
|
5
|
-
const tab = new Literal("tab", "\t");
|
|
6
|
-
const newLine = new Literal("new-line", "\n");
|
|
7
|
-
const carriageReturn = new Literal("carriage-return", "\r");
|
|
8
|
-
const windowsReturn = new Literal("windows-return", "\r\n");
|
|
9
|
-
const doubleForwardSlash = new Literal("double-forward-slash", "//");
|
|
10
|
-
const slashStar = new Literal("slash-star", "/*");
|
|
11
|
-
const starSlash = new Literal("star-slash", "*/");
|
|
12
|
-
|
|
13
|
-
const lineEnd = new Or("lineEnd", [
|
|
14
|
-
windowsReturn,
|
|
15
|
-
newLine,
|
|
16
|
-
carriageReturn
|
|
17
|
-
]);
|
|
18
|
-
|
|
19
|
-
const lineCommentContent = new Repeat("line-comment-content", new Regex("not-line-end", "[^\r][^\n]|[^\n]"));
|
|
20
|
-
const blockCommentContent = new Repeat("block-comment-content", new Regex("not-start-slash", "[^*][^/]"));
|
|
21
|
-
|
|
22
|
-
const lineComment = new And("line-comment", [
|
|
23
|
-
doubleForwardSlash,
|
|
24
|
-
lineCommentContent,
|
|
25
|
-
lineEnd
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
const blockComment = new And("block-comment", [
|
|
29
|
-
slashStar,
|
|
30
|
-
blockCommentContent,
|
|
31
|
-
starSlash
|
|
32
|
-
]);
|
|
33
|
-
|
|
34
|
-
const whitespace = new Or("whitespace", [
|
|
35
|
-
space,
|
|
36
|
-
tab,
|
|
37
|
-
lineComment,
|
|
38
|
-
blockComment
|
|
39
|
-
]);
|
|
40
|
-
|
|
41
|
-
export default whitespace;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Literal, Or, And } from "../../index";
|
|
2
|
-
import name from "../javascriptPatterns/name";
|
|
3
|
-
import number from "../javascriptPatterns/number";
|
|
4
|
-
import string from "../javascriptPatterns/string";
|
|
5
|
-
|
|
6
|
-
const space = new Literal("space", " ");
|
|
7
|
-
const equalTo = new Literal("=", "is");
|
|
8
|
-
const notEqualTo = new Literal("!=", "is not");
|
|
9
|
-
const isGreaterThan = new Literal(">", "is greater than");
|
|
10
|
-
const isLessThan = new Literal("<", "is less than");
|
|
11
|
-
const isGreaterThanOrEqualTo = new Literal(">=", "is greater or the same as");
|
|
12
|
-
const isLessThanOrEqualTo = new Literal("<=", "is less than or the same as");
|
|
13
|
-
const startsWith = new Literal("starts-with", "starts with");
|
|
14
|
-
const endsWith = new Literal("ends-with", "ends with");
|
|
15
|
-
const contains = new Literal("contains", "has");
|
|
16
|
-
|
|
17
|
-
const value = new Or("value", [number, string, name]);
|
|
18
|
-
|
|
19
|
-
const operator = new Or("operator", [
|
|
20
|
-
equalTo,
|
|
21
|
-
notEqualTo,
|
|
22
|
-
isGreaterThan,
|
|
23
|
-
isLessThan,
|
|
24
|
-
isGreaterThanOrEqualTo,
|
|
25
|
-
isLessThanOrEqualTo,
|
|
26
|
-
startsWith,
|
|
27
|
-
endsWith,
|
|
28
|
-
contains,
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const predicate = new And("predicate", [name, space, operator, space, value]);
|
|
32
|
-
|
|
33
|
-
const match = new Literal("match", "Match records where");
|
|
34
|
-
|
|
35
|
-
const filter = new And("filter", [match, space, predicate]);
|
|
36
|
-
|
|
37
|
-
export default filter;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Literal, And, Or } from "../../index";
|
|
2
|
-
|
|
3
|
-
const pat = new Literal("pat", "Pat");
|
|
4
|
-
const dan = new Literal("dan", "Dan");
|
|
5
|
-
const store = new Literal("store", "store");
|
|
6
|
-
const bank = new Literal("bank", "bank");
|
|
7
|
-
|
|
8
|
-
const big = new Literal("big", "big");
|
|
9
|
-
const small = new Literal("small", "small");
|
|
10
|
-
|
|
11
|
-
const space = new Literal("space", " ");
|
|
12
|
-
|
|
13
|
-
const wentTo = new Literal("went-to", "went to");
|
|
14
|
-
const visited = new Literal("visited", "visited");
|
|
15
|
-
|
|
16
|
-
const a = new Literal("a", "a");
|
|
17
|
-
const the = new Literal("the", "the");
|
|
18
|
-
|
|
19
|
-
const noun = new Or("noun", [pat, dan]);
|
|
20
|
-
const location = new Or("location", [store, bank]);
|
|
21
|
-
const verb = new Or("verb", [wentTo, visited]);
|
|
22
|
-
const adjective = new Or("adjective", [big, small]);
|
|
23
|
-
const article = new Or("article", [a, the]);
|
|
24
|
-
|
|
25
|
-
const sentence = new And("sentence", [
|
|
26
|
-
noun,
|
|
27
|
-
space,
|
|
28
|
-
verb,
|
|
29
|
-
space,
|
|
30
|
-
article,
|
|
31
|
-
space,
|
|
32
|
-
adjective,
|
|
33
|
-
space,
|
|
34
|
-
location,
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
export default sentence;
|
|
File without changes
|