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

Unable to parse Java8.g4 with javascript runtime #2576

Closed
onuba opened this issue Jun 18, 2019 · 1 comment
Closed

Unable to parse Java8.g4 with javascript runtime #2576

onuba opened this issue Jun 18, 2019 · 1 comment

Comments

@onuba
Copy link

onuba commented Jun 18, 2019

Hi all,

I am trying to parse Java files with Java8.g4 grammar from github; when I launch my jest test on NodeJS, I get the following error on the Java8Lexer.js generated file:

`SyntaxError: C:\git\stable\ncore\src\java8\antlr4\grammars\java8\Java8Lexer.js: Unexpected token, expected "," (956:70)

  954 |                     return Character.isJavaIdentifierStart(_input.LA(-1));
  955 |             case 1:
> 956 |                     return Character.isJavaIdentifierStart(Character.toCodePoint((char)_input.LA(-2), (char)_input.LA(-1)));
      |                                                                                        ^
  957 |             default:
  958 |                     throw "No predicate with index:" + predIndex;
  959 |     }

  at Parser.raise (node_modules/@babel/parser/lib/index.js:6344:17)
  at Parser.unexpected (node_modules/@babel/parser/lib/index.js:7659:16)
  at Parser.expect (node_modules/@babel/parser/lib/index.js:7645:28)
  at Parser.parseCallExpressionArguments (node_modules/@babel/parser/lib/index.js:8605:14)
  at Parser.parseSubscript (node_modules/@babel/parser/lib/index.js:8515:29)
  at Parser.parseSubscripts (node_modules/@babel/parser/lib/index.js:8434:19)
  at Parser.parseExprSubscripts (node_modules/@babel/parser/lib/index.js:8423:17)
  at Parser.parseMaybeUnary (node_modules/@babel/parser/lib/index.js:8393:21)
  at Parser.parseExprOps (node_modules/@babel/parser/lib/index.js:8280:23)
  at Parser.parseMaybeConditional (node_modules/@babel/parser/lib/index.js:8253:23)`

I generated the javascript grammar files with antlr maven plugin, using the option for it

`

<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.7.2</version>
<executions>
	<!-- Generate the JS parser -->
	<execution>
		<id>js</id>
		<goals>
			<goal>antlr4</goal>
		</goals>
		<configuration>
			<arguments>
				<argument>-Dlanguage=JavaScript</argument>
			</arguments>
		</configuration>
	</execution>
</executions>

`

I saw a similar issue with go and Java.g4 grammar on #1397

¿Maybe is necessary to apply the same patch to Java8.g4 that was applied to Java.g4 in this comment #1397 (comment)?

P.D: Windows 10 with NodeJS v10.15.3 and antlr4 v4.7.2, the files were generated with openJDK 11 and eclipse 2019-03

Thanks in advice!

@onuba
Copy link
Author

onuba commented Jun 18, 2019

OK! My mistake!!! I see a java8 grammar for javascript target at https://github.com/antlr/grammars-v4/tree/master/java8-js .

I will use it. Closing this.

@onuba onuba closed this as completed Jun 18, 2019
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

1 participant