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

Function extractSourceText

repl/commands.go:165–173  ·  view source on GitHub ↗

extractSourceText extracts original text from a parse rule match. Preserves original whitespace if possible.

(ctx antlr.ParserRuleContext)

Source from the content-addressed store, hash-verified

163// extractSourceText extracts original text from a parse rule match.
164// Preserves original whitespace if possible.
165func extractSourceText(ctx antlr.ParserRuleContext) string {
166 if ctx.GetStart() == nil || ctx.GetStop() == nil ||
167 ctx.GetStart().GetStart() < 0 || ctx.GetStop().GetStop() < 0 {
168 // fallback to the normalized parse
169 return ctx.GetText()
170 }
171 s, e := ctx.GetStart().GetStart(), ctx.GetStop().GetStop()
172 return ctx.GetStart().GetInputStream().GetText(s, e)
173}
174
175// Parse parses a repl command line into a command object. This provides
176// the normalized command name plus any parsed parameters (e.g. variable names

Callers 1

ExitExprMethod · 0.85

Calls 1

GetTextMethod · 0.80

Tested by

no test coverage detected