lexer

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lexer

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

func NewLexer

func NewLexer(entrada string) *Lexer

func (*Lexer) ProximoToken

func (l *Lexer) ProximoToken() *Token

type PosicaoToken added in v0.5.0

type PosicaoToken struct {
	Coluna int
	Linha  int
	Indice int
}

type Token

type Token struct {
	Tipo  TokenType
	Valor string

	Inicio *PosicaoToken
	Fim    *PosicaoToken
}

type TokenType

type TokenType int

TokenType representa os tipos de tokens suportados.

const (
	// Erro léxico
	TokenErro TokenType = iota
	// Fim do arquivo
	TokenFimDeArquivo
	// nova linha. Ex: \n ou \r\n
	TokenNovaLinha

	// Ex: variavel
	TokenIdentificador
	// Ex: 123
	TokenInteiro
	// Ex: 123.4
	TokenDecimal
	// Ex: "texto"
	TokenTexto

	TokenSe
	TokenSenao
	TokenEnquanto
	TokenPara
	TokenRetorne
	TokenPare
	TokenContinue

	TokenDe
	TokenImporte

	TokenVerdadeiro
	TokenFalso
	TokenNulo

	TokenVar
	TokenConst
	TokenFunc

	// =
	TokenIgual
	// +
	TokenMais
	// -
	TokenMenos
	// *
	TokenAsterisco
	// **
	TokenPotencia
	// /
	TokenDivisao
	// //
	TokenDivisaoInteira
	// %
	TokenModulo
	// <
	TokenMenorQue
	// <=
	TokenMenorOuIgual
	// ==
	TokenIgualIgual
	// !=
	TokenDiferente
	// >
	TokenMaiorQue
	// >=
	TokenMaiorOuIgual
	// (
	TokenAbreParenteses
	// )
	TokenFechaParenteses
	// ;
	TokenPontoEVirgula
	// ,
	TokenVirgula
	// {
	TokenAbreChaves
	// }
	TokenFechaChaves
	// [
	TokenAbreColchetes
	// ]
	TokenFechaColchetes
	// :
	TokenDoisPontos

	// +=
	TokenMaisIgual
	// -=
	TokenMenosIgual
	// *=
	TokenAsteriscoIgual
	// /=
	TokenBarraIgual

	// Operadores booleanos
	TokenBoolOu
	TokenBoolE
	TokenBoolNao

	// |
	TokenBitABitOu
	// ^
	TokenBitABitExOu
	// &
	TokenBitABitE
	// ~
	TokenBitABitNao

	// <<
	TokenDeslocEsquerda
	// >>
	TokenDeslocDireita

	// .
	TokenPonto

	// const instancia = nova MinhaClasse()
	TokenNova
	TokenClasse

	TokenAssegura
)

Tokens simples

Jump to

Keyboard shortcuts

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