expr

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExprLexerT__0    = 1
	ExprLexerT__1    = 2
	ExprLexerT__2    = 3
	ExprLexerT__3    = 4
	ExprLexerT__4    = 5
	ExprLexerT__5    = 6
	ExprLexerT__6    = 7
	ExprLexerIDENT   = 8
	ExprLexerSTRING  = 9
	ExprLexerINTEGER = 10
	ExprLexerFLOAT   = 11
	ExprLexerWS      = 12
)

ExprLexer tokens.

View Source
const (
	ExprParserEOF     = antlr.TokenEOF
	ExprParserT__0    = 1
	ExprParserT__1    = 2
	ExprParserT__2    = 3
	ExprParserT__3    = 4
	ExprParserT__4    = 5
	ExprParserT__5    = 6
	ExprParserT__6    = 7
	ExprParserIDENT   = 8
	ExprParserSTRING  = 9
	ExprParserINTEGER = 10
	ExprParserFLOAT   = 11
	ExprParserWS      = 12
)

ExprParser tokens.

View Source
const (
	ExprParserRULE_root          = 0
	ExprParserRULE_expr          = 1
	ExprParserRULE_innerExprList = 2
	ExprParserRULE_innerExpr     = 3
	ExprParserRULE_fieldAccess   = 4
	ExprParserRULE_value         = 5
)

ExprParser rules.

Variables

View Source
var ExprLexerLexerStaticData struct {
	ChannelNames           []string
	ModeNames              []string
	LiteralNames           []string
	SymbolicNames          []string
	RuleNames              []string
	PredictionContextCache *antlr.PredictionContextCache
	// contains filtered or unexported fields
}
View Source
var ExprParserStaticData struct {
	LiteralNames           []string
	SymbolicNames          []string
	RuleNames              []string
	PredictionContextCache *antlr.PredictionContextCache
	// contains filtered or unexported fields
}

Functions

func ExprLexerInit

func ExprLexerInit()

ExprLexerInit initializes any static state used to implement ExprLexer. By default the static state used to implement the lexer is lazily initialized during the first call to NewExprLexer(). You can call this function if you wish to initialize the static state ahead of time.

func ExprParserInit

func ExprParserInit()

ExprParserInit initializes any static state used to implement ExprParser. By default the static state used to implement the parser is lazily initialized during the first call to NewExprParser(). You can call this function if you wish to initialize the static state ahead of time.

func InitEmptyExprContext

func InitEmptyExprContext(p *ExprContext)

func InitEmptyFieldAccessContext

func InitEmptyFieldAccessContext(p *FieldAccessContext)

func InitEmptyInnerExprContext

func InitEmptyInnerExprContext(p *InnerExprContext)

func InitEmptyInnerExprListContext

func InitEmptyInnerExprListContext(p *InnerExprListContext)

func InitEmptyRootContext

func InitEmptyRootContext(p *RootContext)

func InitEmptyValueContext

func InitEmptyValueContext(p *ValueContext)

func Parse

func Parse(data string) (ret map[string]string, err error)

Parse parses an expression string into a flat map representation.

Example:

Input:  Logger { level = "info", path = /var/log/app.log }
Output: map[string]string{
           "type": "Logger",
           "level": "info",
           "path":  "/var/log/app.log",
        }

Types

type BaseExprListener

type BaseExprListener struct{}

BaseExprListener is a complete listener for a parse tree produced by ExprParser.

func (*BaseExprListener) EnterEveryRule

func (s *BaseExprListener) EnterEveryRule(ctx antlr.ParserRuleContext)

EnterEveryRule is called when any rule is entered.

func (*BaseExprListener) EnterExpr

func (s *BaseExprListener) EnterExpr(ctx *ExprContext)

EnterExpr is called when production expr is entered.

func (*BaseExprListener) EnterFieldAccess

func (s *BaseExprListener) EnterFieldAccess(ctx *FieldAccessContext)

EnterFieldAccess is called when production fieldAccess is entered.

func (*BaseExprListener) EnterInnerExpr

func (s *BaseExprListener) EnterInnerExpr(ctx *InnerExprContext)

EnterInnerExpr is called when production innerExpr is entered.

func (*BaseExprListener) EnterInnerExprList

func (s *BaseExprListener) EnterInnerExprList(ctx *InnerExprListContext)

EnterInnerExprList is called when production innerExprList is entered.

func (*BaseExprListener) EnterRoot

func (s *BaseExprListener) EnterRoot(ctx *RootContext)

EnterRoot is called when production root is entered.

func (*BaseExprListener) EnterValue

func (s *BaseExprListener) EnterValue(ctx *ValueContext)

EnterValue is called when production value is entered.

func (*BaseExprListener) ExitEveryRule

func (s *BaseExprListener) ExitEveryRule(ctx antlr.ParserRuleContext)

ExitEveryRule is called when any rule is exited.

func (*BaseExprListener) ExitExpr

func (s *BaseExprListener) ExitExpr(ctx *ExprContext)

ExitExpr is called when production expr is exited.

func (*BaseExprListener) ExitFieldAccess

func (s *BaseExprListener) ExitFieldAccess(ctx *FieldAccessContext)

ExitFieldAccess is called when production fieldAccess is exited.

func (*BaseExprListener) ExitInnerExpr

func (s *BaseExprListener) ExitInnerExpr(ctx *InnerExprContext)

ExitInnerExpr is called when production innerExpr is exited.

func (*BaseExprListener) ExitInnerExprList

func (s *BaseExprListener) ExitInnerExprList(ctx *InnerExprListContext)

ExitInnerExprList is called when production innerExprList is exited.

func (*BaseExprListener) ExitRoot

func (s *BaseExprListener) ExitRoot(ctx *RootContext)

ExitRoot is called when production root is exited.

func (*BaseExprListener) ExitValue

func (s *BaseExprListener) ExitValue(ctx *ValueContext)

ExitValue is called when production value is exited.

func (*BaseExprListener) VisitErrorNode

func (s *BaseExprListener) VisitErrorNode(node antlr.ErrorNode)

VisitErrorNode is called when an error node is visited.

func (*BaseExprListener) VisitTerminal

func (s *BaseExprListener) VisitTerminal(node antlr.TerminalNode)

VisitTerminal is called when a terminal node is visited.

type ErrorListener

type ErrorListener struct {
	*antlr.DefaultErrorListener
	Error error
	Data  string
}

ErrorListener implements a custom ANTLR error listener that records syntax errors.

func (*ErrorListener) SyntaxError

func (l *ErrorListener) SyntaxError(_ antlr.Recognizer, _ any, line, column int, msg string, e antlr.RecognitionException)

SyntaxError is called by ANTLR when a syntax error occurs.

type ExprContext

type ExprContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyExprContext

func NewEmptyExprContext() *ExprContext

func NewExprContext

func NewExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprContext

func (*ExprContext) EnterRule

func (s *ExprContext) EnterRule(listener antlr.ParseTreeListener)

func (*ExprContext) ExitRule

func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener)

func (*ExprContext) GetParser

func (s *ExprContext) GetParser() antlr.Parser

func (*ExprContext) GetRuleContext

func (s *ExprContext) GetRuleContext() antlr.RuleContext

func (*ExprContext) IDENT

func (s *ExprContext) IDENT() antlr.TerminalNode

func (*ExprContext) InnerExprList

func (s *ExprContext) InnerExprList() IInnerExprListContext

func (*ExprContext) IsExprContext

func (*ExprContext) IsExprContext()

func (*ExprContext) ToStringTree

func (s *ExprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ExprLexer

type ExprLexer struct {
	*antlr.BaseLexer
	// contains filtered or unexported fields
}

func NewExprLexer

func NewExprLexer(input antlr.CharStream) *ExprLexer

NewExprLexer produces a new lexer instance for the optional input antlr.CharStream.

type ExprListener

type ExprListener interface {
	antlr.ParseTreeListener

	// EnterRoot is called when entering the root production.
	EnterRoot(c *RootContext)

	// EnterExpr is called when entering the expr production.
	EnterExpr(c *ExprContext)

	// EnterInnerExprList is called when entering the innerExprList production.
	EnterInnerExprList(c *InnerExprListContext)

	// EnterInnerExpr is called when entering the innerExpr production.
	EnterInnerExpr(c *InnerExprContext)

	// EnterFieldAccess is called when entering the fieldAccess production.
	EnterFieldAccess(c *FieldAccessContext)

	// EnterValue is called when entering the value production.
	EnterValue(c *ValueContext)

	// ExitRoot is called when exiting the root production.
	ExitRoot(c *RootContext)

	// ExitExpr is called when exiting the expr production.
	ExitExpr(c *ExprContext)

	// ExitInnerExprList is called when exiting the innerExprList production.
	ExitInnerExprList(c *InnerExprListContext)

	// ExitInnerExpr is called when exiting the innerExpr production.
	ExitInnerExpr(c *InnerExprContext)

	// ExitFieldAccess is called when exiting the fieldAccess production.
	ExitFieldAccess(c *FieldAccessContext)

	// ExitValue is called when exiting the value production.
	ExitValue(c *ValueContext)
}

ExprListener is a complete listener for a parse tree produced by ExprParser.

type ExprParser

type ExprParser struct {
	*antlr.BaseParser
}

func NewExprParser

func NewExprParser(input antlr.TokenStream) *ExprParser

NewExprParser produces a new parser instance for the optional input antlr.TokenStream.

func (*ExprParser) Expr

func (p *ExprParser) Expr() (localctx IExprContext)

func (*ExprParser) FieldAccess

func (p *ExprParser) FieldAccess() (localctx IFieldAccessContext)

func (*ExprParser) InnerExpr

func (p *ExprParser) InnerExpr() (localctx IInnerExprContext)

func (*ExprParser) InnerExprList

func (p *ExprParser) InnerExprList() (localctx IInnerExprListContext)

func (*ExprParser) Root

func (p *ExprParser) Root() (localctx IRootContext)

func (*ExprParser) Value

func (p *ExprParser) Value() (localctx IValueContext)

type FieldAccessContext

type FieldAccessContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyFieldAccessContext

func NewEmptyFieldAccessContext() *FieldAccessContext

func NewFieldAccessContext

func NewFieldAccessContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FieldAccessContext

func (*FieldAccessContext) AllIDENT

func (s *FieldAccessContext) AllIDENT() []antlr.TerminalNode

func (*FieldAccessContext) AllINTEGER

func (s *FieldAccessContext) AllINTEGER() []antlr.TerminalNode

func (*FieldAccessContext) EnterRule

func (s *FieldAccessContext) EnterRule(listener antlr.ParseTreeListener)

func (*FieldAccessContext) ExitRule

func (s *FieldAccessContext) ExitRule(listener antlr.ParseTreeListener)

func (*FieldAccessContext) GetParser

func (s *FieldAccessContext) GetParser() antlr.Parser

func (*FieldAccessContext) GetRuleContext

func (s *FieldAccessContext) GetRuleContext() antlr.RuleContext

func (*FieldAccessContext) IDENT

func (*FieldAccessContext) INTEGER

func (s *FieldAccessContext) INTEGER(i int) antlr.TerminalNode

func (*FieldAccessContext) IsFieldAccessContext

func (*FieldAccessContext) IsFieldAccessContext()

func (*FieldAccessContext) ToStringTree

func (s *FieldAccessContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type IExprContext

type IExprContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	IDENT() antlr.TerminalNode
	InnerExprList() IInnerExprListContext

	// IsExprContext differentiates from other interfaces.
	IsExprContext()
}

IExprContext is an interface to support dynamic dispatch.

type IFieldAccessContext

type IFieldAccessContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	AllIDENT() []antlr.TerminalNode
	IDENT(i int) antlr.TerminalNode
	AllINTEGER() []antlr.TerminalNode
	INTEGER(i int) antlr.TerminalNode

	// IsFieldAccessContext differentiates from other interfaces.
	IsFieldAccessContext()
}

IFieldAccessContext is an interface to support dynamic dispatch.

type IInnerExprContext

type IInnerExprContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	FieldAccess() IFieldAccessContext
	Value() IValueContext

	// IsInnerExprContext differentiates from other interfaces.
	IsInnerExprContext()
}

IInnerExprContext is an interface to support dynamic dispatch.

type IInnerExprListContext

type IInnerExprListContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	AllInnerExpr() []IInnerExprContext
	InnerExpr(i int) IInnerExprContext

	// IsInnerExprListContext differentiates from other interfaces.
	IsInnerExprListContext()
}

IInnerExprListContext is an interface to support dynamic dispatch.

type IRootContext

type IRootContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	Expr() IExprContext
	EOF() antlr.TerminalNode

	// IsRootContext differentiates from other interfaces.
	IsRootContext()
}

IRootContext is an interface to support dynamic dispatch.

type IValueContext

type IValueContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// Getter signatures
	IDENT() antlr.TerminalNode
	STRING() antlr.TerminalNode
	INTEGER() antlr.TerminalNode
	FLOAT() antlr.TerminalNode
	Expr() IExprContext

	// IsValueContext differentiates from other interfaces.
	IsValueContext()
}

IValueContext is an interface to support dynamic dispatch.

type InnerExprContext

type InnerExprContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyInnerExprContext

func NewEmptyInnerExprContext() *InnerExprContext

func NewInnerExprContext

func NewInnerExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InnerExprContext

func (*InnerExprContext) EnterRule

func (s *InnerExprContext) EnterRule(listener antlr.ParseTreeListener)

func (*InnerExprContext) ExitRule

func (s *InnerExprContext) ExitRule(listener antlr.ParseTreeListener)

func (*InnerExprContext) FieldAccess

func (s *InnerExprContext) FieldAccess() IFieldAccessContext

func (*InnerExprContext) GetParser

func (s *InnerExprContext) GetParser() antlr.Parser

func (*InnerExprContext) GetRuleContext

func (s *InnerExprContext) GetRuleContext() antlr.RuleContext

func (*InnerExprContext) IsInnerExprContext

func (*InnerExprContext) IsInnerExprContext()

func (*InnerExprContext) ToStringTree

func (s *InnerExprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

func (*InnerExprContext) Value

func (s *InnerExprContext) Value() IValueContext

type InnerExprListContext

type InnerExprListContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyInnerExprListContext

func NewEmptyInnerExprListContext() *InnerExprListContext

func NewInnerExprListContext

func NewInnerExprListContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *InnerExprListContext

func (*InnerExprListContext) AllInnerExpr

func (s *InnerExprListContext) AllInnerExpr() []IInnerExprContext

func (*InnerExprListContext) EnterRule

func (s *InnerExprListContext) EnterRule(listener antlr.ParseTreeListener)

func (*InnerExprListContext) ExitRule

func (s *InnerExprListContext) ExitRule(listener antlr.ParseTreeListener)

func (*InnerExprListContext) GetParser

func (s *InnerExprListContext) GetParser() antlr.Parser

func (*InnerExprListContext) GetRuleContext

func (s *InnerExprListContext) GetRuleContext() antlr.RuleContext

func (*InnerExprListContext) InnerExpr

func (s *InnerExprListContext) InnerExpr(i int) IInnerExprContext

func (*InnerExprListContext) IsInnerExprListContext

func (*InnerExprListContext) IsInnerExprListContext()

func (*InnerExprListContext) ToStringTree

func (s *InnerExprListContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ParseTreeListener

type ParseTreeListener struct {
	BaseExprListener
	Result map[string]string
}

ParseTreeListener walks the parse tree and builds the key-value map.

func (*ParseTreeListener) ExitRoot

func (l *ParseTreeListener) ExitRoot(ctx *RootContext)

ExitRoot is called when exiting the root node of the parse tree. It starts recursive parsing of the main expression.

type RootContext

type RootContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyRootContext

func NewEmptyRootContext() *RootContext

func NewRootContext

func NewRootContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *RootContext

func (*RootContext) EOF

func (s *RootContext) EOF() antlr.TerminalNode

func (*RootContext) EnterRule

func (s *RootContext) EnterRule(listener antlr.ParseTreeListener)

func (*RootContext) ExitRule

func (s *RootContext) ExitRule(listener antlr.ParseTreeListener)

func (*RootContext) Expr

func (s *RootContext) Expr() IExprContext

func (*RootContext) GetParser

func (s *RootContext) GetParser() antlr.Parser

func (*RootContext) GetRuleContext

func (s *RootContext) GetRuleContext() antlr.RuleContext

func (*RootContext) IsRootContext

func (*RootContext) IsRootContext()

func (*RootContext) ToStringTree

func (s *RootContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ValueContext

type ValueContext struct {
	antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyValueContext

func NewEmptyValueContext() *ValueContext

func NewValueContext

func NewValueContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ValueContext

func (*ValueContext) EnterRule

func (s *ValueContext) EnterRule(listener antlr.ParseTreeListener)

func (*ValueContext) ExitRule

func (s *ValueContext) ExitRule(listener antlr.ParseTreeListener)

func (*ValueContext) Expr

func (s *ValueContext) Expr() IExprContext

func (*ValueContext) FLOAT

func (s *ValueContext) FLOAT() antlr.TerminalNode

func (*ValueContext) GetParser

func (s *ValueContext) GetParser() antlr.Parser

func (*ValueContext) GetRuleContext

func (s *ValueContext) GetRuleContext() antlr.RuleContext

func (*ValueContext) IDENT

func (s *ValueContext) IDENT() antlr.TerminalNode

func (*ValueContext) INTEGER

func (s *ValueContext) INTEGER() antlr.TerminalNode

func (*ValueContext) IsValueContext

func (*ValueContext) IsValueContext()

func (*ValueContext) STRING

func (s *ValueContext) STRING() antlr.TerminalNode

func (*ValueContext) ToStringTree

func (s *ValueContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL