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

Parsing was aborted error while using popMode/pushMode #478

Closed
gregbugaj opened this issue Sep 9, 2021 · 4 comments
Closed

Parsing was aborted error while using popMode/pushMode #478

gregbugaj opened this issue Sep 9, 2021 · 4 comments

Comments

@gregbugaj
Copy link

gregbugaj commented Sep 9, 2021

Plugin shows an error while trying to 'Test ANTL Rule' while trying to use pushMode and popMode
However the runtime(javascript) has not issues processing the input.

Input :

class a13 extends `` {}

Lexer rule :

BackTick:                       '`' {this.IncreaseTemplateDepth();} -> pushMode(TEMPLATE);
mode TEMPLATE;
BackTickInside:                 '`' {this.DecreaseTemplateDepth();} -> type(BackTick), popMode;
TemplateStringStartExpression:  '${' -> pushMode(DEFAULT_MODE);
TemplateStringAtom:             ~[`];

Exception in IntelliJ

java.util.EmptyStackException
	at org.antlr.v4.runtime.Lexer.popMode(Lexer.java:192)
	at org.antlr.v4.runtime.atn.LexerPopModeAction.execute(LexerPopModeAction.java:58)
	at org.antlr.v4.runtime.atn.LexerActionExecutor.execute(LexerActionExecutor.java:168)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.accept(LexerATNSimulator.java:366)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.failOrAccept(LexerATNSimulator.java:299)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.execATN(LexerATNSimulator.java:230)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.matchATN(LexerATNSimulator.java:156)
	at org.antlr.v4.runtime.atn.LexerATNSimulator.match(LexerATNSimulator.java:111)
	at org.antlr.v4.runtime.Lexer.nextToken(Lexer.java:141)
	at org.antlr.v4.runtime.BufferedTokenStream.fetch(BufferedTokenStream.java:169)
	at org.antlr.v4.runtime.BufferedTokenStream.fill(BufferedTokenStream.java:485)
	at org.antlr.v4.runtime.BufferedTokenStream.getText(BufferedTokenStream.java:452)
	at org.antlr.v4.runtime.BufferedTokenStream.getText(BufferedTokenStream.java:474)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:304)
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
	at org.antlr.v4.runtime.ParserInterpreter.parse(ParserInterpreter.java:199)
	at org.antlr.intellij.plugin.parsing.ParsingUtils.parseText(ParsingUtils.java:251)
	at org.antlr.intellij.plugin.parsing.ParsingUtils.parseText(ParsingUtils.java:211)
	at org.antlr.intellij.plugin.ANTLRv4PluginController.lambda$parseText$1(ANTLRv4PluginController.java:438)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.lambda$computeInBackgroundAndTryWait$6(BackgroundTaskUtil.java:170)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:183)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
	at com.intellij.openapi.progress.util.BackgroundTaskUtil.lambda$computeInBackgroundAndTryWait$7(BackgroundTaskUtil.java:169)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:265)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
	at java.base/java.lang.Thread.run(Thread.java:829)
@bjansen
Copy link
Collaborator

bjansen commented Sep 10, 2021

The IDE delegates the actual parsing to ANTLR, so I think it's either a bug in your grammar or a bug that should be reported at https://github.com/antlr/antlr4

Have you tried generating a Java parser and testing your input with grun? If the Java parser also fails to parse your input, that could indicate a bug in your grammar.

@KvanTTT
Copy link
Member

KvanTTT commented Sep 10, 2021

Most likely this relates to antlr/antlr4#2006

@parrt
Copy link
Member

parrt commented Feb 20, 2022

Hi. since this is executing actions it can't be an issue with the plug-in so I will close.

@KvanTTT
Copy link
Member

KvanTTT commented Feb 20, 2022

It doesn't relate to actions, it can be reproduced using very simple grammar:

lexer grammar T;
A: 'aa';
B: 'bb' -> popMode;
C: 'cc';

Input:

aabbcc

But it's related to ANTLR core, not plugin.

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

4 participants