Codes:
import { InputStream, CommonTokenStream, Lexer, Token } from 'antlr4';
import antlr4 from 'antlr4';
import PrestoSqlLexer from '../lib/presto/PrestoSqlLexer';
import PrestoSqlParser from '../lib/presto/PrestoSqlParser';
import BaseParser from './common/baseParser';
import {CodeCompletionCore} from "antlr4-c3";
public suggest(sqlScript: string, atIndex?: number): AutocompleteOption[] {
...
// core
const core = new CodeCompletionCore(parser);
// core.ignoredTokens = new Set([
// ]);
return [];
}
I got errors like
TypeError: Class extends value undefined is not a constructor or null
9 | } from './common/parserErrorListener';
10 | import { AutocompleteOption } from './common/AutocompleteOption';
> 11 | import { CodeCompletionCore } from 'antlr4-c3';
| ^
12 |
13 | export default class PrestoSQL extends BaseParser {
14 | public createLexer(input: string): antlr4.Lexer {
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/xpath/XPathLexer.ts:18:33)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/xpath/XPath.ts:16:1)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/xpath/index.ts:6:1)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/index.ts:18:1)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/index.ts:9:1)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4-c3-npm-2.2.1-db3ae1db96-8dd44825f3.zip/node_modules/antlr4-c3/src/CodeCompletionCore.ts:10:1)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4-c3-npm-2.2.1-db3ae1db96-8dd44825f3.zip/node_modules/antlr4-c3/index.ts:8:1)
at Object.<anonymous> (src/parser/presto.ts:11:1)
at Object.<anonymous> (src/parser/index.ts:3:1)
at Object.<anonymous> (src/index.ts:1:1)
any idea why? thanks
I tried to change the import syntax, but failed.
can someone take a look? thank.
is this related to typescript version?
btw, below are deps versions
"dependencies": {
"@types/antlr4": "4.7.0",
"antlr4": "^4.9.3",
"antlr4-c3": "^2.2.1",
"antlr4ts": "^0.5.0-alpha.4",
},
UPDATE
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/xpath/XPathLexer.ts:18:33)
at Object.<anonymous> (../../../../../../.yarn/cache/antlr4ts-npm-0.5.0-dev-7e0fc8988a-640dae2229.zip/node_modules/src/tree/xpath/XPath.ts:16:1)
tree/xpath/XPath.ts:16:1 is pointing to rc/tree/xpath/XPathLexer.ts:18:33
but I did not find the XPatchLexer.ts in https://github.com/tunnelvisionlabs/antlr4ts/tree/0.5.0-alpha.4/src/tree/xpath
anything wrong with my package installing? thanks
but but in my POC node_modules, I saw XPathLexer.d.js (see the attached screenshoot)
This error usually comes up when you have a circular dependency, which cannot automatically resolved. Look at the error trace. It starts in antlr4-c3 index to load the C3 class, goes through some steps and ends up again in the C3 class, which is imported by the code shown. However, it's unclear to me how the step from XPathLexer to your file happens, but the solution is to import the class you derive from directly, instead of using a shortcut via the index file of the lib.
A more detailed description of the problem and a solution can be found at How to fix nasty circular dependency issues once and for all in JavaScript & TypeScript
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.