parser

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

func Ast2string

func Ast2string(ast BaseNode) ([]byte, error)

func IsKeyword

func IsKeyword(s string) bool

Types

type AcessoMembro added in v0.2.0

type AcessoMembro struct {
	Dono   BaseNode
	Membro BaseNode
}

type Anotacao

type Anotacao struct {
	Corpo string
}

type AsseguraNode added in v0.6.0

type AsseguraNode struct {
	Condicao BaseNode
	Mensagem BaseNode
}

type BaseNode

type BaseNode interface {
	// contains filtered or unexported methods
}

type Bloco

type Bloco struct {
	Declaracoes []BaseNode
}

type BlocoPara added in v0.3.0

type BlocoPara struct {
	Identificador string
	Iterador      BaseNode
	Corpo         *Bloco
}

type ChamadaFuncao

type ChamadaFuncao struct {
	Identificador BaseNode   // Nome da função a ser chamada
	Argumentos    []BaseNode // Argumentos da função
}

type ConstanteLiteral

type ConstanteLiteral struct {
	Valor string
}

type ContinueNode added in v0.2.0

type ContinueNode struct{}

type DecimalLiteral

type DecimalLiteral struct {
	Valor string
}

type DeclFuncao

type DeclFuncao struct {
	Nome       string                 // Nome da função
	Parametros []*DeclFuncaoParametro // Parâmetros da função
	Corpo      *Bloco                 // Corpo da função
}

type DeclFuncaoParametro

type DeclFuncaoParametro struct {
	Nome   string   // Nome do parametro
	Tipo   string   // Tipo do parametro (opcional)
	Padrao BaseNode // Valor padrão para o parametro (opcional)
}

type DeclVar

type DeclVar struct {
	Constante     bool     // Define se é constante
	Nome          string   // Nome da variável
	Tipo          string   // Tipo da variável (opcional)
	Inicializador BaseNode // Inicializador da variável (opcional)
}

type Enquanto added in v0.2.0

type Enquanto struct {
	Condicao BaseNode // Condição do while
	Corpo    *Bloco   // Corpo do while
}

type ExpressaoSe

type ExpressaoSe struct {
	Condicao    BaseNode // Condição do if
	Corpo       *Bloco   // Corpo do if
	Alternativa BaseNode // Corpo do else ou if else (opcional)
}

type Identificador

type Identificador struct {
	Nome string
}

type ImporteDe added in v0.4.0

type ImporteDe struct {
	Caminho *TextoLiteral
	Nomes   []string
}

FIXME: adicionar suporte a importação com *

type Indexacao added in v0.6.0

type Indexacao struct {
	Objeto    BaseNode
	Argumento BaseNode
}

type InteiroLiteral

type InteiroLiteral struct {
	Valor string
}

type ListaLiteral added in v0.3.0

type ListaLiteral struct {
	Elementos []BaseNode
}

type MapaLiteral added in v0.6.0

type MapaLiteral struct {
	Entradas [][]BaseNode
}

type NovaNode added in v0.6.0

type NovaNode struct {
	Objeto BaseNode
}

type OpBinaria

type OpBinaria struct {
	Esq      BaseNode // Expressão da esquerda
	Operador string   // Operador
	Dir      BaseNode // Expressão da direita
}

type OpUnaria

type OpUnaria struct {
	Operador  string   // Operador
	Expressao BaseNode // Expressão
}

type PareNode added in v0.2.0

type PareNode struct{}

type Parser

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

func NewParser

func NewParser(lex *lexer.Lexer) *Parser

func NewParserFromString

func NewParserFromString(code string) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (*Programa, error)

type Programa

type Programa struct {
	Declaracoes []BaseNode // Lista de declarações no programa
}

Programa representa o nó raiz do programa na AST.

type Reatribuicao

type Reatribuicao struct {
	Objeto    BaseNode
	Operador  string   // =, -=, +=, /=, //=, *= ou outros
	Expressao BaseNode // A expressao após o sinal de igualdade
}

Casos como `variavel += 1`, `variavel -= 1` e outros

type RetorneNode

type RetorneNode struct {
	Expressao BaseNode
}

type TextoLiteral

type TextoLiteral struct {
	Valor string
}

type TuplaLiteral added in v0.3.0

type TuplaLiteral struct {
	Elementos []BaseNode
}

Jump to

Keyboard shortcuts

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