lexer

package
v0.0.0-...-7d08e18 Latest Latest
Warning

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

Go to latest
Published: May 29, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TabWidth = 4

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {
	Filename string

	Line, Char int
}

type Sourcefile

type Sourcefile struct {
	Path     string
	Name     string
	Contents []rune
	NewLines []int
	Tokens   []*Token
}

func NewSourcefile

func NewSourcefile(filepath string) (*Sourcefile, error)

func (*Sourcefile) GetLine

func (s *Sourcefile) GetLine(line int) string

func (*Sourcefile) MarkPos

func (s *Sourcefile) MarkPos(pos Position) string

func (*Sourcefile) MarkSpan

func (s *Sourcefile) MarkSpan(span Span) string

type Span

type Span struct {
	Filename string

	StartLine, StartChar int
	EndLine, EndChar     int
}

func NewSpan

func NewSpan(start, end Position) Span

func NewSpanFromTokens

func NewSpanFromTokens(start, end *Token) Span

func (Span) End

func (s Span) End() Position

func (Span) Start

func (s Span) Start() Position

type Token

type Token struct {
	Type     TokenType
	Contents string
	Where    Span
}

func Lex

func Lex(input *Sourcefile) []*Token

type TokenType

type TokenType int
const (
	Rune TokenType = iota
	Identifier
	Separator
	Operator
	Number
	Erroneous
	String
	Doccomment
)

func (TokenType) String

func (v TokenType) String() string

Jump to

Keyboard shortcuts

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