lexer

package
v0.0.0-...-3974014 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EOF     = "EOF"
	INVALID = "INVALID"

	// Keywords
	ALGORITHM  = "ALGORITMO"
	BLOCKBEGIN = "INÍCIO"
	BLOCKEND   = "FIM"
	VARSBEGIN  = "VARIÁVEIS"
	VARSEND    = "FIM-VARIÁVEIS"

	// Delimiters
	COMMA     = ","
	COLON     = ":"
	SEMICOLON = ";"
	LPAREN    = "("
	RPAREN    = ")"
	ATTR      = ":="

	// Literals
	INT    = "INTEIRO"
	STRING = "LITERAL"

	// Identifiers
	IDENT = "IDENT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

Lexer keeps the infos to do the lexical analysis.

func New

func New(input string) *Lexer

New creates a new Lexer.

func (*Lexer) GetNextTokenIf

func (l *Lexer) GetNextTokenIf(expectedType string) *Token

GetNextTokenIf get the next token if match a specific token type.

func (*Lexer) GetNextsTokensIf

func (l *Lexer) GetNextsTokensIf(expectedType1, expectedType2 string) (*Token, *Token)

GetNextsTokensIf get the nexts tokens if both match a specifics tokens types.

func (*Lexer) NextToken

func (l *Lexer) NextToken() *Token

NextToken returns the next token.

type Token

type Token struct {
	Type  string
	Value string
}

Jump to

Keyboard shortcuts

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