tinyc

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

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

Go to latest
Published: Jan 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example
package main

import (
	"bramp.net/antlr4/tinyc"

	"fmt"
	"github.com/antlr/antlr4/runtime/Go/antlr"
)

type exampleListener struct {
	*tinyc.BasetinycListener
}

func (l *exampleListener) EnterEveryRule(ctx antlr.ParserRuleContext) {
	fmt.Println(ctx.GetText())
}
func main() {
	// Setup the input
	is := antlr.NewInputStream("...some text to parse...")

	// Create the Lexer
	lexer := tinyc.NewtinycLexer(is)
	stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)

	// Create the Parser
	p := tinyc.NewtinycParser(stream)
	p.BuildParseTrees = true
	p.AddErrorListener(antlr.NewDiagnosticErrorListener(true))

	// Finally walk the tree
	tree := p.Program()
	antlr.ParseTreeWalkerDefault.Walk(&exampleListener{}, tree)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewtinycLexer

func NewtinycLexer(input antlr.CharStream) *tinycLexer

func NewtinycParser

func NewtinycParser(input antlr.TokenStream) *tinycParser

Types

type BasetinycListener

type BasetinycListener struct{}

BasetinycListener is a complete listener for a parse tree produced by tinycParser.

func (*BasetinycListener) EnterEveryRule

func (s *BasetinycListener) EnterEveryRule(ctx antlr.ParserRuleContext)

EnterEveryRule is called when any rule is entered.

func (*BasetinycListener) EnterExpr

func (s *BasetinycListener) EnterExpr(ctx *ExprContext)

EnterExpr is called when production expr is entered.

func (*BasetinycListener) EnterId

func (s *BasetinycListener) EnterId(ctx *IdContext)

EnterId is called when production id is entered.

func (*BasetinycListener) EnterInteger

func (s *BasetinycListener) EnterInteger(ctx *IntegerContext)

EnterInteger is called when production integer is entered.

func (*BasetinycListener) EnterParen_expr

func (s *BasetinycListener) EnterParen_expr(ctx *Paren_exprContext)

EnterParen_expr is called when production paren_expr is entered.

func (*BasetinycListener) EnterProgram

func (s *BasetinycListener) EnterProgram(ctx *ProgramContext)

EnterProgram is called when production program is entered.

func (*BasetinycListener) EnterStatement

func (s *BasetinycListener) EnterStatement(ctx *StatementContext)

EnterStatement is called when production statement is entered.

func (*BasetinycListener) EnterSum

func (s *BasetinycListener) EnterSum(ctx *SumContext)

EnterSum is called when production sum is entered.

func (*BasetinycListener) EnterTerm

func (s *BasetinycListener) EnterTerm(ctx *TermContext)

EnterTerm is called when production term is entered.

func (*BasetinycListener) EnterTest

func (s *BasetinycListener) EnterTest(ctx *TestContext)

EnterTest is called when production test is entered.

func (*BasetinycListener) ExitEveryRule

func (s *BasetinycListener) ExitEveryRule(ctx antlr.ParserRuleContext)

ExitEveryRule is called when any rule is exited.

func (*BasetinycListener) ExitExpr

func (s *BasetinycListener) ExitExpr(ctx *ExprContext)

ExitExpr is called when production expr is exited.

func (*BasetinycListener) ExitId

func (s *BasetinycListener) ExitId(ctx *IdContext)

ExitId is called when production id is exited.

func (*BasetinycListener) ExitInteger

func (s *BasetinycListener) ExitInteger(ctx *IntegerContext)

ExitInteger is called when production integer is exited.

func (*BasetinycListener) ExitParen_expr

func (s *BasetinycListener) ExitParen_expr(ctx *Paren_exprContext)

ExitParen_expr is called when production paren_expr is exited.

func (*BasetinycListener) ExitProgram

func (s *BasetinycListener) ExitProgram(ctx *ProgramContext)

ExitProgram is called when production program is exited.

func (*BasetinycListener) ExitStatement

func (s *BasetinycListener) ExitStatement(ctx *StatementContext)

ExitStatement is called when production statement is exited.

func (*BasetinycListener) ExitSum

func (s *BasetinycListener) ExitSum(ctx *SumContext)

ExitSum is called when production sum is exited.

func (*BasetinycListener) ExitTerm

func (s *BasetinycListener) ExitTerm(ctx *TermContext)

ExitTerm is called when production term is exited.

func (*BasetinycListener) ExitTest

func (s *BasetinycListener) ExitTest(ctx *TestContext)

ExitTest is called when production test is exited.

func (*BasetinycListener) VisitErrorNode

func (s *BasetinycListener) VisitErrorNode(node antlr.ErrorNode)

VisitErrorNode is called when an error node is visited.

func (*BasetinycListener) VisitTerminal

func (s *BasetinycListener) VisitTerminal(node antlr.TerminalNode)

VisitTerminal is called when a terminal node is visited.

type ExprContext

type ExprContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyExprContext

func NewEmptyExprContext() *ExprContext

func NewExprContext

func NewExprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprContext

func (*ExprContext) EnterRule

func (s *ExprContext) EnterRule(listener antlr.ParseTreeListener)

func (*ExprContext) ExitRule

func (s *ExprContext) ExitRule(listener antlr.ParseTreeListener)

func (*ExprContext) Expr

func (s *ExprContext) Expr() IExprContext

func (*ExprContext) GetParser

func (s *ExprContext) GetParser() antlr.Parser

func (*ExprContext) GetRuleContext

func (s *ExprContext) GetRuleContext() antlr.RuleContext

func (*ExprContext) Id

func (s *ExprContext) Id() IIdContext

func (*ExprContext) IsExprContext

func (*ExprContext) IsExprContext()

func (*ExprContext) Test

func (s *ExprContext) Test() ITestContext

func (*ExprContext) ToStringTree

func (s *ExprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type IExprContext

type IExprContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsExprContext differentiates from other interfaces.
	IsExprContext()
}

IExprContext is an interface to support dynamic dispatch.

type IIdContext

type IIdContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsIdContext differentiates from other interfaces.
	IsIdContext()
}

IIdContext is an interface to support dynamic dispatch.

type IIntegerContext

type IIntegerContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsIntegerContext differentiates from other interfaces.
	IsIntegerContext()
}

IIntegerContext is an interface to support dynamic dispatch.

type IParen_exprContext

type IParen_exprContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsParen_exprContext differentiates from other interfaces.
	IsParen_exprContext()
}

IParen_exprContext is an interface to support dynamic dispatch.

type IProgramContext

type IProgramContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsProgramContext differentiates from other interfaces.
	IsProgramContext()
}

IProgramContext is an interface to support dynamic dispatch.

type IStatementContext

type IStatementContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsStatementContext differentiates from other interfaces.
	IsStatementContext()
}

IStatementContext is an interface to support dynamic dispatch.

type ISumContext

type ISumContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsSumContext differentiates from other interfaces.
	IsSumContext()
}

ISumContext is an interface to support dynamic dispatch.

type ITermContext

type ITermContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsTermContext differentiates from other interfaces.
	IsTermContext()
}

ITermContext is an interface to support dynamic dispatch.

type ITestContext

type ITestContext interface {
	antlr.ParserRuleContext

	// GetParser returns the parser.
	GetParser() antlr.Parser

	// IsTestContext differentiates from other interfaces.
	IsTestContext()
}

ITestContext is an interface to support dynamic dispatch.

type IdContext

type IdContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyIdContext

func NewEmptyIdContext() *IdContext

func NewIdContext

func NewIdContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IdContext

func (*IdContext) EnterRule

func (s *IdContext) EnterRule(listener antlr.ParseTreeListener)

func (*IdContext) ExitRule

func (s *IdContext) ExitRule(listener antlr.ParseTreeListener)

func (*IdContext) GetParser

func (s *IdContext) GetParser() antlr.Parser

func (*IdContext) GetRuleContext

func (s *IdContext) GetRuleContext() antlr.RuleContext

func (*IdContext) IsIdContext

func (*IdContext) IsIdContext()

func (*IdContext) STRING

func (s *IdContext) STRING() antlr.TerminalNode

func (*IdContext) ToStringTree

func (s *IdContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type IntegerContext

type IntegerContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyIntegerContext

func NewEmptyIntegerContext() *IntegerContext

func NewIntegerContext

func NewIntegerContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *IntegerContext

func (*IntegerContext) EnterRule

func (s *IntegerContext) EnterRule(listener antlr.ParseTreeListener)

func (*IntegerContext) ExitRule

func (s *IntegerContext) ExitRule(listener antlr.ParseTreeListener)

func (*IntegerContext) GetParser

func (s *IntegerContext) GetParser() antlr.Parser

func (*IntegerContext) GetRuleContext

func (s *IntegerContext) GetRuleContext() antlr.RuleContext

func (*IntegerContext) INT

func (*IntegerContext) IsIntegerContext

func (*IntegerContext) IsIntegerContext()

func (*IntegerContext) ToStringTree

func (s *IntegerContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type Paren_exprContext

type Paren_exprContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyParen_exprContext

func NewEmptyParen_exprContext() *Paren_exprContext

func NewParen_exprContext

func NewParen_exprContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *Paren_exprContext

func (*Paren_exprContext) EnterRule

func (s *Paren_exprContext) EnterRule(listener antlr.ParseTreeListener)

func (*Paren_exprContext) ExitRule

func (s *Paren_exprContext) ExitRule(listener antlr.ParseTreeListener)

func (*Paren_exprContext) Expr

func (s *Paren_exprContext) Expr() IExprContext

func (*Paren_exprContext) GetParser

func (s *Paren_exprContext) GetParser() antlr.Parser

func (*Paren_exprContext) GetRuleContext

func (s *Paren_exprContext) GetRuleContext() antlr.RuleContext

func (*Paren_exprContext) IsParen_exprContext

func (*Paren_exprContext) IsParen_exprContext()

func (*Paren_exprContext) ToStringTree

func (s *Paren_exprContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type ProgramContext

type ProgramContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyProgramContext

func NewEmptyProgramContext() *ProgramContext

func NewProgramContext

func NewProgramContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProgramContext

func (*ProgramContext) AllStatement

func (s *ProgramContext) AllStatement() []IStatementContext

func (*ProgramContext) EnterRule

func (s *ProgramContext) EnterRule(listener antlr.ParseTreeListener)

func (*ProgramContext) ExitRule

func (s *ProgramContext) ExitRule(listener antlr.ParseTreeListener)

func (*ProgramContext) GetParser

func (s *ProgramContext) GetParser() antlr.Parser

func (*ProgramContext) GetRuleContext

func (s *ProgramContext) GetRuleContext() antlr.RuleContext

func (*ProgramContext) IsProgramContext

func (*ProgramContext) IsProgramContext()

func (*ProgramContext) Statement

func (s *ProgramContext) Statement(i int) IStatementContext

func (*ProgramContext) ToStringTree

func (s *ProgramContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type StatementContext

type StatementContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyStatementContext

func NewEmptyStatementContext() *StatementContext

func NewStatementContext

func NewStatementContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *StatementContext

func (*StatementContext) AllStatement

func (s *StatementContext) AllStatement() []IStatementContext

func (*StatementContext) EnterRule

func (s *StatementContext) EnterRule(listener antlr.ParseTreeListener)

func (*StatementContext) ExitRule

func (s *StatementContext) ExitRule(listener antlr.ParseTreeListener)

func (*StatementContext) Expr

func (s *StatementContext) Expr() IExprContext

func (*StatementContext) GetParser

func (s *StatementContext) GetParser() antlr.Parser

func (*StatementContext) GetRuleContext

func (s *StatementContext) GetRuleContext() antlr.RuleContext

func (*StatementContext) IsStatementContext

func (*StatementContext) IsStatementContext()

func (*StatementContext) Paren_expr

func (s *StatementContext) Paren_expr() IParen_exprContext

func (*StatementContext) Statement

func (s *StatementContext) Statement(i int) IStatementContext

func (*StatementContext) ToStringTree

func (s *StatementContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type SumContext

type SumContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptySumContext

func NewEmptySumContext() *SumContext

func NewSumContext

func NewSumContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SumContext

func (*SumContext) EnterRule

func (s *SumContext) EnterRule(listener antlr.ParseTreeListener)

func (*SumContext) ExitRule

func (s *SumContext) ExitRule(listener antlr.ParseTreeListener)

func (*SumContext) GetParser

func (s *SumContext) GetParser() antlr.Parser

func (*SumContext) GetRuleContext

func (s *SumContext) GetRuleContext() antlr.RuleContext

func (*SumContext) IsSumContext

func (*SumContext) IsSumContext()

func (*SumContext) Sum

func (s *SumContext) Sum() ISumContext

func (*SumContext) Term

func (s *SumContext) Term() ITermContext

func (*SumContext) ToStringTree

func (s *SumContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type TermContext

type TermContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyTermContext

func NewEmptyTermContext() *TermContext

func NewTermContext

func NewTermContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TermContext

func (*TermContext) EnterRule

func (s *TermContext) EnterRule(listener antlr.ParseTreeListener)

func (*TermContext) ExitRule

func (s *TermContext) ExitRule(listener antlr.ParseTreeListener)

func (*TermContext) GetParser

func (s *TermContext) GetParser() antlr.Parser

func (*TermContext) GetRuleContext

func (s *TermContext) GetRuleContext() antlr.RuleContext

func (*TermContext) Id

func (s *TermContext) Id() IIdContext

func (*TermContext) Integer

func (s *TermContext) Integer() IIntegerContext

func (*TermContext) IsTermContext

func (*TermContext) IsTermContext()

func (*TermContext) Paren_expr

func (s *TermContext) Paren_expr() IParen_exprContext

func (*TermContext) ToStringTree

func (s *TermContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

type TestContext

type TestContext struct {
	*antlr.BaseParserRuleContext
	// contains filtered or unexported fields
}

func NewEmptyTestContext

func NewEmptyTestContext() *TestContext

func NewTestContext

func NewTestContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *TestContext

func (*TestContext) AllSum

func (s *TestContext) AllSum() []ISumContext

func (*TestContext) EnterRule

func (s *TestContext) EnterRule(listener antlr.ParseTreeListener)

func (*TestContext) ExitRule

func (s *TestContext) ExitRule(listener antlr.ParseTreeListener)

func (*TestContext) GetParser

func (s *TestContext) GetParser() antlr.Parser

func (*TestContext) GetRuleContext

func (s *TestContext) GetRuleContext() antlr.RuleContext

func (*TestContext) IsTestContext

func (*TestContext) IsTestContext()

func (*TestContext) Sum

func (s *TestContext) Sum(i int) ISumContext

func (*TestContext) ToStringTree

func (s *TestContext) ToStringTree(ruleNames []string, recog antlr.Recognizer) string

Jump to

Keyboard shortcuts

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