cclLexer

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CCLToken

type CCLToken struct {
	// Type is the type of the token.
	Type CCLTokenType

	// Line is the line number where this token is found.
	Line int

	// Column is the column number where this token is found.
	Column int
	// contains filtered or unexported fields
}

CCLToken represents a token.

func Lex

func Lex(input string) ([]*CCLToken, error)

func (*CCLToken) FormatValueAsString

func (t *CCLToken) FormatValueAsString() string

FormatValueAsString returns the formatted value of the token as a string.

func (*CCLToken) GetBuiltInDataTypeUsage

func (t *CCLToken) GetBuiltInDataTypeUsage(ctx *cclValues.CCLCodeContext) *cclValues.CCLTypeUsage

GetBuiltInDataTypeUsage returns the built-in data type usage if the token is a built-in data type.

func (*CCLToken) GetComment

func (t *CCLToken) GetComment() string

GetComment returns the comment value of the token. If the token is not a comment, it returns an empty string.

func (*CCLToken) GetCustomTypeUsage

func (t *CCLToken) GetCustomTypeUsage(
	ctx *cclValues.CCLCodeContext,
	currentNamespace string,
) *cclValues.CCLTypeUsage

GetCustomTypeUsage returns the custom type usage if the token is an identifier representing a custom type, in the specified ccl code context and namespace.

func (*CCLToken) GetFloatLiteral

func (t *CCLToken) GetFloatLiteral() float64

GetFloatLiteral returns the float literal value of the token. If the token is not a float literal, it returns 0.

func (*CCLToken) GetIdentifier

func (t *CCLToken) GetIdentifier() string

GetIdentifier returns the identifier value of the token. If the token is not an identifier, it returns an empty string.

func (*CCLToken) GetIntLiteral

func (t *CCLToken) GetIntLiteral() int

GetIntLiteral returns the integer literal value of the token. If the token is not an integer literal, it returns 0.

func (*CCLToken) GetLiteralTypeInfo

func (t *CCLToken) GetLiteralTypeInfo(ctx *cclValues.CCLCodeContext) *cclValues.CCLTypeUsage

GetLiteralTypeInfo returns type info of the current literal token. a literal token is for example: string literal, int literal, float literal, bool literal, etc. so for a "hello"" token, it will return the type info for string type.

func (*CCLToken) GetLiteralValue

func (t *CCLToken) GetLiteralValue() any

GetLiteralValue returns the literal value of the token.

func (*CCLToken) GetReservedLiteral added in v0.0.3

func (t *CCLToken) GetReservedLiteral() string

GetReservedLiteral returns the reserved literal value of the token. If the token is not a reserved literal, it returns an empty string. Some examples of reserved literals are: true, false, null, nil, self, super, this.

func (*CCLToken) GetStringLiteral

func (t *CCLToken) GetStringLiteral() string

GetStringLiteral returns the string literal value of the token. If the token is not a string literal, it returns an empty string.

func (*CCLToken) IsBuiltinDataType

func (t *CCLToken) IsBuiltinDataType() bool

IsBuiltinDataType returns true if the token is a built-in data type. e.g. int, float, string, bool, etc.

func (*CCLToken) IsIdentifier

func (t *CCLToken) IsIdentifier() bool

IsIdentifier returns true if the token is an identifier.

func (*CCLToken) IsReservedLiteral added in v0.0.3

func (t *CCLToken) IsReservedLiteral() bool

IsReservedLiteral returns true if the token is a reserved literal. e.g. true, false, null, nil, self, super, this

func (*CCLToken) IsTokenLiteralValue

func (t *CCLToken) IsTokenLiteralValue() bool

IsTokenValue returns true if the token is a value token.

func (*CCLToken) String

func (t *CCLToken) String() string

String returns the string representation of the token.

type CCLTokenType

type CCLTokenType int

CCLTokenType represents the type of a token.

const (
	TokenTypeError            CCLTokenType = iota // error occurred
	TokenTypeEOF                                  // end of file
	TokenTypeComment                              // a comment
	TokenTypeHash                                 // #
	TokenTypeKeywordModel                         // model
	TokenTypeKeywordRequired                      // required
	TokenTypeKeywordPublic                        // public
	TokenTypeKeywordPrivate                       // private
	TokenTypeKeywordInternal                      // internal
	TokenTypeKeywordProtected                     // protected
	TokenTypeIdentifier                           // an identifier
	TokenTypeColon                                // :
	TokenTypeSemicolon                            // ;
	TokenTypeDataType                             // data type
	TokenTypeLeftBrace                            // {
	TokenTypeRightBrace                           // }
	TokenTypeLeftBracket                          // [
	TokenTypeRightBracket                         // ]
	TokenTypeStringLiteral                        // a string literal
	TokenTypeIntLiteral                           // an integer literal
	TokenTypeFloatLiteral                         // a float literal
	TokenTypeReservedLiteral                      // a reserved literal: true, false, null, nil, self, super, this, etc...
	TokenTypeWhitespace                           // a whitespace: ' ', '\t', '\n', '\r'
	TokenTypeLeftParenthesis                      // (
	TokenTypeRightParenthesis                     // )
	TokenTypeDot                                  // .
	TokenTypeComma                                // ,
	TokenTypePlus                                 // +
	TokenTypePlusPlus                             // ++
	TokenTypeMinus                                // -
	TokenTypeMinusMinus                           // --
	TokenTypeMultiply                             // *
	TokenTypePower                                // **
	TokenTypeDivide                               // /
	TokenTypeModulo                               // %
	TokenTypeAmpersand                            // &
	TokenTypePipe                                 // |
	TokenTypeAnd                                  // &&
	TokenTypeOr                                   // ||

	TokenTypeAssignment         // =
	TokenTypePlusAssignment     // +=
	TokenTypeMinusAssignment    // -=
	TokenTypeMultiplyAssignment // *=
	TokenTypeDivideAssignment   // /=

	TokenTypeNotEqualOperator // !=
)
const (
	TokenTypeReservedForFuture CCLTokenType = -1
)

func (CCLTokenType) String

func (t CCLTokenType) String() string

String returns the string representation of the token type.

func (CCLTokenType) ToString

func (t CCLTokenType) ToString() string

ToString returns the string representation of the token type.

type UnexpectedCharacterError

type UnexpectedCharacterError struct {
	Character  rune
	Line       int
	Column     int
	InnerError error
}

UnexpectedCharacterError represents an error when an unexpected character is found.

func (*UnexpectedCharacterError) Error

func (e *UnexpectedCharacterError) Error() string

Error returns the string representation of the unexpected character error.

type UnexpectedEndOfAttributeError

type UnexpectedEndOfAttributeError struct {
	Line   int
	Column int
}

UnexpectedEndOfAttributeError represents an error when an unexpected end of attribute is found.

func (*UnexpectedEndOfAttributeError) Error

Error returns the string representation of the unexpected end of attribute error.

type UnexpectedEndOfStringLiteralError

type UnexpectedEndOfStringLiteralError struct {
	Line   int
	Column int
}

UnexpectedEndOfStringLiteralError represents an error when an unexpected end of string literal is found.

func (*UnexpectedEndOfStringLiteralError) Error

Error returns the string representation of the unexpected end of string literal error.

Jump to

Keyboard shortcuts

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