cclParser

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxShownSourceLineLen is the maximum length of the source line
	// to be shown in output messages.
	MaxShownSourceLineLen = 64
)

Variables

This section is empty.

Functions

func ParseCCLSourceContent

func ParseCCLSourceContent(options *CCLParseOptions) (*cclValues.SourceCodeDefinition, error)

ParseCCLSourceContent takes a CCLParseOptions struct and parses the SourceContent field into a SourceCodeDefinition value. It uses the CCL lexer to tokenize the source content and then parses the tokens using the CCLParser. The function returns a pointer to a SourceCodeDefinition value and an error if any occurred during the parsing process.

func ParseCCLSourceFile

func ParseCCLSourceFile(options *CCLParseOptions) (*cclValues.SourceCodeDefinition, error)

ParseCCLSourceFile reads a CCL source file and parses it into a SourceCodeDefinition value. It uses the CCL lexer to tokenize the source content and then parses the tokens using the CCLParser. The function returns a pointer to a SourceCodeDefinition value and an error if any occurred during the parsing process.

Types

type CCLParseOptions

type CCLParseOptions struct {
	SourceFilePath string
	SourceContent  string
	CodeContext    *cclValues.CCLCodeContext
}

CCLParseOptions is a struct that contains the options for parsing a CCL source file.

type CCLParser

type CCLParser struct {
	// Options is the options for the parser.
	Options *CCLParseOptions
	// contains filtered or unexported fields
}

func (*CCLParser) ErrInvalidSyntax

func (p *CCLParser) ErrInvalidSyntax(hint string) *InvalidSyntaxError

ErrInvalidSyntax returns an invalid syntax error with an optional hint message (can be empty).

func (*CCLParser) FindTokenPattern

func (p *CCLParser) FindTokenPattern(tokens []cclLexer.CCLTokenType) bool

FindTokenPattern peeks in front of the current token to see if the provided patterns match the tokens from now on. Comments are ignored. Tokens which are -1 in the specified arguments, will make this function to accept any token.

func (*CCLParser) GetCurrent

func (p *CCLParser) GetCurrent() *cclLexer.CCLToken

GetCurrent returns the current token being parsed. Please note that this method is exported mostly for tests.

func (*CCLParser) IsAtEnd

func (p *CCLParser) IsAtEnd() bool

IsAtEnd checks if the parser has reached the end of the input. Please note that this method is exported mostly for tests.

func (*CCLParser) IsCurrentLiteralValue

func (p *CCLParser) IsCurrentLiteralValue() bool

IsCurrentValue checks if the current token is a literal value token.

func (*CCLParser) IsCurrentReservedLiteral added in v0.0.3

func (p *CCLParser) IsCurrentReservedLiteral() bool

IsCurrentReservedLiteral checks if the current token is a reserved literal.

func (*CCLParser) IsCurrentValueOrIdentifier

func (p *CCLParser) IsCurrentValueOrIdentifier() bool

IsCurrentValueOrIdentifier checks if the current token is a literal value token or an identifier.

func (*CCLParser) ParseAsCCL

func (p *CCLParser) ParseAsCCL() (*cclValues.SourceCodeDefinition, error)

func (*CCLParser) ParseAttributes

func (p *CCLParser) ParseAttributes() ([]*cclValues.AttributeUsageInfo, error)

ParseAttributes Keeps parsing all of the available attributes in the current position until it hits something other than attribute.

func (*CCLParser) ParseGlobalAttribute

func (p *CCLParser) ParseGlobalAttribute() (*cclValues.AttributeUsageInfo, error)

func (*CCLParser) ParseModelDefinition

func (p *CCLParser) ParseModelDefinition(currentNamespace string) (*cclValues.ModelDefinition, error)

ParseModelDefinition parses a model definition from the current position in the source code.

func (*CCLParser) ParseModelField

func (p *CCLParser) ParseModelField(currentNamespace string) (*cclValues.ModelFieldDefinition, error)

type ExpectedValueError

type ExpectedValueError struct {
	ParamName string

	SourcePosition *cclUtils.SourceCodePosition
}

func (*ExpectedValueError) Error

func (e *ExpectedValueError) Error() string

type InvalidAttributeUsageError

type InvalidAttributeUsageError struct {
	SourcePosition *cclUtils.SourceCodePosition
}

func (*InvalidAttributeUsageError) Error

type InvalidSyntaxError

type InvalidSyntaxError struct {
	Language    globalValues.LanguageType
	HintMessage string

	SourcePosition *cclUtils.SourceCodePosition
}

func (*InvalidSyntaxError) Error

func (e *InvalidSyntaxError) Error() string

type UndefinedIdentifierError

type UndefinedIdentifierError struct {
	TargetIdentifier string
	Language         globalValues.LanguageType

	SourcePosition *cclUtils.SourceCodePosition
}

func (*UndefinedIdentifierError) Error

func (e *UndefinedIdentifierError) Error() string

type UnexpectedEOFError

type UnexpectedEOFError struct {
	SourcePosition *cclUtils.SourceCodePosition
}

func (*UnexpectedEOFError) Error

func (e *UnexpectedEOFError) Error() string

type UnexpectedEndOfAttributeError

type UnexpectedEndOfAttributeError struct {
	SourcePosition *cclUtils.SourceCodePosition
}

func (*UnexpectedEndOfAttributeError) Error

type UnexpectedTokenAfterAssignmentError

type UnexpectedTokenAfterAssignmentError struct {
	ParamName  string
	TokenValue string

	SourcePosition *cclUtils.SourceCodePosition
}

func (*UnexpectedTokenAfterAssignmentError) Error

type UnexpectedTokenAfterParameterError

type UnexpectedTokenAfterParameterError struct {
	ParamName  string
	TokenValue string

	SourcePosition *cclUtils.SourceCodePosition
}

func (*UnexpectedTokenAfterParameterError) Error

type UnexpectedTokenError

type UnexpectedTokenError struct {
	Expected cclLexer.CCLTokenType
	Actual   cclLexer.CCLTokenType

	SourcePosition *cclUtils.SourceCodePosition
}

func (*UnexpectedTokenError) Error

func (e *UnexpectedTokenError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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