ANTLR Parse listener implementations
(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException)
| 823 | |
| 824 | // ANTLR Parse listener implementations |
| 825 | func (p *antlrVisitor) SyntaxError(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException) { |
| 826 | offset := p.helper.sourceInfo.ComputeOffset(int32(line), int32(column)) |
| 827 | l := p.helper.getLocationByOffset(offset) |
| 828 | // Hack to keep existing error messages consistent with previous versions of CEL when a reserved word |
| 829 | // is used as an identifier. This behavior needs to be overhauled to provide consistent, normalized error |
| 830 | // messages out of ANTLR to prevent future breaking changes related to error message content. |
| 831 | if strings.Contains(msg, "no viable alternative") { |
| 832 | msg = reservedIdentifier.ReplaceAllString(msg, mismatchedReservedIdentifier) |
| 833 | } |
| 834 | // Ensure that no more than 100 syntax errors are reported as this will halt attempts to recover from a |
| 835 | // seriously broken expression. |
| 836 | if p.errorReports < p.errorReportingLimit { |
| 837 | p.errorReports++ |
| 838 | p.errors.syntaxError(l, msg) |
| 839 | } else { |
| 840 | tme := &tooManyErrors{errorReportingLimit: p.errorReportingLimit} |
| 841 | p.errors.syntaxError(l, tme.Error()) |
| 842 | panic(tme) |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | func (p *antlrVisitor) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs *antlr.ATNConfigSet) { |
| 847 | // Intentional |
nothing calls this directly
no test coverage detected