@madie/cql-antlr-parser
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -11,3 +11,2 @@ "use strict"; | ||
const CustomErrorListener_1 = __importDefault(require("./CustomErrorListener")); | ||
const CqlExpressionVisitor_1 = __importDefault(require("./CqlExpressionVisitor")); | ||
class CqlAntlr { | ||
@@ -22,4 +21,8 @@ constructor(cql) { | ||
tree_1.ParseTreeWalker.DEFAULT.walk(listener, tree); | ||
const cqlExpressionVisitor = new CqlExpressionVisitor_1.default(result); | ||
cqlExpressionVisitor.visit(tree); | ||
/** | ||
* Disabled. Only partially implemented and would be | ||
* a duplicate of checks performed by the CQL-to-ELM Translator. | ||
*/ | ||
// const cqlExpressionVisitor = new CqlExpressionVisitor(result); | ||
// cqlExpressionVisitor.visit(tree); | ||
return result; | ||
@@ -36,3 +39,3 @@ } | ||
expressionDefinitions: [], | ||
errors: [] | ||
errors: [], | ||
}; | ||
@@ -39,0 +42,0 @@ } |
@@ -14,3 +14,4 @@ "use strict"; | ||
build() { | ||
CqlVersionCreator_1.default.setNameVersion(this.ctx.children, this.cqlDao); | ||
var _a; | ||
CqlVersionCreator_1.default.setNameVersion((_a = this.ctx) === null || _a === void 0 ? void 0 : _a.children, this.cqlDao); | ||
this.cqlDao.name = this.findChildText(generated_1.cqlLexer.IDENTIFIER); | ||
@@ -17,0 +18,0 @@ return this.cqlDao; |
@@ -1,2 +0,2 @@ | ||
import { ANTLRErrorListener } from "antlr4ts"; | ||
import { ANTLRErrorListener, CommonToken } from "antlr4ts"; | ||
import { Recognizer } from "antlr4ts/Recognizer"; | ||
@@ -6,7 +6,10 @@ import { Token } from "antlr4ts/Token"; | ||
import CqlResult from "./dto/CqlResult"; | ||
/** | ||
* Fires on grammar errors. | ||
*/ | ||
export default class CustomErrorListener implements ANTLRErrorListener<Token> { | ||
private cqlResult; | ||
constructor(cqlResult: CqlResult); | ||
syntaxError<T extends Token>(recognizer: Recognizer<T, ParserATNSimulator>, offendingSymbol: T | undefined, line: number, charPositionInLine: number, msg: string): void; | ||
syntaxError<T extends Token>(recognizer: Recognizer<T, ParserATNSimulator>, offendingSymbol: T | CommonToken | undefined, line: number, charPositionInLine: number, msg: string): void; | ||
} | ||
//# sourceMappingURL=CustomErrorListener.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Fires on grammar errors. | ||
*/ | ||
class CustomErrorListener { | ||
@@ -11,6 +14,14 @@ constructor(cqlResult) { | ||
text: offendingSymbol.text, | ||
start: { line, position: offendingSymbol.startIndex }, | ||
stop: { line, position: offendingSymbol.stopIndex }, | ||
start: { | ||
line, | ||
position: offendingSymbol.charPositionInLine, | ||
}, | ||
stop: { | ||
line, | ||
position: offendingSymbol.charPositionInLine + | ||
(offendingSymbol.stopIndex - offendingSymbol.startIndex) + | ||
1, // plus 1 to ensure full text is included in Ace Editor highlight | ||
}, | ||
name: offendingSymbol.text, | ||
message: msg | ||
message: msg, | ||
}); | ||
@@ -17,0 +28,0 @@ } |
@@ -22,7 +22,7 @@ "use strict"; | ||
expect(cqlResult.codeSystems.length).toBe(3); | ||
expect(cqlResult.errors.length).toBe(4); | ||
expect(cqlResult.errors.length).toBe(3); | ||
expect(cqlResult.errors[0].name).toBe("includess"); | ||
expect(cqlResult.errors[0].message).toContain("extraneous input 'includess' expecting"); | ||
expect(cqlResult.errors[0].start).toEqual({ line: 6, position: 180 }); | ||
expect(cqlResult.errors[0].stop).toEqual({ line: 6, position: 188 }); | ||
expect(cqlResult.errors[0].start).toEqual({ line: 6, position: 0 }); | ||
expect(cqlResult.errors[0].stop).toEqual({ line: 6, position: 9 }); | ||
expect(cqlResult.errors[1].name).toBe("valuesetss"); | ||
@@ -66,3 +66,3 @@ expect(cqlResult.errors[2].name).toBe("Interval"); | ||
const cqlResult = cqlAntlr.parse(); | ||
expect(cqlResult.errors.length).toEqual(1); | ||
expect(cqlResult.errors.length).toEqual(0); | ||
}); | ||
@@ -69,0 +69,0 @@ it("should recognize cql 1.5 aggregate clause", () => { |
{ | ||
"name": "@madie/cql-antlr-parser", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Antlr Parsing of CQL in typescript", | ||
@@ -37,4 +37,4 @@ "publishConfig": { | ||
"@types/jest": "^27.4.0", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"@typescript-eslint/eslint-plugin": "^5.9.0", | ||
"@typescript-eslint/parser": "^5.9.0", | ||
"eslint": "^8.6.0", | ||
@@ -45,6 +45,6 @@ "eslint-config-airbnb-typescript": "^16.1.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-jest": "^25.3.4", | ||
"eslint-plugin-jest": "^26.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"jest": "^27.4.5", | ||
"jest-extended": "^1.2.0", | ||
"jest": "^27.4.7", | ||
"jest-extended": "^2.0.0", | ||
"prettier": "^2.5.1", | ||
@@ -51,0 +51,0 @@ "ts-jest": "^27.1.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1541120
22149
1