lexer

package
v0.0.0-...-0fac830 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Namespace Token = iota
	// Use imports a package
	Use

	// Let creates a new variable
	Let
	// Const creates a new constant
	Const
	// Equal assigns a value to a variable
	Assign

	Increment
	Decrement

	// Nil is an uninitialized token
	Nil
	// StringLiteral is a string token: "
	DoubleStringLiteral
	// SingleStringLiteral is a single string token: '
	SingleStringLiteral

	// End marks the end of a block: semi-colon
	SemiColon

	// SingleLineComment is a single line comment: //
	SingleLineComment
	// MultiLineCommentStart is the start of a multi-line comment: /*
	MultiLineCommentStart
	// MultiLineCommentEnd is the end of a multi-line comment: */
	MultiLineCommentEnd

	// TemplateStart marks the start of an HTML block: <template>
	TemplateStart
	// TemplateEnd marks the end of an HTML block: </template>
	TemplateEnd
	Template

	// Export exports a variable
	Export Token = iota + 100
	// Use imports a package
	UseToken
	// Func creates a new function
	Func
	// FuncCall calls a function
	FuncCall
	// ParantesisStart is the start of a parantesis: (
	ParantesisStart
	// ParantesisEnd is the end of a parantesis: )
	ParantesisEnd
	// CurlyBraceStart is the start of a curly brace: {
	CurlyBraceStart
	// CurlyBraceEnd is the end of a curly brace: }
	CurlyBraceEnd
	// Return returns a value
	Return
	// Identifier is an identifier
	Identifier

	For = iota + 100
	While
	If
	Else
	Equal
	NotEqual

	And
	Or

	Addition = iota + 1000
	Subtraction
	Multiplication
	Division
	Modulo

	// Unknown is an unknown token
	Unknown = iota + 10000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

type Lexer struct {
	Tokens []LexerToken
	// contains filtered or unexported fields
}

func New

func New(entry string, files ...string) *Lexer

func (*Lexer) Parse

func (l *Lexer) Parse() error

func (*Lexer) Sum

func (l *Lexer) Sum() string

type LexerToken

type LexerToken struct {
	Type  Token  `json:"token"`
	Value string `json:"value"`
	Info  struct {
		File string `json:"file"`
		Line int    `json:"line"`
		Pos  int    `json:"pos"`
	}
}

type Token

type Token int

func (Token) String

func (t Token) String() string

Jump to

Keyboard shortcuts

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