Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Class constructor Lexer cannot be invoked without 'new' #310

Closed
AdityaDaksha opened this issue Apr 27, 2017 · 4 comments
Closed

Comments

@AdityaDaksha
Copy link

AdityaDaksha commented Apr 27, 2017

 ngOnInit() {
      //console.log(this.response);
      this.testAntlr4ts();
 }

  testAntlr4ts() {
      // Create the lexer and parser
      let inputStream = new ANTLRInputStream("text");
      let lexer = new GrammerLexer(inputStream);
      let tokenStream = new CommonTokenStream(lexer);
      let parser = new GrammerParser(tokenStream);

      //parser.buildParseTrees = true;
      let tree = parser.expression();
      console.log(tree);
  }

getting below exception:

at new BQLLexer (http://localhost:4200/main.bundle.js:732:16)
    at RuleAppComponent.webpackJsonp.750.RuleAppComponent.testAntlr4ts (http://localhost:4200/main.bundle.js:546:21)
    at RuleAppComponent.webpackJsonp.750.RuleAppComponent.ngOnInit (http://localhost:4200/main.bundle.js:541:14)
    at Wrapper_RuleAppComponent.ngDoCheck (/AppModule/RuleAppComponent/wrapper.ngfactory.js:22:53)
    at CompiledTemplate.proxyViewClass.View_AppComponent0.detectChangesInternal (/AppModule/AppComponent/component.ngfactory.js:53:30)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:4200/vendor.bundle.js:114333:14)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:4200/vendor.bundle.js:114528:44)
    at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (http://localhost:4200/vendor.bundle.js:114318:18)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.detectChangesInternal (/AppModule/AppComponent/host.ngfactory.js:29:19)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:4200/vendor.bundle.js:114333:14)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:4200/vendor.bundle.js:114528:44)
    at ViewRef_.detectChanges (http://localhost:4200/vendor.bundle.js:76866:20)
    at http://localhost:4200/vendor.bundle.js:51073:67
    at Array.forEach (native)
    at ApplicationRef_.tick (http://localhost:4200/vendor.bundle.js:51073:25)

package.json

{
  "name": "app",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --proxy-config proxy.config.json",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "antlr4ts": "antlr4ts -visitor C:/**/Grammer.g4"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "angular-split": "^0.1.20",
    "angular2-froala-wysiwyg": "^2.5.1-2",
    "angular2-resizable": "^0.4.1",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "ng2-bootstrap": "^1.6.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.7.6",
    "antlr4ts": "^0.4.0-alpha.4"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-rc.1",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "antlr4ts": "^0.4.0-alpha.4",
    "antlr4ts-cli": "^0.4.0-alpha.4",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.1.1",
    "ts-node": "~2.0.0",
    "tslint": "~4.4.2",
    "typescript": "~2.0.0"
  }
}
@nehaagrawal
Copy link

nehaagrawal commented May 1, 2017

can someone please help us here. We are getting this error when it executes constructor for Lexer.js

//generated code from MyLexer.ts
constructor(input: CharStream) {
		super(input); // it fails here while calling Lexer.js 
		this._interp = new LexerATNSimulator(BQLLexer._ATN, this);
	}

@BurtHarris
Copy link
Collaborator

To date, we have not tackled getting antlr4ts to run on browsers, we recognize that it's desirable but it is not currently in scope for our first release, so helping with the current info provided is tricky. If you can simplify the sample code for this issue to be node.js only, we can probably tackle it sooner. Ideally you could point me at a simpler sample project on github rather than embed project files in the issue description.

@mindhivefi
Copy link

I think this could be fixed by setting the tsconfig's target to es5. Is there some reason why it has been set to es2015?

@sharwell
Copy link
Member

Duplicate of #326

@sharwell sharwell marked this as a duplicate of #326 Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants