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

Method SyntaxError

parser/parser.go:920–939  ·  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

918
919// ANTLR Parse listener implementations
920func (p *parser) SyntaxError(recognizer antlr.Recognizer, offendingSymbol any, line, column int, msg string, e antlr.RecognitionException) {
921 offset := p.helper.sourceInfo.ComputeOffset(int32(line), int32(column))
922 l := p.helper.getLocationByOffset(offset)
923 // Hack to keep existing error messages consistent with previous versions of CEL when a reserved word
924 // is used as an identifier. This behavior needs to be overhauled to provide consistent, normalized error
925 // messages out of ANTLR to prevent future breaking changes related to error message content.
926 if strings.Contains(msg, "no viable alternative") {
927 msg = reservedIdentifier.ReplaceAllString(msg, mismatchedReservedIdentifier)
928 }
929 // Ensure that no more than 100 syntax errors are reported as this will halt attempts to recover from a
930 // seriously broken expression.
931 if p.errorReports < p.errorReportingLimit {
932 p.errorReports++
933 p.errors.syntaxError(l, msg)
934 } else {
935 tme := &tooManyErrors{errorReportingLimit: p.errorReportingLimit}
936 p.errors.syntaxError(l, tme.Error())
937 panic(tme)
938 }
939}
940
941func (p *parser) ReportAmbiguity(recognizer antlr.Parser, dfa *antlr.DFA, startIndex, stopIndex int, exact bool, ambigAlts *antlr.BitSet, configs *antlr.ATNConfigSet) {
942 // 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