token

package
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Overview

range.go defines types to work with token positions in an AST these types are not used by Token itself, but are meant to be used by code-analysis tools

Index

Constants

This section is empty.

Variables

View Source
var KeywordMap = map[string]TokenType{}/* 130 elements not displayed */

maps all DDP-keywords to their token-type should not be modified!

Functions

This section is empty.

Types

type Position

type Position struct {
	Line   uint // 1-based Line index in the corresponding file
	Column uint // 1-based Column index in the corresponding file
}

a position in a ddp source-file Line and Column are 1-based and measured in utf8-characters not bytes

func NewEndPos

func NewEndPos(tok *Token) Position

Get the ending position of a Token

func NewStartPos

func NewStartPos(tok *Token) Position

Get the starting position of a Token

func (Position) IsBefore

func (p Position) IsBefore(pos Position) bool

wether p comes before pos

func (Position) IsBehind

func (p Position) IsBehind(pos Position) bool

wether p comes after pos

func (Position) String

func (p Position) String() string

type Range

type Range struct {
	Start Position // First Character position in the Range
	End   Position // Last Character position in the Range
}

a range in a ddp source-file

func NewRange

func NewRange(begin, end *Token) Range

creates a new range from the first character of begin to the last character of end

func (Range) String

func (r Range) String() string

type Token

type Token struct {
	Type      TokenType               // type of the token
	Literal   string                  // the literal from which it was scanned
	Indent    uint                    // how many levels it is indented
	Range     Range                   // the range the token spans
	AliasInfo *ddptypes.ParameterType // only present in ALIAS_PARAMETERs, holds type information, nil otherwise
}

a single ddp token

func (*Token) Column

func (t *Token) Column() uint

t.Range.Start.Column

func (*Token) Line

func (t *Token) Line() uint

t.Range.Start.Line

func (*Token) String

func (t *Token) String() string

func (*Token) StringVerbose

func (t *Token) StringVerbose() string

type TokenType

type TokenType int
const (
	ILLEGAL TokenType = iota
	EOF
	IDENTIFIER
	ALIAS_PARAMETER // <x> only found in function aliases
	COMMENT         // [...]
	SYMBOL          // any symbol not matched otherwise (?, !, ~, ...)

	INT    // 1 2
	FLOAT  // 2,2 3,4
	STRING // "hallo" "hi\n"
	CHAR   // 'H' 'ü'
	TRUE   // wahr
	FALSE  // falsch

	PLUS         // plus
	MINUS        // minus
	MAL          // mal
	DURCH        // durch
	MODULO       // modulo
	HOCH         // hoch
	WURZEL       // (n.) Wurzel (von)
	BETRAG       // Betrag (von)
	UND          // und
	ODER         // oder
	NICHT        // nicht
	GLEICH       // gleich
	UNGLEICH     // ungleich
	KLEINER      // kleiner (als)
	GRÖßER       // größer (als)(, oder) groesser (als)(, oder)
	ZWISCHEN     // zwischen <a> und <b>
	NEGATE       // -
	IST          // ist
	LINKS        // links
	RECHTS       // rechts
	GRÖßE        // Größe von
	LÄNGE        // Länge von
	KONTRA       // kontra
	VERKETTET    // verkettet mit
	ERHÖHE       // +=
	VERRINGERE   // -=
	VERVIELFACHE // *=
	TEILE        // /=
	VERSCHIEBE   // >>= <<=
	NEGIERE      // x = !x ~=
	LOGARITHMUS
	ZUR
	BASIS

	DER
	DIE
	VON
	ALS
	WENN
	DANN
	ABER
	SONST
	SOLANGE
	FÜR
	JEDE
	JEDEN
	JEDES
	BIS
	MIT
	SCHRITTGRÖßE
	ZAHL
	ZAHLEN
	KOMMAZAHL
	KOMMAZAHLEN
	WAHRHEITSWERT
	BUCHSTABE
	BUCHSTABEN
	TEXT
	LISTE
	LISTEN
	REFERENZ
	FUNKTION
	BINDE
	EIN
	GIB
	ZURÜCK
	NICHTS
	UM
	BIT
	NACH
	VERSCHOBEN
	LOGISCH
	MACHE
	WIEDERHOLE
	DEM
	PARAMETER
	DEN
	PARAMETERN
	VOM
	TYP
	GIBT
	EINE
	EINEN
	MACHT
	KANN
	SO
	BENUTZT
	WERDEN
	SPEICHERE
	DAS
	ERGEBNIS
	IN
	AN
	STELLE
	VONBIS
	DEFINIERT
	LEERE
	LEEREN
	AUS
	BESTEHT
	EINER
	EINEM
	VERLASSE
	COUNT_MAL
	ALIAS
	STEHT
	OEFFENTLICHE
	OEFFENTLICHEN
	WIR
	NENNEN
	KOMBINATION
	STANDARDWERT
	ERSTELLEN
	SIE
	FAHRE
	SCHLEIFE
	FORT
	IM
	BEREICH
	AB
	ZUM
	ELEMENT

	DOT    // .
	COMMA  // ,
	COLON  // :
	LPAREN // (
	RPAREN // )
)

func KeywordToTokenType

func KeywordToTokenType(keyword string) TokenType

func (TokenType) String

func (t TokenType) String() string

Jump to

Keyboard shortcuts

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