lex

package
v0.0.0-...-4aab756 Latest Latest
Warning

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

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

Documentation

Overview

Contains the lexical analysis package for the interpreter.

Index

Constants

View Source
const EOF = -1

Used to represent the end of the input

View Source
const MAX_DEPTH_DEFAULT = 1000

Maximum depth of the lexer, if reached, the lexer will stop processing

Variables

This section is empty.

Functions

func IsAlphaNumeric

func IsAlphaNumeric(r rune) bool

Returns true if the rune is a letter or a number

func IsAlphabet

func IsAlphabet(r rune) bool

Returns true if the rune is a letter

func IsNewLine

func IsNewLine(r rune) bool

Returns true if the rune is a new line character

func IsNumber

func IsNumber(r rune) bool

Returns true if the rune is a number

func IsWhitespace

func IsWhitespace(r rune) bool

Returns true if the rune is a whitespace character or a new line character

Types

type Command

type Command string

Represent different types of commands e.g add

const (
	CommandAdd     Command = "add"     // Add a new task
	CommandDepends Command = "depends" // Add a dependency
	CommandNext    Command = "next"    // Mark this task as the next task to be executed

)

type Lexer

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

A lexer is used to tokenize a string into a series of tokens

func NewLexer

func NewLexer(manager *manager.ErrorManager) *Lexer

Create a new lexer that will tokenize the given input

func (*Lexer) Reset

func (l *Lexer) Reset() *Lexer

func (*Lexer) SetInitialState

func (l *Lexer) SetInitialState(state StateFn)

Useful for parsing partial input

func (*Lexer) SetInput

func (l *Lexer) SetInput(input string) *Lexer

func (*Lexer) Tokenize

func (l *Lexer) Tokenize() ([]token.Token, []manager.ErrorTranspiler)

Tokenize the input string and return the tokens

type StateFn

type StateFn func(*Lexer) StateFn

A lexer is a function that processes the input and returns the next state

Jump to

Keyboard shortcuts

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