lexer

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Group = "group"

Variables

This section is empty.

Functions

This section is empty.

Types

type BuiltinType

type BuiltinType int
const (
	Any     BuiltinType = iota // any
	Bool                       // bool
	Byte                       // byte
	Bytes                      // bytes
	String                     // string
	Int                        // int
	Int8                       // int8
	Int16                      // int16
	Int32                      // int32
	Int64                      // int64
	Uint                       // uint
	Uint8                      // uint8
	Uint16                     // uint16
	Uint32                     // uint32
	Uint64                     // uint64
	Float32                    // float32
	Float64                    // float64
	Map                        // map<K,V>
	Vector                     // vector<T>
	Array                      // array<T,Size>
)

func LookupType

func LookupType(ident string) (BuiltinType, bool)

func (BuiltinType) IsContainer added in v0.1.3

func (bt BuiltinType) IsContainer() bool

func (BuiltinType) IsFloat added in v0.1.3

func (bt BuiltinType) IsFloat() bool

func (BuiltinType) IsInt added in v0.1.2

func (bt BuiltinType) IsInt() bool

func (BuiltinType) IsNumber added in v0.1.3

func (bt BuiltinType) IsNumber() bool

func (BuiltinType) String

func (bt BuiltinType) String() string

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) AddLine

func (f *File) AddLine(offset int)

func (*File) AddLineInfo

func (f *File) AddLineInfo(offset int, filename string, line int)

func (*File) Base

func (f *File) Base() int

func (*File) Line

func (f *File) Line(p Pos) int

func (*File) LineCount

func (f *File) LineCount() int

func (*File) MergeLine

func (f *File) MergeLine(line int)

func (*File) Name

func (f *File) Name() string

func (*File) Offset

func (f *File) Offset(p Pos) int

func (*File) Pos

func (f *File) Pos(offset int) Pos

func (*File) Position

func (f *File) Position(p Pos) (pos Position)

func (*File) PositionFor

func (f *File) PositionFor(p Pos, adjusted bool) (pos Position)

func (*File) SetLines

func (f *File) SetLines(lines []int) bool

func (*File) SetLinesForContent

func (f *File) SetLinesForContent(content []byte)

func (*File) Size

func (f *File) Size() int

type FileSet

type FileSet struct {
	// contains filtered or unexported fields
}

func NewFileSet

func NewFileSet() *FileSet

func (*FileSet) AddFile

func (s *FileSet) AddFile(filename string, base, size int) *File

func (*FileSet) Base

func (s *FileSet) Base() int

func (*FileSet) File

func (s *FileSet) File(p Pos) (f *File)

func (*FileSet) Iterate

func (s *FileSet) Iterate(f func(*File) bool)

func (*FileSet) Position

func (s *FileSet) Position(p Pos) (pos Position)

func (*FileSet) PositionFor

func (s *FileSet) PositionFor(p Pos, adjusted bool) (pos Position)

type Pos

type Pos int
const NoPos Pos = 0

func (Pos) IsValid

func (p Pos) IsValid() bool

type Position

type Position struct {
	Filename string // filename, if any
	Offset   int    // byte offset, starting at 0
	Line     int    // line number, starting at 1
	Column   int    // column number, starting at 1 (character count per line)
}

A source position is represented by a Position value. A position is valid if Line > 0.

func (*Position) IsValid

func (pos *Position) IsValid() bool

IsValid reports whether the position is valid.

func (Position) String

func (pos Position) String() string

type Token

type Token int
const (
	ILLEGAL Token = iota
	EOF
	COMMENT

	IDENT  // main
	INT    // 12345
	FLOAT  // 123.45
	CHAR   // 'a'
	STRING // "abc"

	LPAREN    // (
	RPAREN    // )
	LBRACK    // [
	RBRACK    // ]
	LBRACE    // {
	RBRACE    // }
	LESS      // <
	GREATER   // >
	COMMA     // ,
	PERIOD    // .
	SEMICOLON // ;
	COLON     // :
	ASSIGN    // =
	AT        // @ @function(args)
	DOLLAR    // $ env variable
	SHARP     // #

	PACKAGE  // package
	IMPORT   // import
	ENUM     // enum
	CONST    // const
	STRUCT   // struct
	PROTOCOL // protocol
	SERVICE  // service
	REQUIRED // required
	OPTIONAL // optional
	EXTENDS  // extends

)

func Lookup

func Lookup(ident string) Token

func LookupOperator

func LookupOperator(lit string) (Token, bool)

func (Token) IsKeyword

func (tok Token) IsKeyword() bool

func (Token) IsLiteral

func (tok Token) IsLiteral() bool

func (Token) IsOperator

func (tok Token) IsOperator() bool

func (Token) String

func (tok Token) String() string

Jump to

Keyboard shortcuts

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