MCPcopy Create free account
hub / github.com/cel-expr/cel-go / SyntaxError

Method SyntaxError

parser/antlr_parser.go:825–844  ·  view source on GitHub ↗

ANTLR Parse listener implementations

(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException)

Source from the content-addressed store, hash-verified

823
824// ANTLR Parse listener implementations
825func (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
846func (p *antlrVisitor) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs *antlr.ATNConfigSet) {
847 // Intentional

Callers

nothing calls this directly

Calls 5

ErrorMethod · 0.95
ComputeOffsetMethod · 0.80
getLocationByOffsetMethod · 0.80
syntaxErrorMethod · 0.80
ContainsMethod · 0.65

Tested by

no test coverage detected