@witchcraft/expressit 0.1.2 → 0.2.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 +9 -5
- package/dist/Lexer.js +2 -2
- package/dist/Parser.d.ts +14 -29
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +120 -135
- package/dist/ast/builders/array.d.ts +1 -3
- package/dist/ast/builders/array.d.ts.map +1 -1
- package/dist/ast/builders/array.js +3 -5
- package/dist/ast/builders/condition.d.ts +5 -11
- package/dist/ast/builders/condition.d.ts.map +1 -1
- package/dist/ast/builders/condition.js +2 -3
- package/dist/ast/builders/delim.d.ts +1 -1
- package/dist/ast/builders/error.d.ts +3 -4
- package/dist/ast/builders/error.d.ts.map +1 -1
- package/dist/ast/builders/error.js +6 -2
- package/dist/ast/builders/expression.d.ts +3 -7
- package/dist/ast/builders/expression.d.ts.map +1 -1
- package/dist/ast/builders/expression.js +3 -5
- package/dist/ast/builders/group.d.ts +3 -8
- package/dist/ast/builders/group.d.ts.map +1 -1
- package/dist/ast/builders/group.js +3 -3
- package/dist/ast/builders/pos.d.ts +1 -2
- package/dist/ast/builders/pos.d.ts.map +1 -1
- package/dist/ast/builders/token.d.ts +3 -5
- package/dist/ast/builders/token.d.ts.map +1 -1
- package/dist/ast/builders/token.js +3 -4
- package/dist/ast/builders/type.d.ts +1 -1
- package/dist/ast/builders/variable.d.ts +3 -5
- package/dist/ast/builders/variable.d.ts.map +1 -1
- package/dist/ast/builders/variable.js +2 -3
- package/dist/ast/createArrayNode.d.ts +3 -0
- package/dist/ast/createArrayNode.d.ts.map +1 -0
- package/dist/ast/createArrayNode.js +12 -0
- package/dist/ast/createConditionNode.d.ts +11 -0
- package/dist/ast/createConditionNode.d.ts.map +1 -0
- package/dist/ast/createConditionNode.js +18 -0
- package/dist/ast/createExpressionNode.d.ts +3 -0
- package/dist/ast/createExpressionNode.d.ts.map +1 -0
- package/dist/ast/createExpressionNode.js +14 -0
- package/dist/ast/createGroupNode.d.ts +5 -0
- package/dist/ast/createGroupNode.d.ts.map +1 -0
- package/dist/ast/createGroupNode.js +14 -0
- package/dist/ast/createNormalizedCondition.d.ts +3 -0
- package/dist/ast/createNormalizedCondition.d.ts.map +1 -0
- package/dist/ast/createNormalizedCondition.js +10 -0
- package/dist/ast/createNormalizedExpression.d.ts +3 -0
- package/dist/ast/createNormalizedExpression.d.ts.map +1 -0
- package/dist/ast/createNormalizedExpression.js +10 -0
- package/dist/ast/createToken.d.ts +6 -0
- package/dist/ast/createToken.d.ts.map +1 -0
- package/dist/ast/createToken.js +15 -0
- package/dist/ast/createVariableNode.d.ts +3 -0
- package/dist/ast/createVariableNode.d.ts.map +1 -0
- package/dist/ast/createVariableNode.js +12 -0
- package/dist/ast/error.d.ts +3 -0
- package/dist/ast/error.d.ts.map +1 -0
- package/dist/ast/error.js +9 -0
- package/dist/ast/handlers.d.ts +5 -12
- package/dist/ast/handlers.d.ts.map +1 -1
- package/dist/ast/handlers.js +21 -29
- package/dist/ast/index.d.ts +9 -1
- package/dist/ast/index.d.ts.map +1 -1
- package/dist/ast/index.js +18 -2
- package/dist/defaults/defaultConditionNormalizer.d.ts +3 -0
- package/dist/defaults/defaultConditionNormalizer.d.ts.map +1 -0
- package/dist/defaults/defaultKeyParser.d.ts +3 -0
- package/dist/defaults/defaultKeyParser.d.ts.map +1 -0
- package/dist/defaults/defaultPrefixApplier.d.ts +3 -0
- package/dist/defaults/defaultPrefixApplier.d.ts.map +1 -0
- package/dist/defaults/defaultValueComparer.d.ts +3 -0
- package/dist/defaults/defaultValueComparer.d.ts.map +1 -0
- package/dist/{helpers/general → defaults}/index.d.ts +0 -2
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/{helpers/general → defaults}/index.js +0 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/{helpers/errors.d.ts → internal/ExpressitError.d.ts} +3 -2
- package/dist/internal/ExpressitError.d.ts.map +1 -0
- package/dist/{helpers/errors.js → internal/ExpressitError.js} +2 -2
- package/dist/internal/applyBoolean.d.ts.map +1 -0
- package/dist/{helpers/general → internal}/applyPrefix.d.ts +1 -1
- package/dist/internal/applyPrefix.d.ts.map +1 -0
- package/dist/{helpers/parser → internal}/checkParserOpts.d.ts +2 -1
- package/dist/internal/checkParserOpts.d.ts.map +1 -0
- package/dist/{helpers/parser → internal}/checkParserOpts.js +14 -14
- package/dist/internal/escapeVariableOrPrefix.d.ts +2 -0
- package/dist/internal/escapeVariableOrPrefix.d.ts.map +1 -0
- package/dist/internal/escapeVariableOrPrefix.js +38 -0
- package/dist/internal/extractPosition.d.ts +5 -0
- package/dist/internal/extractPosition.d.ts.map +1 -0
- package/dist/internal/getUnclosedRightParenCount.d.ts +4 -0
- package/dist/internal/getUnclosedRightParenCount.d.ts.map +1 -0
- package/dist/{helpers/parser → internal}/getUnclosedRightParenCount.js +1 -1
- package/dist/{helpers/parser → internal}/parseParserOptions.d.ts +1 -1
- package/dist/internal/parseParserOptions.d.ts.map +1 -0
- package/dist/{helpers/parser → internal}/parseParserOptions.js +4 -4
- package/dist/internal/unescape.d.ts.map +1 -0
- package/dist/package.json.js +7 -7
- package/dist/types/ast.d.ts +195 -6
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/ast.js +2 -0
- package/dist/types/autocomplete.d.ts +5 -6
- package/dist/types/autocomplete.d.ts.map +1 -1
- package/dist/types/parser.d.ts +17 -22
- package/dist/types/parser.d.ts.map +1 -1
- package/dist/utils/extractTokens.d.ts +2 -4
- package/dist/utils/extractTokens.d.ts.map +1 -1
- package/dist/utils/extractTokens.js +14 -18
- package/dist/utils/generateParentsMap.d.ts +10 -0
- package/dist/utils/generateParentsMap.d.ts.map +1 -0
- package/dist/utils/generateParentsMap.js +73 -0
- package/dist/utils/getCursorInfo.d.ts +1 -1
- package/dist/utils/getCursorInfo.d.ts.map +1 -1
- package/dist/utils/getCursorInfo.js +3 -5
- package/dist/utils/getOppositeDelimiter.d.ts +2 -1
- package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
- package/dist/utils/getOppositeDelimiter.js +6 -5
- package/dist/utils/getParent.d.ts +5 -0
- package/dist/utils/getParent.d.ts.map +1 -0
- package/dist/utils/getParent.js +6 -0
- package/dist/utils/getSurroundingErrors.d.ts +3 -4
- package/dist/utils/getSurroundingErrors.d.ts.map +1 -1
- package/dist/utils/getSurroundingErrors.js +3 -3
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -0
- package/dist/utils/isNode.d.ts +10 -0
- package/dist/utils/isNode.d.ts.map +1 -0
- package/dist/utils/isNode.js +6 -0
- package/dist/utils/isToken.d.ts +8 -0
- package/dist/utils/isToken.d.ts.map +1 -0
- package/dist/utils/isToken.js +6 -0
- package/dist/utils/prettyAst.d.ts +1 -2
- package/dist/utils/prettyAst.d.ts.map +1 -1
- package/dist/utils/prettyAst.js +19 -26
- package/package.json +7 -7
- package/src/Lexer.ts +2 -2
- package/src/Parser.ts +158 -165
- package/src/ast/builders/array.ts +4 -9
- package/src/ast/builders/condition.ts +10 -15
- package/src/ast/builders/delim.ts +1 -1
- package/src/ast/builders/error.ts +10 -6
- package/src/ast/builders/expression.ts +17 -23
- package/src/ast/builders/group.ts +7 -11
- package/src/ast/builders/pos.ts +2 -3
- package/src/ast/builders/token.ts +6 -7
- package/src/ast/builders/type.ts +1 -1
- package/src/ast/builders/variable.ts +6 -8
- package/src/ast/createArrayNode.ts +17 -0
- package/src/ast/createConditionNode.ts +58 -0
- package/src/ast/createExpressionNode.ts +21 -0
- package/src/ast/createGroupNode.ts +46 -0
- package/src/ast/createNormalizedCondition.ts +12 -0
- package/src/ast/createNormalizedExpression.ts +9 -0
- package/src/ast/createToken.ts +26 -0
- package/src/ast/createVariableNode.ts +18 -0
- package/src/ast/error.ts +9 -0
- package/src/ast/handlers.ts +26 -37
- package/src/ast/index.ts +9 -1
- package/src/{helpers/general → defaults}/defaultConditionNormalizer.ts +1 -1
- package/src/{helpers/general → defaults}/defaultKeyParser.ts +1 -1
- package/src/{helpers/general → defaults}/defaultPrefixApplier.ts +1 -1
- package/src/{helpers/general → defaults}/defaultValueComparer.ts +1 -1
- package/src/{helpers/general → defaults}/index.ts +0 -2
- package/src/index.ts +2 -1
- package/src/{helpers/errors.ts → internal/ExpressitError.ts} +2 -2
- package/src/{helpers/general → internal}/applyPrefix.ts +1 -1
- package/src/{helpers/parser → internal}/checkParserOpts.ts +16 -15
- package/src/internal/escapeVariableOrPrefix.ts +36 -0
- package/src/{helpers/parser → internal}/extractPosition.ts +2 -2
- package/src/{helpers/parser → internal}/getUnclosedRightParenCount.ts +1 -2
- package/src/{helpers/parser → internal}/parseParserOptions.ts +5 -5
- package/src/types/ast.ts +292 -7
- package/src/types/autocomplete.ts +5 -7
- package/src/types/parser.ts +17 -22
- package/src/utils/extractTokens.ts +16 -20
- package/src/utils/generateParentsMap.ts +60 -0
- package/src/utils/getCursorInfo.ts +4 -6
- package/src/utils/getOppositeDelimiter.ts +11 -10
- package/src/utils/getParent.ts +16 -0
- package/src/utils/getSurroundingErrors.ts +10 -9
- package/src/utils/index.ts +4 -0
- package/src/utils/isNode.ts +12 -0
- package/src/utils/isToken.ts +10 -0
- package/src/utils/prettyAst.ts +20 -17
- package/dist/ast/classes/ArrayNode.d.ts +0 -18
- package/dist/ast/classes/ArrayNode.d.ts.map +0 -1
- package/dist/ast/classes/ArrayNode.js +0 -55
- package/dist/ast/classes/Condition.d.ts +0 -13
- package/dist/ast/classes/Condition.d.ts.map +0 -1
- package/dist/ast/classes/Condition.js +0 -21
- package/dist/ast/classes/ConditionNode.d.ts +0 -73
- package/dist/ast/classes/ConditionNode.d.ts.map +0 -1
- package/dist/ast/classes/ConditionNode.js +0 -101
- package/dist/ast/classes/ErrorToken.d.ts +0 -27
- package/dist/ast/classes/ErrorToken.d.ts.map +0 -1
- package/dist/ast/classes/ErrorToken.js +0 -47
- package/dist/ast/classes/Expression.d.ts +0 -13
- package/dist/ast/classes/Expression.d.ts.map +0 -1
- package/dist/ast/classes/Expression.js +0 -19
- package/dist/ast/classes/ExpressionNode.d.ts +0 -21
- package/dist/ast/classes/ExpressionNode.d.ts.map +0 -1
- package/dist/ast/classes/ExpressionNode.js +0 -57
- package/dist/ast/classes/GroupNode.d.ts +0 -64
- package/dist/ast/classes/GroupNode.d.ts.map +0 -1
- package/dist/ast/classes/GroupNode.js +0 -69
- package/dist/ast/classes/Node.d.ts +0 -22
- package/dist/ast/classes/Node.d.ts.map +0 -1
- package/dist/ast/classes/Node.js +0 -28
- package/dist/ast/classes/Token.d.ts +0 -27
- package/dist/ast/classes/Token.d.ts.map +0 -1
- package/dist/ast/classes/Token.js +0 -28
- package/dist/ast/classes/ValidToken.d.ts +0 -26
- package/dist/ast/classes/ValidToken.d.ts.map +0 -1
- package/dist/ast/classes/ValidToken.js +0 -49
- package/dist/ast/classes/VariableNode.d.ts +0 -33
- package/dist/ast/classes/VariableNode.d.ts.map +0 -1
- package/dist/ast/classes/VariableNode.js +0 -58
- package/dist/ast/classes/index.d.ts +0 -12
- package/dist/ast/classes/index.d.ts.map +0 -1
- package/dist/ast/classes/index.js +0 -24
- package/dist/helpers/errors.d.ts.map +0 -1
- package/dist/helpers/general/applyBoolean.d.ts.map +0 -1
- package/dist/helpers/general/applyPrefix.d.ts.map +0 -1
- package/dist/helpers/general/defaultConditionNormalizer.d.ts +0 -3
- package/dist/helpers/general/defaultConditionNormalizer.d.ts.map +0 -1
- package/dist/helpers/general/defaultKeyParser.d.ts +0 -3
- package/dist/helpers/general/defaultKeyParser.d.ts.map +0 -1
- package/dist/helpers/general/defaultPrefixApplier.d.ts +0 -3
- package/dist/helpers/general/defaultPrefixApplier.d.ts.map +0 -1
- package/dist/helpers/general/defaultValueComparer.d.ts +0 -3
- package/dist/helpers/general/defaultValueComparer.d.ts.map +0 -1
- package/dist/helpers/general/index.d.ts.map +0 -1
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/index.js +0 -8
- package/dist/helpers/parser/assignParents.d.ts +0 -4
- package/dist/helpers/parser/assignParents.d.ts.map +0 -1
- package/dist/helpers/parser/assignParents.js +0 -71
- package/dist/helpers/parser/checkParserOpts.d.ts.map +0 -1
- package/dist/helpers/parser/extractPosition.d.ts +0 -5
- package/dist/helpers/parser/extractPosition.d.ts.map +0 -1
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts +0 -4
- package/dist/helpers/parser/getUnclosedRightParenCount.d.ts.map +0 -1
- package/dist/helpers/parser/index.d.ts +0 -9
- package/dist/helpers/parser/index.d.ts.map +0 -1
- package/dist/helpers/parser/index.js +0 -18
- package/dist/helpers/parser/parseParserOptions.d.ts.map +0 -1
- package/dist/helpers/parser/seal.d.ts +0 -8
- package/dist/helpers/parser/seal.d.ts.map +0 -1
- package/dist/helpers/parser/seal.js +0 -10
- package/dist/helpers/parser/setParent.d.ts +0 -6
- package/dist/helpers/parser/setParent.d.ts.map +0 -1
- package/dist/helpers/parser/setParent.js +0 -4
- package/dist/helpers/parser/unescape.d.ts.map +0 -1
- package/src/ast/classes/ArrayNode.ts +0 -46
- package/src/ast/classes/Condition.ts +0 -22
- package/src/ast/classes/ConditionNode.ts +0 -141
- package/src/ast/classes/ErrorToken.ts +0 -49
- package/src/ast/classes/Expression.ts +0 -26
- package/src/ast/classes/ExpressionNode.ts +0 -62
- package/src/ast/classes/GroupNode.ts +0 -127
- package/src/ast/classes/Node.ts +0 -47
- package/src/ast/classes/Token.ts +0 -59
- package/src/ast/classes/ValidToken.ts +0 -56
- package/src/ast/classes/VariableNode.ts +0 -67
- package/src/ast/classes/index.ts +0 -13
- package/src/helpers/index.ts +0 -6
- package/src/helpers/parser/assignParents.ts +0 -51
- package/src/helpers/parser/index.ts +0 -10
- package/src/helpers/parser/seal.ts +0 -14
- package/src/helpers/parser/setParent.ts +0 -5
- /package/dist/{helpers/general → defaults}/defaultConditionNormalizer.js +0 -0
- /package/dist/{helpers/general → defaults}/defaultKeyParser.js +0 -0
- /package/dist/{helpers/general → defaults}/defaultPrefixApplier.js +0 -0
- /package/dist/{helpers/general → defaults}/defaultValueComparer.js +0 -0
- /package/dist/{helpers/general → internal}/applyBoolean.d.ts +0 -0
- /package/dist/{helpers/general → internal}/applyBoolean.js +0 -0
- /package/dist/{helpers/general → internal}/applyPrefix.js +0 -0
- /package/dist/{helpers/parser → internal}/extractPosition.js +0 -0
- /package/dist/{helpers/parser → internal}/unescape.d.ts +0 -0
- /package/dist/{helpers/parser → internal}/unescape.js +0 -0
- /package/src/{helpers/general → internal}/applyBoolean.ts +0 -0
- /package/src/{helpers/parser → internal}/unescape.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/helpers/errors.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGhE,qBAAa,yBAAyB,CAAC,CAAC,SAAS,WAAW,CAAE,SAAQ,KAAK;IAC1E,OAAO,EAAE,MAAM,CAAU;IAEzB,IAAI,EAAE,MAAM,CAAa;IAEzB,IAAI,EAAE,CAAC,CAAA;IAEP,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAA;gBAEN,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM;CAYzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyBoolean.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/applyBoolean.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAO/E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyPrefix.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/applyPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,gBAAgB;AAChB,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,MAAM,CAGzG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConditionNormalizer.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/defaultConditionNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAc,MAAM,uBAAuB,CAAA;AAG5E,eAAO,MAAM,0BAA0B,EAAE,mBAKxC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultKeyParser.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/defaultKeyParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGtD,eAAO,MAAM,gBAAgB,EAAE,SAI7B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultPrefixApplier.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/defaultPrefixApplier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,eAAO,MAAM,oBAAoB,EAAE,aAGlC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaultValueComparer.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/defaultValueComparer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,eAAO,MAAM,oBAAoB,EAAE,aAGlC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/general/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAI3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/helpers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assignParents.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/assignParents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE/C,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAyC9C"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ArrayNode } from "../../ast/classes/ArrayNode.js";
|
|
2
|
-
import { ConditionNode } from "../../ast/classes/ConditionNode.js";
|
|
3
|
-
import { ExpressionNode } from "../../ast/classes/ExpressionNode.js";
|
|
4
|
-
import { GroupNode } from "../../ast/classes/GroupNode.js";
|
|
5
|
-
import { Node } from "../../ast/classes/Node.js";
|
|
6
|
-
import { VariableNode } from "../../ast/classes/VariableNode.js";
|
|
7
|
-
function assignParents(ast) {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
-
if (ast instanceof VariableNode) {
|
|
10
|
-
if (ast.prefix)
|
|
11
|
-
ast.prefix.parent = ast;
|
|
12
|
-
if ((_a = ast.quote) == null ? void 0 : _a.left)
|
|
13
|
-
ast.quote.left.parent = ast;
|
|
14
|
-
if ((_b = ast.quote) == null ? void 0 : _b.right)
|
|
15
|
-
ast.quote.right.parent = ast;
|
|
16
|
-
if ((_c = ast.quote) == null ? void 0 : _c.flags)
|
|
17
|
-
ast.quote.flags.parent = ast;
|
|
18
|
-
ast.value.parent = ast;
|
|
19
|
-
} else if (ast instanceof ConditionNode) {
|
|
20
|
-
if (ast.operator)
|
|
21
|
-
ast.operator.parent = ast;
|
|
22
|
-
if (ast.property) {
|
|
23
|
-
ast.property.parent = ast;
|
|
24
|
-
if (ast.property instanceof Node)
|
|
25
|
-
assignParents(ast.property);
|
|
26
|
-
}
|
|
27
|
-
if (ast.propertyOperator)
|
|
28
|
-
ast.propertyOperator.parent = ast;
|
|
29
|
-
if ((_d = ast.sep) == null ? void 0 : _d.left)
|
|
30
|
-
ast.sep.left.parent = ast;
|
|
31
|
-
if ((_e = ast.sep) == null ? void 0 : _e.right)
|
|
32
|
-
ast.sep.right.parent = ast;
|
|
33
|
-
ast.value.parent = ast;
|
|
34
|
-
if (ast.value instanceof Node)
|
|
35
|
-
assignParents(ast.value);
|
|
36
|
-
} else if (ast instanceof ExpressionNode) {
|
|
37
|
-
if (ast.operator)
|
|
38
|
-
ast.operator.parent = ast;
|
|
39
|
-
ast.right.parent = ast;
|
|
40
|
-
if (ast.right instanceof Node)
|
|
41
|
-
assignParents(ast.right);
|
|
42
|
-
ast.left.parent = ast;
|
|
43
|
-
if (ast.left instanceof Node)
|
|
44
|
-
assignParents(ast.left);
|
|
45
|
-
} else if (ast instanceof GroupNode) {
|
|
46
|
-
if (ast.prefix) {
|
|
47
|
-
ast.prefix.parent = ast;
|
|
48
|
-
if (ast.prefix instanceof Node)
|
|
49
|
-
assignParents(ast.prefix);
|
|
50
|
-
}
|
|
51
|
-
if ((_f = ast.paren) == null ? void 0 : _f.left)
|
|
52
|
-
ast.paren.left.parent = ast;
|
|
53
|
-
if ((_g = ast.paren) == null ? void 0 : _g.right)
|
|
54
|
-
ast.paren.right.parent = ast;
|
|
55
|
-
ast.expression.parent = ast;
|
|
56
|
-
if (ast.expression instanceof Node)
|
|
57
|
-
assignParents(ast.expression);
|
|
58
|
-
} else if (ast instanceof ArrayNode) {
|
|
59
|
-
if (ast.bracket.left)
|
|
60
|
-
ast.bracket.left.parent = ast;
|
|
61
|
-
if (ast.bracket.right)
|
|
62
|
-
ast.bracket.right.parent = ast;
|
|
63
|
-
for (const val of ast.values) {
|
|
64
|
-
val.parent = ast;
|
|
65
|
-
assignParents(val);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
assignParents
|
|
71
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkParserOpts.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/checkParserOpts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,uBAAuB,CAAA;AAM7E,wBAAgB,eAAe,CAAC,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,eAAe,GAAE,OAAe,EAAE,eAAe,GAAE,OAAe,GAAG,IAAI,CAoIlJ"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Token } from "../../Lexer.js";
|
|
2
|
-
import type { Position } from "../../types/ast.js";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export declare function extractPosition(pos: Pick<Token, "startOffset" | "endOffset">, shift: number): Position;
|
|
5
|
-
//# sourceMappingURL=extractPosition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractPosition.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/extractPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAGlD,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAKtG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUnclosedRightParenCount.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/getUnclosedRightParenCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAM,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG/C,gBAAgB;AAGhB,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAelE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { assignParents } from "./assignParents.js";
|
|
2
|
-
export { checkParserOpts } from "./checkParserOpts.js";
|
|
3
|
-
export { extractPosition } from "./extractPosition.js";
|
|
4
|
-
export { getUnclosedRightParenCount } from "./getUnclosedRightParenCount.js";
|
|
5
|
-
export { parseParserOptions } from "./parseParserOptions.js";
|
|
6
|
-
export { seal } from "./seal.js";
|
|
7
|
-
export { setParent } from "./setParent.js";
|
|
8
|
-
export { unescape } from "./unescape.js";
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { assignParents } from "./assignParents.js";
|
|
2
|
-
import { checkParserOpts } from "./checkParserOpts.js";
|
|
3
|
-
import { extractPosition } from "./extractPosition.js";
|
|
4
|
-
import { getUnclosedRightParenCount } from "./getUnclosedRightParenCount.js";
|
|
5
|
-
import { parseParserOptions } from "./parseParserOptions.js";
|
|
6
|
-
import { seal } from "./seal.js";
|
|
7
|
-
import { setParent } from "./setParent.js";
|
|
8
|
-
import { unescape } from "./unescape.js";
|
|
9
|
-
export {
|
|
10
|
-
assignParents,
|
|
11
|
-
checkParserOpts,
|
|
12
|
-
extractPosition,
|
|
13
|
-
getUnclosedRightParenCount,
|
|
14
|
-
parseParserOptions,
|
|
15
|
-
seal,
|
|
16
|
-
setParent,
|
|
17
|
-
unescape
|
|
18
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseParserOptions.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/parseParserOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAM7E,gBAAgB;AAChB,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,EACnD,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,iBAAiB,CAAC,CAAC,CAAC,CA4CtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/seal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,KAAK,GAAG,QAAQ,GAAG,IAAI,CAGhD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setParent.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/setParent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,OAAO,MAAyC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unescape.d.ts","sourceRoot":"","sources":["../../../src/helpers/parser/unescape.ts"],"names":[],"mappings":"AAAA,gBAAgB;AAChB,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE5C"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { ConditionNode } from "./ConditionNode.js"
|
|
2
|
-
import { Node } from "./Node.js"
|
|
3
|
-
import { ValidToken } from "./ValidToken.js"
|
|
4
|
-
import type { VariableNode } from "./VariableNode.js"
|
|
5
|
-
|
|
6
|
-
import { AST_TYPE, type NodeDelimiters, type TOKEN_TYPE } from "../../types/ast.js"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export class ArrayNode<
|
|
10
|
-
TValid extends boolean = boolean,
|
|
11
|
-
> extends Node<AST_TYPE.ARRAY> {
|
|
12
|
-
readonly values: VariableNode[]
|
|
13
|
-
|
|
14
|
-
readonly bracket: NodeDelimiters<TOKEN_TYPE.BRACKETL, TOKEN_TYPE.BRACKETR>
|
|
15
|
-
|
|
16
|
-
#parent: any
|
|
17
|
-
|
|
18
|
-
#setParent: boolean = false
|
|
19
|
-
|
|
20
|
-
get parent(): ConditionNode | undefined {
|
|
21
|
-
return this.#parent
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
set parent(value: ConditionNode | undefined) {
|
|
25
|
-
if (this.#setParent) { throw new Error("parent property is readonly") }
|
|
26
|
-
this.#parent = value
|
|
27
|
-
this.#setParent = true
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
constructor({ values, bracket, start, end }: {
|
|
31
|
-
values: ArrayNode<TValid>["values"]
|
|
32
|
-
bracket: ArrayNode<TValid>["bracket"]
|
|
33
|
-
start: number
|
|
34
|
-
end: number
|
|
35
|
-
}) {
|
|
36
|
-
super(AST_TYPE.ARRAY, start, end)
|
|
37
|
-
this.values = values
|
|
38
|
-
this.bracket = bracket
|
|
39
|
-
// @ts-expect-error ignore readonly
|
|
40
|
-
this.valid = (
|
|
41
|
-
this.values.every(val => val.valid) &&
|
|
42
|
-
this.bracket.left instanceof ValidToken &&
|
|
43
|
-
this.bracket.right instanceof ValidToken
|
|
44
|
-
) as TValid
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export class Condition<TOp extends string = string, TValue = any> {
|
|
2
|
-
readonly value: TValue
|
|
3
|
-
|
|
4
|
-
readonly operator?: TOp
|
|
5
|
-
|
|
6
|
-
readonly property: string[]
|
|
7
|
-
|
|
8
|
-
readonly negate: boolean
|
|
9
|
-
|
|
10
|
-
constructor({ property, operator, value, negate }: {
|
|
11
|
-
property: Condition<TOp, TValue>["property"]
|
|
12
|
-
operator: Condition<TOp, TValue>["operator"]
|
|
13
|
-
value: Condition<TOp, TValue>["value"]
|
|
14
|
-
negate: Condition<TOp, TValue>["negate"]
|
|
15
|
-
}) {
|
|
16
|
-
this.value = value
|
|
17
|
-
this.operator = operator
|
|
18
|
-
this.property = property
|
|
19
|
-
this.negate = negate
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import type { ArrayNode } from "./ArrayNode.js"
|
|
2
|
-
import type { ErrorToken } from "./ErrorToken.js"
|
|
3
|
-
import type { ExpressionNode } from "./ExpressionNode.js"
|
|
4
|
-
import type { GroupNode } from "./GroupNode.js"
|
|
5
|
-
import { Node } from "./Node.js"
|
|
6
|
-
import { ValidToken } from "./ValidToken.js"
|
|
7
|
-
import { VariableNode } from "./VariableNode.js"
|
|
8
|
-
|
|
9
|
-
import { type AnyToken, AST_TYPE, type TOKEN_TYPE } from "../../types/ast.js"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A condition is composed of a `variable`, @see Variable , and, if it's negated, a "not" `operator` token, @see ValidToken .
|
|
14
|
-
*
|
|
15
|
-
* The `value` property refers to the boolean value of the condition (not to the string value of the variable). See the `operator` property.
|
|
16
|
-
*/
|
|
17
|
-
export class ConditionNode<
|
|
18
|
-
TValid extends boolean = boolean,
|
|
19
|
-
TOperator extends
|
|
20
|
-
ValidToken<TOKEN_TYPE.NOT> | undefined =
|
|
21
|
-
ValidToken<TOKEN_TYPE.NOT> | undefined,
|
|
22
|
-
> extends Node<AST_TYPE.CONDITION> {
|
|
23
|
-
/**
|
|
24
|
-
* Contains a value node which could be a variable, an array node (if enabled), or a group.
|
|
25
|
-
*
|
|
26
|
-
* Might be an error in cases like:
|
|
27
|
-
* - just passing a negation operator
|
|
28
|
-
* - if condition property operators are used and you have an input like just `[SEP]`, `op[SEP]`, `prop[SEP]op[SEP]`, `[CUSTOM OP]`, or `prop[CUSTOM OP]` where the variable is missing.
|
|
29
|
-
*/
|
|
30
|
-
readonly value:
|
|
31
|
-
| VariableNode<TValid>
|
|
32
|
-
| ArrayNode<TValid>
|
|
33
|
-
| GroupNode<TValid>
|
|
34
|
-
| (TValid extends false ? ErrorToken<TOKEN_TYPE.VALUE> : never)
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* If the condition was negated, contains the "not" token, @see ValidToken , the condition was negated with.
|
|
38
|
-
*/
|
|
39
|
-
readonly operator?: ValidToken<TOKEN_TYPE.NOT>
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* If condition property operators are used, this will contain the property (as a variable), or an error token if it was missing (but some separator or operator was passed).
|
|
43
|
-
*
|
|
44
|
-
* While the property is a variable and can be a quoted variable, it cannot be a prefixed variable string.
|
|
45
|
-
*
|
|
46
|
-
* See the corresponding @see ParserOptions for more details.
|
|
47
|
-
*/
|
|
48
|
-
readonly property?: VariableNode | (TValid extends false ? ErrorToken<TOKEN_TYPE.VALUE> : never)
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* If condition property operators are used, this will contain the operator.
|
|
52
|
-
*
|
|
53
|
-
* If a "short" form was used, this will contain an `OP_CUSTOM` type token, and the condition's `sep` will always be undefined.
|
|
54
|
-
*
|
|
55
|
-
* If a "long/expanded" form was used, this will contain a `VALUE` type token, and at least one of condition's `sep` tokens will be defined.
|
|
56
|
-
*
|
|
57
|
-
* See the corresponding @see ParserOptions for more details.
|
|
58
|
-
*/
|
|
59
|
-
readonly propertyOperator?: AnyToken<TOKEN_TYPE.OP_CUSTOM | TOKEN_TYPE.VALUE>
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* If "long/expanded" form condition property operators are used, this will contain the separators, otherwise it is undefined.
|
|
63
|
-
*
|
|
64
|
-
* If it's defined, either both side will be valid tokens, or only the left, while the right might be undefined or an error token.
|
|
65
|
-
*
|
|
66
|
-
* This is because given a string like `[SEP]val` which would produce an error like `[MISSING PROPERTY ERROR][SEP]var`, the separator is always interpreted as being the left one. And even if we have a situation like `op[SEP]var`, it is always interpreted by the parser as `prop[SEP]var`.
|
|
67
|
-
*
|
|
68
|
-
* Why might the right be undefined instead of an error token? This is because we don't need a separator between the operator and a group, `prop[SEP]op(group)`, but we do between a variable in cases like `prop[SEP]op"var"` which would produce an error token on the right side (we could parse this but it just looks inconsistent).
|
|
69
|
-
*
|
|
70
|
-
* See the corresponding @see ParserOptions for more details.
|
|
71
|
-
*/
|
|
72
|
-
readonly sep?: {
|
|
73
|
-
left?: AnyToken<TOKEN_TYPE.OP_EXPANDED_SEP>
|
|
74
|
-
right?: AnyToken<TOKEN_TYPE.OP_EXPANDED_SEP>
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#parent: any
|
|
78
|
-
|
|
79
|
-
#setParent: boolean = false
|
|
80
|
-
|
|
81
|
-
get parent(): GroupNode |
|
|
82
|
-
ExpressionNode |
|
|
83
|
-
undefined {
|
|
84
|
-
return this.#parent
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
set parent(value: GroupNode |
|
|
88
|
-
ExpressionNode |
|
|
89
|
-
undefined,
|
|
90
|
-
) {
|
|
91
|
-
if (this.#setParent) {throw new Error("parent property is readonly")}
|
|
92
|
-
this.#parent = value
|
|
93
|
-
this.#setParent = true
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
constructor({ property, propertyOperator, sep, value, start, end, operator }: {
|
|
97
|
-
operator?: TOperator
|
|
98
|
-
property?: ConditionNode<TValid>["property"]
|
|
99
|
-
propertyOperator?: ConditionNode<TValid>["propertyOperator"]
|
|
100
|
-
sep?: ConditionNode<TValid>["sep"]
|
|
101
|
-
value: ConditionNode<TValid>["value"]
|
|
102
|
-
start: number
|
|
103
|
-
end: number
|
|
104
|
-
}) {
|
|
105
|
-
super(AST_TYPE.CONDITION, start, end)
|
|
106
|
-
this.value = value
|
|
107
|
-
this.operator = operator
|
|
108
|
-
this.property = property
|
|
109
|
-
this.propertyOperator = propertyOperator
|
|
110
|
-
this.sep = sep
|
|
111
|
-
this.operator = operator
|
|
112
|
-
// @ts-expect-error ignore readonly
|
|
113
|
-
this.valid = ((
|
|
114
|
-
this.operator === undefined ||
|
|
115
|
-
this.operator instanceof ValidToken
|
|
116
|
-
) &&
|
|
117
|
-
this.value instanceof Node &&
|
|
118
|
-
this.value.valid
|
|
119
|
-
) && (
|
|
120
|
-
(
|
|
121
|
-
this.property === undefined &&
|
|
122
|
-
this.propertyOperator === undefined &&
|
|
123
|
-
this.sep === undefined
|
|
124
|
-
) || (
|
|
125
|
-
this.property instanceof VariableNode &&
|
|
126
|
-
(
|
|
127
|
-
this.propertyOperator instanceof ValidToken ||
|
|
128
|
-
(
|
|
129
|
-
this.sep?.left instanceof ValidToken &&
|
|
130
|
-
(
|
|
131
|
-
this.sep.right === undefined ||
|
|
132
|
-
this.sep?.right instanceof ValidToken
|
|
133
|
-
)
|
|
134
|
-
)
|
|
135
|
-
)
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
) as TValid
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ConditionNode } from "./ConditionNode.js"
|
|
2
|
-
import type { ExpressionNode } from "./ExpressionNode.js"
|
|
3
|
-
import type { GroupNode } from "./GroupNode.js"
|
|
4
|
-
import { Token } from "./Token.js"
|
|
5
|
-
import type { VariableNode } from "./VariableNode.js"
|
|
6
|
-
|
|
7
|
-
import type { TOKEN_TYPE } from "../../types/ast.js"
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The class for invalid recovery tokens.
|
|
11
|
-
*
|
|
12
|
-
* Unlike valid tokens, error tokens:
|
|
13
|
-
*
|
|
14
|
-
* - Have no value.
|
|
15
|
-
* - Contain an extra property, `expected` with an array of tokens *that would have fixed the issue* (NOT every possible token that could be there).
|
|
16
|
-
* - The start end positions will always be equal. An invalid token has no length.
|
|
17
|
-
*/
|
|
18
|
-
export class ErrorToken<
|
|
19
|
-
TExpected extends TOKEN_TYPE = TOKEN_TYPE,
|
|
20
|
-
> extends Token<false, never, never, TExpected[]> {
|
|
21
|
-
readonly expected: TExpected[]
|
|
22
|
-
|
|
23
|
-
#parent: any
|
|
24
|
-
|
|
25
|
-
get parent(): VariableNode |
|
|
26
|
-
GroupNode |
|
|
27
|
-
ExpressionNode |
|
|
28
|
-
ConditionNode {
|
|
29
|
-
return this.#parent
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
set parent(value: VariableNode |
|
|
33
|
-
GroupNode |
|
|
34
|
-
ExpressionNode |
|
|
35
|
-
ConditionNode,
|
|
36
|
-
) {
|
|
37
|
-
if (this.#parent) {throw new Error("parent property is readonly")}
|
|
38
|
-
this.#parent = value
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
constructor({ expected, start, end }: {
|
|
42
|
-
expected: TExpected[]
|
|
43
|
-
start: number
|
|
44
|
-
end: number
|
|
45
|
-
}) {
|
|
46
|
-
super(start, end)
|
|
47
|
-
this.expected = expected
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Condition } from "./Condition.js"
|
|
2
|
-
|
|
3
|
-
import type { TokenBooleanTypes } from "../../types/ast.js"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export class Expression<TType extends string = string, TValue = any> {
|
|
7
|
-
readonly left:
|
|
8
|
-
| Expression<TType, TValue>
|
|
9
|
-
| Condition<TType, TValue>
|
|
10
|
-
|
|
11
|
-
readonly right:
|
|
12
|
-
| Expression<TType, TValue>
|
|
13
|
-
| Condition<TType, TValue>
|
|
14
|
-
|
|
15
|
-
readonly operator: TokenBooleanTypes
|
|
16
|
-
|
|
17
|
-
constructor({ operator, left, right }: {
|
|
18
|
-
operator: Expression<TType, TValue>["operator"]
|
|
19
|
-
right: Expression<TType, TValue>["right"]
|
|
20
|
-
left: Expression<TType, TValue>["left"]
|
|
21
|
-
}) {
|
|
22
|
-
this.operator = operator
|
|
23
|
-
this.right = right
|
|
24
|
-
this.left = left
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { ConditionNode } from "./ConditionNode.js"
|
|
2
|
-
import type { ErrorToken } from "./ErrorToken.js"
|
|
3
|
-
import type { GroupNode } from "./GroupNode.js"
|
|
4
|
-
import { Node } from "./Node.js"
|
|
5
|
-
import { ValidToken } from "./ValidToken.js"
|
|
6
|
-
|
|
7
|
-
import { type AnyToken, AST_TYPE, type TOKEN_TYPE, type TokenBooleanTypes } from "../../types/ast.js"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export class ExpressionNode<
|
|
11
|
-
TValid extends boolean = boolean,
|
|
12
|
-
>
|
|
13
|
-
extends Node<AST_TYPE.EXPRESSION> {
|
|
14
|
-
readonly operator: AnyToken<TokenBooleanTypes>
|
|
15
|
-
|
|
16
|
-
readonly left:
|
|
17
|
-
| ExpressionNode<TValid>
|
|
18
|
-
| ConditionNode<TValid>
|
|
19
|
-
| GroupNode<TValid>
|
|
20
|
-
| (TValid extends false ? ErrorToken<TOKEN_TYPE.VALUE> : never)
|
|
21
|
-
|
|
22
|
-
readonly right:
|
|
23
|
-
| ExpressionNode<TValid>
|
|
24
|
-
| ConditionNode<TValid>
|
|
25
|
-
| GroupNode<TValid>
|
|
26
|
-
| (TValid extends false ? ErrorToken<TOKEN_TYPE.VALUE> : never)
|
|
27
|
-
|
|
28
|
-
#parent: any
|
|
29
|
-
|
|
30
|
-
#setParent: boolean = false
|
|
31
|
-
|
|
32
|
-
get parent(): GroupNode | undefined {
|
|
33
|
-
return this.#parent
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
set parent(value: GroupNode | undefined) {
|
|
37
|
-
if (this.#setParent) {throw new Error("parent property is readonly")}
|
|
38
|
-
this.#parent = value
|
|
39
|
-
this.#setParent = true
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
constructor({ operator, left, right, start, end }: {
|
|
43
|
-
operator: ExpressionNode<TValid>["operator"]
|
|
44
|
-
right: ExpressionNode<TValid>["right"]
|
|
45
|
-
left: ExpressionNode<TValid>["left"]
|
|
46
|
-
start: number
|
|
47
|
-
end: number
|
|
48
|
-
}) {
|
|
49
|
-
super(AST_TYPE.EXPRESSION, start, end)
|
|
50
|
-
this.operator = operator
|
|
51
|
-
this.right = right
|
|
52
|
-
this.left = left
|
|
53
|
-
// @ts-expect-error ignore readonly
|
|
54
|
-
this.valid = (
|
|
55
|
-
this.operator instanceof ValidToken &&
|
|
56
|
-
this.left instanceof Node &&
|
|
57
|
-
this.left.valid &&
|
|
58
|
-
this.right instanceof Node &&
|
|
59
|
-
this.right.valid
|
|
60
|
-
) as TValid
|
|
61
|
-
}
|
|
62
|
-
}
|