forked from antlr/antlr4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report LexerEmptyModeStackException and recover instead of throwing e…
…mpty stack exception, fixes antlr#2006 Fixed for Java, C#, Python2/3, JavaScript, Go runtimes Need to be fixed: C++, Swift, Dart, PHP
- Loading branch information
Showing
17 changed files
with
270 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Antlr4.Runtime | ||
{ | ||
public class LexerEmptyModeStackException : LexerException | ||
{ | ||
public LexerEmptyModeStackException(Lexer lexer, ICharStream input, int startIndex) : base(lexer, input, startIndex) | ||
{ | ||
} | ||
|
||
public override string GetErrorMessage(string input) | ||
{ | ||
return "Unable to pop mode because modes stack is empty at: '" + input + "'"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Antlr4.Runtime | ||
{ | ||
public abstract class LexerException : RecognitionException | ||
{ | ||
/** Matching attempted at what input index? */ | ||
public readonly int StartIndex; | ||
|
||
protected LexerException(Lexer lexer, ICharStream input, int startIndex) : base(lexer, input) | ||
{ | ||
StartIndex = startIndex; | ||
} | ||
|
||
public abstract string GetErrorMessage(string input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
runtime/Java/src/org/antlr/v4/runtime/LexerEmptyModeStackException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.antlr.v4.runtime; | ||
|
||
public class LexerEmptyModeStackException extends LexerException { | ||
public LexerEmptyModeStackException(Lexer lexer, IntStream input, int startIndex) { | ||
super(lexer, input, startIndex); | ||
} | ||
|
||
@Override | ||
public String getErrorMessage(String input) { | ||
return "Unable to pop mode because modes stack is empty at: '" + input + "'"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.antlr.v4.runtime; | ||
|
||
public abstract class LexerException extends RecognitionException { | ||
/** Matching attempted at what input index? */ | ||
protected final int startIndex; | ||
|
||
public LexerException(Lexer lexer, IntStream input, int startIndex) { | ||
super(lexer, input, null); | ||
this.startIndex = startIndex; | ||
} | ||
|
||
public int getStartIndex() { | ||
return startIndex; | ||
} | ||
|
||
public abstract String getErrorMessage(String input); | ||
} |
Oops, something went wrong.