Documentation
¶
Overview ¶
Package parser offers a CQL parser that produces an intermediate ELM like data structure for evaluation.
Index ¶
Constants ¶
const ( // SyntaxError is returned by the lexer when the CQL does not meet the grammar. SyntaxError = ErrorType("SyntaxError") // ValidationError is returned by the parser when the CQL meets the grammar, but does not meet // some other validation rules (like referencing a non-existent expression definition). ValidationError = ErrorType("ValidationError") // InternalError occurs when the parser errors in an unexpected way. This is not a user error, nor // a feature that we purposefully do not support. InternalError = ErrorType("InternalError") // UnsupportedError is return for CQL language features that are not yet supported. UnsupportedError = ErrorType("UnsupportedError") )
const ( // ErrorSeverityInfo is informational. ErrorSeverityInfo = ErrorSeverity("Info") // ErrorSeverityWarning is a medium severity error. ErrorSeverityWarning = ErrorSeverity("Warning") // ErrorSeverityError is a high severity error. ErrorSeverityError = ErrorSeverity("Error") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorSeverity ¶
type ErrorSeverity string
ErrorSeverity represents different ParsingError severity levels.
type LibraryErrors ¶
type LibraryErrors struct { LibKey result.LibKey Errors []*ParsingError }
LibraryErrors contains a list of CQL parsing errors that occurred within a single library.
func (*LibraryErrors) Append ¶
func (le *LibraryErrors) Append(e *ParsingError)
Append adds the given error to the list of ParsingErrors.
func (*LibraryErrors) Error ¶
func (le *LibraryErrors) Error() string
func (*LibraryErrors) Unwrap ¶
func (le *LibraryErrors) Unwrap() []error
Unwrap implements the Go standard errors package Unwrap() function. See https://pkg.go.dev/errors.
type ParameterErrors ¶
type ParameterErrors struct { DefKey result.DefKey Errors []*ParsingError }
ParameterErrors contains a list of CQL parsing errors that occurred parsing a single parameter.
func (*ParameterErrors) Append ¶
func (pe *ParameterErrors) Append(e *ParsingError)
Append adds the given error to the list of ParsingErrors.
func (*ParameterErrors) Error ¶
func (pe *ParameterErrors) Error() string
func (*ParameterErrors) Unwrap ¶
func (pe *ParameterErrors) Unwrap() []error
Unwrap implements the Go standard errors package Unwrap() function. See https://pkg.go.dev/errors.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses CQL library and parameter strings into our intermediate ELM like data structure. The parser is responsible for all validation and implicit conversions.
func (*Parser) DataModel ¶
func (p *Parser) DataModel() *modelinfo.ModelInfos
DataModel returns the parsed model info.
func (*Parser) Libraries ¶
func (p *Parser) Libraries(ctx context.Context, cqlLibs []string, config Config) ([]*model.Library, error)
Libraries parses the CQL libraries into a list of model.Library or an error. Underlying parsing issues will return a ParsingErrors struct that users can check for and report to the user accordingly. TODO: b/332337287 - Investigate returning results as a map now that libraries are being sorted.
func (*Parser) Parameters ¶
func (p *Parser) Parameters(ctx context.Context, params map[result.DefKey]string, config Config) (map[result.DefKey]model.IExpression, error)
Parameters parses CQL literals into model.IExpressions. Each param should be a CQL literal, not an expression definition, valueset or other CQL construct.
type ParsingError ¶
type ParsingError struct { // High level message about the error. Message string // Line is the 1-based line number within source file where the error occurred. Line int // Column is the 0-based column number within source file where the error occurred. Column int // Type is the type of the error that occurred, such as SyntaxError or InternalError. Type ErrorType // Severity represents different severity levels. Severity ErrorSeverity // Cause is an optional, underlying error that caused the parsing error. Cause error }
ParsingError represents a specific parser error and its location.
func (*ParsingError) Error ¶
func (pe *ParsingError) Error() string
func (*ParsingError) Unwrap ¶
func (pe *ParsingError) Unwrap() error