Documentation
¶
Index ¶
- Constants
- func ParseCCL(ctx *cclValues.CCLCodeContext, tokens []*cclLexer.CCLToken, ...) (*cclValues.SourceCodeDefinition, error)
- func ParseCCLSourceContent(options *CCLParseOptions) (*cclValues.SourceCodeDefinition, error)
- func ParseCCLSourceFile(options *CCLParseOptions) (*cclValues.SourceCodeDefinition, error)
- type CCLParseOptions
- type CCLParser
- func (p *CCLParser) ErrInvalidSyntax(hint string) *InvalidSyntaxError
- func (p *CCLParser) FindTokenPattern(tokens []cclLexer.CCLTokenType) bool
- func (p *CCLParser) GetCurrent() *cclLexer.CCLToken
- func (p *CCLParser) IsAtEnd() bool
- func (p *CCLParser) IsCurrentLiteralValue() bool
- func (p *CCLParser) IsCurrentReservedLiteral() bool
- func (p *CCLParser) IsCurrentValueOrIdentifier() bool
- func (p *CCLParser) ParseAsCCL() (*cclValues.SourceCodeDefinition, error)
- func (p *CCLParser) ParseAttributes() ([]*cclValues.AttributeUsageInfo, error)
- func (p *CCLParser) ParseGlobalAttribute() (*cclValues.AttributeUsageInfo, error)
- func (p *CCLParser) ParseModelDefinition(currentNamespace string) (*cclValues.ModelDefinition, error)
- func (p *CCLParser) ParseModelField(currentNamespace string) (*cclValues.ModelFieldDefinition, error)
- type ExpectedValueError
- type InvalidAttributeUsageError
- type InvalidSyntaxError
- type UndefinedIdentifierError
- type UnexpectedEOFError
- type UnexpectedEndOfAttributeError
- type UnexpectedTokenAfterAssignmentError
- type UnexpectedTokenAfterParameterError
- type UnexpectedTokenError
Constants ¶
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 ParseCCL ¶
func ParseCCL( ctx *cclValues.CCLCodeContext, tokens []*cclLexer.CCLToken, options *CCLParseOptions, ) (*cclValues.SourceCodeDefinition, error)
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 ¶
GetCurrent returns the current token being parsed. Please note that this method is exported mostly for tests.
func (*CCLParser) IsAtEnd ¶
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 ¶
IsCurrentValue checks if the current token is a literal value token.
func (*CCLParser) IsCurrentReservedLiteral ¶ added in v0.0.3
IsCurrentReservedLiteral checks if the current token is a reserved literal.
func (*CCLParser) IsCurrentValueOrIdentifier ¶
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 ¶
func (e *InvalidAttributeUsageError) Error() string
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 ¶
func (e *UnexpectedEndOfAttributeError) Error() string
type UnexpectedTokenAfterAssignmentError ¶
type UnexpectedTokenAfterAssignmentError struct {
ParamName string
TokenValue string
SourcePosition *cclUtils.SourceCodePosition
}
func (*UnexpectedTokenAfterAssignmentError) Error ¶
func (e *UnexpectedTokenAfterAssignmentError) Error() string
type UnexpectedTokenAfterParameterError ¶
type UnexpectedTokenAfterParameterError struct {
ParamName string
TokenValue string
SourcePosition *cclUtils.SourceCodePosition
}
func (*UnexpectedTokenAfterParameterError) Error ¶
func (e *UnexpectedTokenAfterParameterError) Error() string
type UnexpectedTokenError ¶
type UnexpectedTokenError struct {
Expected cclLexer.CCLTokenType
Actual cclLexer.CCLTokenType
SourcePosition *cclUtils.SourceCodePosition
}
func (*UnexpectedTokenError) Error ¶
func (e *UnexpectedTokenError) Error() string