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

Method SyntaxError

parser/parser.go:912–931  ·  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

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