token

package
v0.0.0-...-6f11ea9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LiteralBegin = literal_begin
	LiteralEnd   = literal_end
)
View Source
const (
	LOWEST = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	Filename string
	Offset   int
	Line     int
	Column   int
}

func (Position) String

func (pos Position) String() string

func (Position) To

func (pos Position) To(offset int) Position

To returns the Position(2) after a positive offset from the current position(1)

name = tstr

^  ^
|  |
1  2

where offset is the length of the token(s)

type PositionRange

type PositionRange struct {
	Start, End Position
}

func (*PositionRange) String

func (ps *PositionRange) String() string

type Token

type Token int
const (
	// Special Tokens
	ILLEGAL Token = iota
	EOF
	COMMENT // ;

	IDENT // person

	INT  // Unisigned integer or negative integer: -9 / 9
	UINT // Unsigned integer: 9
	NINT // Negative integer: -9

	FLOAT   // float; one of float16, float32, float64
	FLOAT16 // A number representable as an IEEE 754 half-precision float (major type 7, additional information 25).
	FLOAT32 // A number representable as an IEEE 754 single-precision float (major type 7, additional information 26).
	FLOAT64 // A number representable as an IEEE 754 double-precision float (major type 7, additional information 27).

	TSTR         // tstr
	TEXT         // text
	TEXT_LITERAL // "text"

	BYTES // bytes
	BSTR  // bstr

	BOOL  // bool
	TRUE  // true
	FALSE // false
	NIL   // nil
	NULL  // null
	ANY   // any

	MINUS  // -
	LPAREN // (
	LBRACK // [
	LBRACE // {

	RPAREN // )
	RBRACK // ]
	RBRACE // }

	COMMA  // ,
	PERIOD // .
	COLON  // :

	ASSIGN              // =
	ARROW_MAP           // =>
	OPTIONAL            // ?
	TYPE_CHOICE         // /
	GROUP_CHOICE        // //
	TYPE_CHOICE_ASSIGN  // /=
	GROUP_CHOICE_ASSIGN // /=
	AMPERSAND           // &
	HASH                // #

	LEFT_ANGLE_BRACKET  // <
	RIGHT_ANGLE_BRACKET // >

	INCLUSIVE_BOUND // ..
	EXCLUSIVE_BOUND // ...

	ZERO_OR_MORE // *
	ONE_OR_MORE  // +
	UNWRAP       // ~

	SIZE    // .size
	BITS    // .bits
	REGEXP  // .regexp
	CBOR    // .cbor
	CBORSEQ // .cborseq
	WITHIN  // .within
	AND     // .and

	LT      // .lt
	LE      // .le
	GT      // .gt
	GE      // .ge
	EQ      // .eq
	NE      // .ne
	DEFAULT // .default

	PLUS    // .plus
	CAT     // .cat
	DET     // .det
	ABNF    // .abnf
	ABNFB   // .abnfb
	FEATURE // .feature

	UNEXPECTED // Unexpected Token
	EOL        // End of Line

)

The list of tokens

func Lookup

func Lookup(str string) Token

Lookup returns whether or not a string is cddl token else returns an IDENT token

func (Token) IsControlOp

func (t Token) IsControlOp() bool

func (Token) IsLiteral

func (t Token) IsLiteral(literal string) bool

func (Token) IsNumeric

func (t Token) IsNumeric() bool

func (Token) Precedence

func (t Token) Precedence() int

Precedence returns the token's precedence used to built the ast in parsing

func (Token) String

func (t Token) String() string

type TokenPos

type TokenPos struct {
	Filename string
	Offset   int
}

Jump to

Keyboard shortcuts

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