r

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/r"

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

type exampleListener struct {
	*r.BaseRListener
}

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 := r.NewRLexer(is)
	stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)

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

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

Index

Examples

Constants

View Source
const (
	RLexerT__0    = 1
	RLexerT__1    = 2
	RLexerT__2    = 3
	RLexerT__3    = 4
	RLexerT__4    = 5
	RLexerT__5    = 6
	RLexerT__6    = 7
	RLexerT__7    = 8
	RLexerT__8    = 9
	RLexerT__9    = 10
	RLexerT__10   = 11
	RLexerT__11   = 12
	RLexerT__12   = 13
	RLexerT__13   = 14
	RLexerT__14   = 15
	RLexerT__15   = 16
	RLexerT__16   = 17
	RLexerT__17   = 18
	RLexerT__18   = 19
	RLexerT__19   = 20
	RLexerT__20   = 21
	RLexerT__21   = 22
	RLexerT__22   = 23
	RLexerT__23   = 24
	RLexerT__24   = 25
	RLexerT__25   = 26
	RLexerT__26   = 27
	RLexerT__27   = 28
	RLexerT__28   = 29
	RLexerT__29   = 30
	RLexerT__30   = 31
	RLexerT__31   = 32
	RLexerT__32   = 33
	RLexerT__33   = 34
	RLexerT__34   = 35
	RLexerT__35   = 36
	RLexerT__36   = 37
	RLexerT__37   = 38
	RLexerT__38   = 39
	RLexerT__39   = 40
	RLexerT__40   = 41
	RLexerT__41   = 42
	RLexerT__42   = 43
	RLexerT__43   = 44
	RLexerT__44   = 45
	RLexerT__45   = 46
	RLexerT__46   = 47
	RLexerT__47   = 48
	RLexerT__48   = 49
	RLexerT__49   = 50
	RLexerT__50   = 51
	RLexerT__51   = 52
	RLexerT__52   = 53
	RLexerT__53   = 54
	RLexerT__54   = 55
	RLexerHEX     = 56
	RLexerINT     = 57
	RLexerFLOAT   = 58
	RLexerCOMPLEX = 59
	RLexerSTRING  = 60
	RLexerID      = 61
	RLexerUSER_OP = 62
	RLexerNL      = 63
	RLexerWS      = 64
)

RLexer tokens.

View Source
const (
	RParserEOF     = antlr.TokenEOF
	RParserT__0    = 1
	RParserT__1    = 2
	RParserT__2    = 3
	RParserT__3    = 4
	RParserT__4    = 5
	RParserT__5    = 6
	RParserT__6    = 7
	RParserT__7    = 8
	RParserT__8    = 9
	RParserT__9    = 10
	RParserT__10   = 11
	RParserT__11   = 12
	RParserT__12   = 13
	RParserT__13   = 14
	RParserT__14   = 15
	RParserT__15   = 16
	RParserT__16   = 17
	RParserT__17   = 18
	RParserT__18   = 19
	RParserT__19   = 20
	RParserT__20   = 21
	RParserT__21   = 22
	RParserT__22   = 23
	RParserT__23   = 24
	RParserT__24   = 25
	RParserT__25   = 26
	RParserT__26   = 27
	RParserT__27   = 28
	RParserT__28   = 29
	RParserT__29   = 30
	RParserT__30   = 31
	RParserT__31   = 32
	RParserT__32   = 33
	RParserT__33   = 34
	RParserT__34   = 35
	RParserT__35   = 36
	RParserT__36   = 37
	RParserT__37   = 38
	RParserT__38   = 39
	RParserT__39   = 40
	RParserT__40   = 41
	RParserT__41   = 42
	RParserT__42   = 43
	RParserT__43   = 44
	RParserT__44   = 45
	RParserT__45   = 46
	RParserT__46   = 47
	RParserT__47   = 48
	RParserT__48   = 49
	RParserT__49   = 50
	RParserT__50   = 51
	RParserT__51   = 52
	RParserT__52   = 53
	RParserT__53   = 54
	RParserT__54   = 55
	RParserHEX     = 56
	RParserINT     = 57
	RParserFLOAT   = 58
	RParserCOMPLEX = 59
	RParserSTRING  = 60
	RParserID      = 61
	RParserUSER_OP = 62
	RParserNL      = 63
	RParserWS      = 64
)

RParser tokens.

View Source
const (
	RParserRULE_prog     = 0
	RParserRULE_expr     = 1
	RParserRULE_exprlist = 2
	RParserRULE_formlist = 3
	RParserRULE_form     = 4
	RParserRULE_sublist  = 5
	RParserRULE_sub      = 6
)

RParser rules.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseRListener

type BaseRListener struct{}

BaseRListener is a complete listener for a parse tree produced by RParser.

func (*BaseRListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BaseRListener) EnterExpr

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

EnterExpr is called when production expr is entered.

func (*BaseRListener) EnterExprlist

func (s *BaseRListener) EnterExprlist(ctx *ExprlistContext)

EnterExprlist is called when production exprlist is entered.

func (*BaseRListener) EnterForm

func (s *BaseRListener) EnterForm(ctx *FormContext)

EnterForm is called when production form is entered.

func (*BaseRListener) EnterFormlist

func (s *BaseRListener) EnterFormlist(ctx *FormlistContext)

EnterFormlist is called when production formlist is entered.

func (*BaseRListener) EnterProg

func (s *BaseRListener) EnterProg(ctx *ProgContext)

EnterProg is called when production prog is entered.

func (*BaseRListener) EnterSub

func (s *BaseRListener) EnterSub(ctx *SubContext)

EnterSub is called when production sub is entered.

func (*BaseRListener) EnterSublist

func (s *BaseRListener) EnterSublist(ctx *SublistContext)

EnterSublist is called when production sublist is entered.

func (*BaseRListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BaseRListener) ExitExpr

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

ExitExpr is called when production expr is exited.

func (*BaseRListener) ExitExprlist

func (s *BaseRListener) ExitExprlist(ctx *ExprlistContext)

ExitExprlist is called when production exprlist is exited.

func (*BaseRListener) ExitForm

func (s *BaseRListener) ExitForm(ctx *FormContext)

ExitForm is called when production form is exited.

func (*BaseRListener) ExitFormlist

func (s *BaseRListener) ExitFormlist(ctx *FormlistContext)

ExitFormlist is called when production formlist is exited.

func (*BaseRListener) ExitProg

func (s *BaseRListener) ExitProg(ctx *ProgContext)

ExitProg is called when production prog is exited.

func (*BaseRListener) ExitSub

func (s *BaseRListener) ExitSub(ctx *SubContext)

ExitSub is called when production sub is exited.

func (*BaseRListener) ExitSublist

func (s *BaseRListener) ExitSublist(ctx *SublistContext)

ExitSublist is called when production sublist is exited.

func (*BaseRListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BaseRListener) VisitTerminal

func (s *BaseRListener) 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) AllExpr

func (s *ExprContext) AllExpr() []IExprContext

func (*ExprContext) COMPLEX

func (s *ExprContext) COMPLEX() antlr.TerminalNode

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(i int) IExprContext

func (*ExprContext) Exprlist

func (s *ExprContext) Exprlist() IExprlistContext

func (*ExprContext) FLOAT

func (s *ExprContext) FLOAT() antlr.TerminalNode

func (*ExprContext) Formlist

func (s *ExprContext) Formlist() IFormlistContext

func (*ExprContext) GetParser

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

func (*ExprContext) GetRuleContext

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

func (*ExprContext) HEX

func (s *ExprContext) HEX() antlr.TerminalNode

func (*ExprContext) ID

func (s *ExprContext) ID() antlr.TerminalNode

func (*ExprContext) INT

func (s *ExprContext) INT() antlr.TerminalNode

func (*ExprContext) IsExprContext

func (*ExprContext) IsExprContext()

func (*ExprContext) STRING

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

func (*ExprContext) Sublist

func (s *ExprContext) Sublist() ISublistContext

func (*ExprContext) ToStringTree

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

func (*ExprContext) USER_OP

func (s *ExprContext) USER_OP() antlr.TerminalNode

type ExprlistContext

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

func NewEmptyExprlistContext

func NewEmptyExprlistContext() *ExprlistContext

func NewExprlistContext

func NewExprlistContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExprlistContext

func (*ExprlistContext) AllExpr

func (s *ExprlistContext) AllExpr() []IExprContext

func (*ExprlistContext) AllNL

func (s *ExprlistContext) AllNL() []antlr.TerminalNode

func (*ExprlistContext) EnterRule

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

func (*ExprlistContext) ExitRule

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

func (*ExprlistContext) Expr

func (s *ExprlistContext) Expr(i int) IExprContext

func (*ExprlistContext) GetParser

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

func (*ExprlistContext) GetRuleContext

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

func (*ExprlistContext) IsExprlistContext

func (*ExprlistContext) IsExprlistContext()

func (*ExprlistContext) NL

func (*ExprlistContext) ToStringTree

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

type FormContext

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

func NewEmptyFormContext

func NewEmptyFormContext() *FormContext

func NewFormContext

func NewFormContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FormContext

func (*FormContext) EnterRule

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

func (*FormContext) ExitRule

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

func (*FormContext) Expr

func (s *FormContext) Expr() IExprContext

func (*FormContext) GetParser

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

func (*FormContext) GetRuleContext

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

func (*FormContext) ID

func (s *FormContext) ID() antlr.TerminalNode

func (*FormContext) IsFormContext

func (*FormContext) IsFormContext()

func (*FormContext) ToStringTree

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

type FormlistContext

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

func NewEmptyFormlistContext

func NewEmptyFormlistContext() *FormlistContext

func NewFormlistContext

func NewFormlistContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *FormlistContext

func (*FormlistContext) AllForm

func (s *FormlistContext) AllForm() []IFormContext

func (*FormlistContext) EnterRule

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

func (*FormlistContext) ExitRule

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

func (*FormlistContext) Form

func (s *FormlistContext) Form(i int) IFormContext

func (*FormlistContext) GetParser

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

func (*FormlistContext) GetRuleContext

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

func (*FormlistContext) IsFormlistContext

func (*FormlistContext) IsFormlistContext()

func (*FormlistContext) ToStringTree

func (s *FormlistContext) 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 IExprlistContext

type IExprlistContext interface {
	antlr.ParserRuleContext

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

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

IExprlistContext is an interface to support dynamic dispatch.

type IFormContext

type IFormContext interface {
	antlr.ParserRuleContext

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

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

IFormContext is an interface to support dynamic dispatch.

type IFormlistContext

type IFormlistContext interface {
	antlr.ParserRuleContext

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

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

IFormlistContext is an interface to support dynamic dispatch.

type IProgContext

type IProgContext interface {
	antlr.ParserRuleContext

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

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

IProgContext is an interface to support dynamic dispatch.

type ISubContext

type ISubContext interface {
	antlr.ParserRuleContext

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

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

ISubContext is an interface to support dynamic dispatch.

type ISublistContext

type ISublistContext interface {
	antlr.ParserRuleContext

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

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

ISublistContext is an interface to support dynamic dispatch.

type ProgContext

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

func NewEmptyProgContext

func NewEmptyProgContext() *ProgContext

func NewProgContext

func NewProgContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ProgContext

func (*ProgContext) AllExpr

func (s *ProgContext) AllExpr() []IExprContext

func (*ProgContext) AllNL

func (s *ProgContext) AllNL() []antlr.TerminalNode

func (*ProgContext) EOF

func (s *ProgContext) EOF() antlr.TerminalNode

func (*ProgContext) EnterRule

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

func (*ProgContext) ExitRule

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

func (*ProgContext) Expr

func (s *ProgContext) Expr(i int) IExprContext

func (*ProgContext) GetParser

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

func (*ProgContext) GetRuleContext

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

func (*ProgContext) IsProgContext

func (*ProgContext) IsProgContext()

func (*ProgContext) NL

func (s *ProgContext) NL(i int) antlr.TerminalNode

func (*ProgContext) ToStringTree

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

type RLexer

type RLexer struct {
	*antlr.BaseLexer
	// contains filtered or unexported fields
}

func NewRLexer

func NewRLexer(input antlr.CharStream) *RLexer

type RListener

type RListener interface {
	antlr.ParseTreeListener

	// EnterProg is called when entering the prog production.
	EnterProg(c *ProgContext)

	// EnterExpr is called when entering the expr production.
	EnterExpr(c *ExprContext)

	// EnterExprlist is called when entering the exprlist production.
	EnterExprlist(c *ExprlistContext)

	// EnterFormlist is called when entering the formlist production.
	EnterFormlist(c *FormlistContext)

	// EnterForm is called when entering the form production.
	EnterForm(c *FormContext)

	// EnterSublist is called when entering the sublist production.
	EnterSublist(c *SublistContext)

	// EnterSub is called when entering the sub production.
	EnterSub(c *SubContext)

	// ExitProg is called when exiting the prog production.
	ExitProg(c *ProgContext)

	// ExitExpr is called when exiting the expr production.
	ExitExpr(c *ExprContext)

	// ExitExprlist is called when exiting the exprlist production.
	ExitExprlist(c *ExprlistContext)

	// ExitFormlist is called when exiting the formlist production.
	ExitFormlist(c *FormlistContext)

	// ExitForm is called when exiting the form production.
	ExitForm(c *FormContext)

	// ExitSublist is called when exiting the sublist production.
	ExitSublist(c *SublistContext)

	// ExitSub is called when exiting the sub production.
	ExitSub(c *SubContext)
}

RListener is a complete listener for a parse tree produced by RParser.

type RParser

type RParser struct {
	*antlr.BaseParser
}

func NewRParser

func NewRParser(input antlr.TokenStream) *RParser

func (*RParser) Expr

func (p *RParser) Expr() (localctx IExprContext)

func (*RParser) Expr_Sempred

func (p *RParser) Expr_Sempred(localctx antlr.RuleContext, predIndex int) bool

func (*RParser) Exprlist

func (p *RParser) Exprlist() (localctx IExprlistContext)

func (*RParser) Form

func (p *RParser) Form() (localctx IFormContext)

func (*RParser) Formlist

func (p *RParser) Formlist() (localctx IFormlistContext)

func (*RParser) Prog

func (p *RParser) Prog() (localctx IProgContext)

func (*RParser) Sempred

func (p *RParser) Sempred(localctx antlr.RuleContext, ruleIndex, predIndex int) bool

func (*RParser) Sub

func (p *RParser) Sub() (localctx ISubContext)

func (*RParser) Sublist

func (p *RParser) Sublist() (localctx ISublistContext)

type SubContext

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

func NewEmptySubContext

func NewEmptySubContext() *SubContext

func NewSubContext

func NewSubContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SubContext

func (*SubContext) EnterRule

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

func (*SubContext) ExitRule

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

func (*SubContext) Expr

func (s *SubContext) Expr() IExprContext

func (*SubContext) GetParser

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

func (*SubContext) GetRuleContext

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

func (*SubContext) ID

func (s *SubContext) ID() antlr.TerminalNode

func (*SubContext) IsSubContext

func (*SubContext) IsSubContext()

func (*SubContext) STRING

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

func (*SubContext) ToStringTree

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

type SublistContext

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

func NewEmptySublistContext

func NewEmptySublistContext() *SublistContext

func NewSublistContext

func NewSublistContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *SublistContext

func (*SublistContext) AllSub

func (s *SublistContext) AllSub() []ISubContext

func (*SublistContext) EnterRule

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

func (*SublistContext) ExitRule

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

func (*SublistContext) GetParser

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

func (*SublistContext) GetRuleContext

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

func (*SublistContext) IsSublistContext

func (*SublistContext) IsSublistContext()

func (*SublistContext) Sub

func (s *SublistContext) Sub(i int) ISubContext

func (*SublistContext) ToStringTree

func (s *SublistContext) 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