Package org.apache.groovy.parser.antlr4
Interface SyntaxErrorReportable
- All Known Implementing Classes:
AbstractLexer,AbstractParser,GroovyLangLexer,GroovyLangParser,GroovyLexer,GroovyParser
public interface SyntaxErrorReportable
A SyntaxErrorReportable is a recognizer that can report syntax error
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault PositionInfogenPositionInfo(int offset) Builds a position from the current error line and the current error column plusoffset.default PositionInfogenPositionInfo(Tuple2<Integer, Integer> offset) Builds a position by addingoffsetto the current error line and column.intReturns the 1-based column of the current syntax error.intReturns the 1-based line of the current syntax error.intReturns whether this reporter is the lexer or the parser.default voidThrows a syntax error whenconditionis false, at the current error position, without repeating that position in the message.default voidThrows a syntax error whenconditionis false, without a position adjustment.default voidThrows a syntax error whenconditionis false, addingoffsetto the current error column.default voidThrows a syntax error whenconditionis false.default voidThrows a syntax error whenconditionis false.default voidrequire(boolean condition, String msg, Tuple2<Integer, Integer> offset, boolean toAttachPositionInfo) Throws a syntax error whenconditionis false.default voidthrowSyntaxError(String msg, int offset, boolean toAttachPositionInfo) Throws a syntax error whose column is the current error column plusoffset.default voidthrowSyntaxError(String msg, Tuple2<Integer, Integer> offset, boolean toAttachPositionInfo)
-
Field Details
-
NO_OFFSET
A line offset of zero and a column offset of zero.
-
-
Method Details
-
require
Throws a syntax error whenconditionis false.offsetis added to the current error column; the line is not adjusted.- Parameters:
condition- requirement that must holdmsg- the error textoffset- columns added to the current error columntoAttachPositionInfo- whether the message includes the caret position
-
require
default void require(boolean condition, String msg, Tuple2<Integer, Integer> offset, boolean toAttachPositionInfo) Throws a syntax error whenconditionis false.offset's first value is added to the error line and its second value to the error column.- Parameters:
condition- requirement that must holdmsg- the error textoffset- line adjustment, then column adjustmenttoAttachPositionInfo- whether the message includes the caret position
-
require
Throws a syntax error whenconditionis false, without a position adjustment.toAttachPositionInfoselects whether the message includes the caret position.- Parameters:
condition- requirement that must holdmsg- the error texttoAttachPositionInfo- whether the message includes the caret position
-
require
Throws a syntax error whenconditionis false, addingoffsetto the current error column. The message does not repeat the caret position.- Parameters:
condition- requirement that must holdmsg- the error textoffset- columns added to the current error column
-
require
Throws a syntax error whenconditionis false.offset's first value is added to the error line and its second value to the error column. The message does not repeat the caret position.- Parameters:
condition- requirement that must holdmsg- the error textoffset- line adjustment, then column adjustment
-
require
Throws a syntax error whenconditionis false, at the current error position, without repeating that position in the message.- Parameters:
condition- requirement that must holdmsg- the error text
-
throwSyntaxError
Throws a syntax error whose column is the current error column plusoffset.- Parameters:
msg- the error textoffset- columns added to the current error columntoAttachPositionInfo- whether the message includes the caret position
-
throwSyntaxError
default void throwSyntaxError(String msg, Tuple2<Integer, Integer> offset, boolean toAttachPositionInfo) - Parameters:
toAttachPositionInfo- iftrue, append" @ line N, column M"to the exception message. Leavefalsewhen the error will be wrapped inSyntaxException, which already appends the same location (otherwise the displayed message repeats the position).
-
getSyntaxErrorSource
int getSyntaxErrorSource()Returns whether this reporter is the lexer or the parser.- Returns:
GroovySyntaxError.LEXERorGroovySyntaxError.PARSER
-
genPositionInfo
Builds a position from the current error line and the current error column plusoffset.- Parameters:
offset- columns added to the current error column- Returns:
- that position
-
genPositionInfo
Builds a position by addingoffsetto the current error line and column.- Parameters:
offset- line adjustment, then column adjustment- Returns:
- that position
-
getErrorLine
int getErrorLine()Returns the 1-based line of the current syntax error.- Returns:
- the error line
-
getErrorColumn
int getErrorColumn()Returns the 1-based column of the current syntax error.- Returns:
- the error column
-