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

Method Declare

repl/parser/commands_parser.go:1318–1370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1316}
1317
1318func (p *CommandsParser) Declare() (localctx IDeclareContext) {
1319 localctx = NewDeclareContext(p, p.GetParserRuleContext(), p.GetState())
1320 p.EnterRule(localctx, 8, CommandsParserRULE_declare)
1321 p.EnterOuterAlt(localctx, 1)
1322 {
1323 p.SetState(101)
1324 p.Match(CommandsParserT__3)
1325 if p.HasError() {
1326 // Recognition error - abort rule
1327 goto errorExit
1328 }
1329 }
1330 p.SetState(104)
1331 p.GetErrorHandler().Sync(p)
1332 if p.HasError() {
1333 goto errorExit
1334 }
1335
1336 switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 2, p.GetParserRuleContext()) {
1337 case 1:
1338 {
1339 p.SetState(102)
1340
1341 var _x = p.VarDecl()
1342
1343 localctx.(*DeclareContext).var_ = _x
1344 }
1345
1346 case 2:
1347 {
1348 p.SetState(103)
1349
1350 var _x = p.FnDecl()
1351
1352 localctx.(*DeclareContext).fn = _x
1353 }
1354
1355 case antlr.ATNInvalidAltNumber:
1356 goto errorExit
1357 }
1358
1359errorExit:
1360 if p.HasError() {
1361 v := p.GetError()
1362 localctx.SetException(v)
1363 p.GetErrorHandler().ReportError(p, v)
1364 p.GetErrorHandler().Recover(p, v)
1365 p.SetError(nil)
1366 }
1367 p.ExitRule()
1368 return localctx
1369 goto errorExit // Trick to prevent compiler error if the label is not used
1370}
1371
1372// IVarDeclContext is an interface to support dynamic dispatch.
1373type IVarDeclContext interface {

Callers 1

CommandMethod · 0.95

Calls 9

VarDeclMethod · 0.95
FnDeclMethod · 0.95
NewDeclareContextFunction · 0.85
ReportErrorMethod · 0.80
RecoverMethod · 0.80
GetStateMethod · 0.65
MatchMethod · 0.65
EnterRuleMethod · 0.45
ExitRuleMethod · 0.45

Tested by

no test coverage detected