Documentation
¶
Index ¶
- type CCLToken
- func (t *CCLToken) FormatValueAsString() string
- func (t *CCLToken) GetBuiltInDataTypeUsage(ctx *cclValues.CCLCodeContext) *cclValues.CCLTypeUsage
- func (t *CCLToken) GetComment() string
- func (t *CCLToken) GetCustomTypeUsage(ctx *cclValues.CCLCodeContext, currentNamespace string) *cclValues.CCLTypeUsage
- func (t *CCLToken) GetFloatLiteral() float64
- func (t *CCLToken) GetIdentifier() string
- func (t *CCLToken) GetIntLiteral() int
- func (t *CCLToken) GetLiteralTypeInfo(ctx *cclValues.CCLCodeContext) *cclValues.CCLTypeUsage
- func (t *CCLToken) GetLiteralValue() any
- func (t *CCLToken) GetReservedLiteral() string
- func (t *CCLToken) GetStringLiteral() string
- func (t *CCLToken) IsBuiltinDataType() bool
- func (t *CCLToken) IsIdentifier() bool
- func (t *CCLToken) IsReservedLiteral() bool
- func (t *CCLToken) IsTokenLiteralValue() bool
- func (t *CCLToken) String() string
- type CCLTokenType
- type UnexpectedCharacterError
- type UnexpectedEndOfAttributeError
- type UnexpectedEndOfStringLiteralError
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 (*CCLToken) FormatValueAsString ¶
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 ¶
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 ¶
GetFloatLiteral returns the float literal value of the token. If the token is not a float literal, it returns 0.
func (*CCLToken) GetIdentifier ¶
GetIdentifier returns the identifier value of the token. If the token is not an identifier, it returns an empty string.
func (*CCLToken) GetIntLiteral ¶
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 ¶
GetLiteralValue returns the literal value of the token.
func (*CCLToken) GetReservedLiteral ¶ added in v0.0.3
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 ¶
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 ¶
IsBuiltinDataType returns true if the token is a built-in data type. e.g. int, float, string, bool, etc.
func (*CCLToken) IsIdentifier ¶
IsIdentifier returns true if the token is an identifier.
func (*CCLToken) IsReservedLiteral ¶ added in v0.0.3
IsReservedLiteral returns true if the token is a reserved literal. e.g. true, false, null, nil, self, super, this
func (*CCLToken) IsTokenLiteralValue ¶
IsTokenValue returns true if the token is a value 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 ¶
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 ¶
UnexpectedEndOfAttributeError represents an error when an unexpected end of attribute is found.
func (*UnexpectedEndOfAttributeError) Error ¶
func (e *UnexpectedEndOfAttributeError) Error() string
Error returns the string representation of the unexpected end of attribute error.
type UnexpectedEndOfStringLiteralError ¶
UnexpectedEndOfStringLiteralError represents an error when an unexpected end of string literal is found.
func (*UnexpectedEndOfStringLiteralError) Error ¶
func (e *UnexpectedEndOfStringLiteralError) Error() string
Error returns the string representation of the unexpected end of string literal error.