UNPKG

@abaplint/core

Version:
81 lines 3.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Find = void 0; const Expressions = require("../../2_statements/expressions"); const inline_data_1 = require("../expressions/inline_data"); const basic_1 = require("../../types/basic"); const source_1 = require("../expressions/source"); const target_1 = require("../expressions/target"); class Find { runSyntax(node, input) { for (const s of node.findDirectExpressions(Expressions.Source)) { source_1.Source.runSyntax(s, input); } const rfound = node.findExpressionAfterToken("RESULTS"); if (rfound && rfound.get() instanceof Expressions.Target) { const sub = new basic_1.StructureType([ { name: "OFFSET", type: basic_1.IntegerType.get() }, { name: "LENGTH", type: basic_1.IntegerType.get() } ], "SUBMATCH_RESULT", "SUBMATCH_RESULT"); const type = new basic_1.StructureType([ { name: "LINE", type: basic_1.IntegerType.get() }, { name: "OFFSET", type: basic_1.IntegerType.get() }, { name: "LENGTH", type: basic_1.IntegerType.get() }, { name: "SUBMATCHES", type: new basic_1.TableType(sub, { withHeader: false, keyType: basic_1.TableKeyType.default }) }, ], "MATCH_RESULT", "MATCH_RESULT"); if (node.concatTokens().toUpperCase().startsWith("FIND FIRST")) { this.inline(rfound, input, type); } else { this.inline(rfound, input, new basic_1.TableType(type, { withHeader: false, keyType: basic_1.TableKeyType.default }, "MATCH_RESULT_TAB")); } } const ofound = node.findExpressionsAfterToken("OFFSET"); for (const o of ofound) { if (o.get() instanceof Expressions.Target) { this.inline(o, input, basic_1.IntegerType.get()); } } const lfound = node.findExpressionAfterToken("LINE"); if (lfound && lfound.get() instanceof Expressions.Target) { this.inline(lfound, input, basic_1.IntegerType.get()); } const cfound = node.findExpressionAfterToken("COUNT"); if (cfound && cfound.get() instanceof Expressions.Target) { this.inline(cfound, input, basic_1.IntegerType.get()); } const lnfound = node.findExpressionAfterToken("LENGTH"); if (lnfound && lnfound.get() instanceof Expressions.Target) { this.inline(lnfound, input, basic_1.IntegerType.get()); } if (node.findDirectTokenByText("SUBMATCHES")) { for (const t of node.findDirectExpressions(Expressions.Target)) { if (t === rfound || t === lfound || t === cfound || t === lnfound) { continue; } else if (ofound.indexOf(t) >= 0) { continue; } const inline = t === null || t === void 0 ? void 0 : t.findDirectExpression(Expressions.InlineData); if (inline) { inline_data_1.InlineData.runSyntax(inline, input, basic_1.StringType.get()); } else { target_1.Target.runSyntax(t, input); } } } } ///////////////////// inline(node, input, type) { const inline = node.findDirectExpression(Expressions.InlineData); if (inline) { inline_data_1.InlineData.runSyntax(inline, input, type); } else { target_1.Target.runSyntax(node, input); } } } exports.Find = Find; //# sourceMappingURL=find.js.map