@madie/cql-antlr-parser
Version:
Antlr Parsing of CQL in typescript
41 lines • 1.76 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const CreatorBase_1 = __importDefault(require("./CreatorBase"));
const CqlVersionCreator_1 = __importDefault(require("./CqlVersionCreator"));
const generated_1 = require("../generated");
const AntlrUtils_1 = __importDefault(require("./AntlrUtils"));
class CqlExpressionDefinitionCreator extends CreatorBase_1.default {
constructor(ctx) {
super(ctx, {});
}
findExpressionType(children, lexerType, occurrence = 1) {
if (children) {
const foundChild = AntlrUtils_1.default.findChild(children, lexerType, occurrence);
this.processExpressionClass(foundChild);
}
}
processExpressionClass(foundChild) {
if (foundChild) {
this.cqlDao.expressionClass = foundChild.constructor.name;
}
}
build() {
CqlVersionCreator_1.default.setNameVersion(this.ctx.children, this.cqlDao);
this.cqlDao.name = this.findChildName();
this.cqlDao.expression = this.findChildExpression();
if (!this.cqlDao.expression) {
const foundChild = AntlrUtils_1.default.findChild(this.ctx.children, generated_1.cqlLexer.T__36, 1);
this.cqlDao.expression = this.findChildText(generated_1.cqlLexer.T__36, 1);
this.processExpressionClass(foundChild);
}
else {
this.findExpressionType(this.ctx.children, generated_1.cqlLexer.IDENTIFIER, 1);
}
return this.cqlDao;
}
}
exports.default = CqlExpressionDefinitionCreator;
//# sourceMappingURL=CqlExpressionDefinitionCreator.js.map