metric

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

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

type exampleListener struct {
	*metric.BasemetricListener
}

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

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

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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewmetricLexer

func NewmetricLexer(input antlr.CharStream) *metricLexer

func NewmetricParser

func NewmetricParser(input antlr.TokenStream) *metricParser

Types

type BasemetricListener

type BasemetricListener struct{}

BasemetricListener is a complete listener for a parse tree produced by metricParser.

func (*BasemetricListener) EnterBaseunit

func (s *BasemetricListener) EnterBaseunit(ctx *BaseunitContext)

EnterBaseunit is called when production baseunit is entered.

func (*BasemetricListener) EnterDerivedunit

func (s *BasemetricListener) EnterDerivedunit(ctx *DerivedunitContext)

EnterDerivedunit is called when production derivedunit is entered.

func (*BasemetricListener) EnterEveryRule

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

EnterEveryRule is called when any rule is entered.

func (*BasemetricListener) EnterExponent

func (s *BasemetricListener) EnterExponent(ctx *ExponentContext)

EnterExponent is called when production exponent is entered.

func (*BasemetricListener) EnterMeasure

func (s *BasemetricListener) EnterMeasure(ctx *MeasureContext)

EnterMeasure is called when production measure is entered.

func (*BasemetricListener) EnterPrefix

func (s *BasemetricListener) EnterPrefix(ctx *PrefixContext)

EnterPrefix is called when production prefix is entered.

func (*BasemetricListener) EnterUnit

func (s *BasemetricListener) EnterUnit(ctx *UnitContext)

EnterUnit is called when production unit is entered.

func (*BasemetricListener) EnterUom

func (s *BasemetricListener) EnterUom(ctx *UomContext)

EnterUom is called when production uom is entered.

func (*BasemetricListener) ExitBaseunit

func (s *BasemetricListener) ExitBaseunit(ctx *BaseunitContext)

ExitBaseunit is called when production baseunit is exited.

func (*BasemetricListener) ExitDerivedunit

func (s *BasemetricListener) ExitDerivedunit(ctx *DerivedunitContext)

ExitDerivedunit is called when production derivedunit is exited.

func (*BasemetricListener) ExitEveryRule

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

ExitEveryRule is called when any rule is exited.

func (*BasemetricListener) ExitExponent

func (s *BasemetricListener) ExitExponent(ctx *ExponentContext)

ExitExponent is called when production exponent is exited.

func (*BasemetricListener) ExitMeasure

func (s *BasemetricListener) ExitMeasure(ctx *MeasureContext)

ExitMeasure is called when production measure is exited.

func (*BasemetricListener) ExitPrefix

func (s *BasemetricListener) ExitPrefix(ctx *PrefixContext)

ExitPrefix is called when production prefix is exited.

func (*BasemetricListener) ExitUnit

func (s *BasemetricListener) ExitUnit(ctx *UnitContext)

ExitUnit is called when production unit is exited.

func (*BasemetricListener) ExitUom

func (s *BasemetricListener) ExitUom(ctx *UomContext)

ExitUom is called when production uom is exited.

func (*BasemetricListener) VisitErrorNode

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

VisitErrorNode is called when an error node is visited.

func (*BasemetricListener) VisitTerminal

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

VisitTerminal is called when a terminal node is visited.

type BaseunitContext

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

func NewBaseunitContext

func NewBaseunitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *BaseunitContext

func NewEmptyBaseunitContext

func NewEmptyBaseunitContext() *BaseunitContext

func (*BaseunitContext) EnterRule

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

func (*BaseunitContext) ExitRule

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

func (*BaseunitContext) GetParser

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

func (*BaseunitContext) GetRuleContext

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

func (*BaseunitContext) IsBaseunitContext

func (*BaseunitContext) IsBaseunitContext()

func (*BaseunitContext) ToStringTree

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

type DerivedunitContext

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

func NewDerivedunitContext

func NewDerivedunitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *DerivedunitContext

func NewEmptyDerivedunitContext

func NewEmptyDerivedunitContext() *DerivedunitContext

func (*DerivedunitContext) EnterRule

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

func (*DerivedunitContext) ExitRule

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

func (*DerivedunitContext) GetParser

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

func (*DerivedunitContext) GetRuleContext

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

func (*DerivedunitContext) IsDerivedunitContext

func (*DerivedunitContext) IsDerivedunitContext()

func (*DerivedunitContext) ToStringTree

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

type ExponentContext

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

func NewEmptyExponentContext

func NewEmptyExponentContext() *ExponentContext

func NewExponentContext

func NewExponentContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *ExponentContext

func (*ExponentContext) EnterRule

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

func (*ExponentContext) ExitRule

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

func (*ExponentContext) GetParser

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

func (*ExponentContext) GetRuleContext

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

func (*ExponentContext) INTE

func (*ExponentContext) IsExponentContext

func (*ExponentContext) IsExponentContext()

func (*ExponentContext) ToStringTree

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

type IBaseunitContext

type IBaseunitContext interface {
	antlr.ParserRuleContext

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

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

IBaseunitContext is an interface to support dynamic dispatch.

type IDerivedunitContext

type IDerivedunitContext interface {
	antlr.ParserRuleContext

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

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

IDerivedunitContext is an interface to support dynamic dispatch.

type IExponentContext

type IExponentContext interface {
	antlr.ParserRuleContext

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

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

IExponentContext is an interface to support dynamic dispatch.

type IMeasureContext

type IMeasureContext interface {
	antlr.ParserRuleContext

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

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

IMeasureContext is an interface to support dynamic dispatch.

type IPrefixContext

type IPrefixContext interface {
	antlr.ParserRuleContext

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

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

IPrefixContext is an interface to support dynamic dispatch.

type IUnitContext

type IUnitContext interface {
	antlr.ParserRuleContext

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

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

IUnitContext is an interface to support dynamic dispatch.

type IUomContext

type IUomContext interface {
	antlr.ParserRuleContext

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

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

IUomContext is an interface to support dynamic dispatch.

type MeasureContext

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

func NewEmptyMeasureContext

func NewEmptyMeasureContext() *MeasureContext

func NewMeasureContext

func NewMeasureContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *MeasureContext

func (*MeasureContext) EnterRule

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

func (*MeasureContext) ExitRule

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

func (*MeasureContext) Exponent

func (s *MeasureContext) Exponent() IExponentContext

func (*MeasureContext) GetParser

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

func (*MeasureContext) GetRuleContext

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

func (*MeasureContext) IsMeasureContext

func (*MeasureContext) IsMeasureContext()

func (*MeasureContext) Prefix

func (s *MeasureContext) Prefix() IPrefixContext

func (*MeasureContext) ToStringTree

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

func (*MeasureContext) Unit

func (s *MeasureContext) Unit() IUnitContext

type PrefixContext

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

func NewEmptyPrefixContext

func NewEmptyPrefixContext() *PrefixContext

func NewPrefixContext

func NewPrefixContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *PrefixContext

func (*PrefixContext) EnterRule

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

func (*PrefixContext) ExitRule

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

func (*PrefixContext) GetParser

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

func (*PrefixContext) GetRuleContext

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

func (*PrefixContext) IsPrefixContext

func (*PrefixContext) IsPrefixContext()

func (*PrefixContext) ToStringTree

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

type UnitContext

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

func NewEmptyUnitContext

func NewEmptyUnitContext() *UnitContext

func NewUnitContext

func NewUnitContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *UnitContext

func (*UnitContext) Baseunit

func (s *UnitContext) Baseunit() IBaseunitContext

func (*UnitContext) Derivedunit

func (s *UnitContext) Derivedunit() IDerivedunitContext

func (*UnitContext) EnterRule

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

func (*UnitContext) ExitRule

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

func (*UnitContext) GetParser

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

func (*UnitContext) GetRuleContext

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

func (*UnitContext) IsUnitContext

func (*UnitContext) IsUnitContext()

func (*UnitContext) ToStringTree

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

type UomContext

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

func NewEmptyUomContext

func NewEmptyUomContext() *UomContext

func NewUomContext

func NewUomContext(parser antlr.Parser, parent antlr.ParserRuleContext, invokingState int) *UomContext

func (*UomContext) AllMeasure

func (s *UomContext) AllMeasure() []IMeasureContext

func (*UomContext) EnterRule

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

func (*UomContext) ExitRule

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

func (*UomContext) GetParser

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

func (*UomContext) GetRuleContext

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

func (*UomContext) IsUomContext

func (*UomContext) IsUomContext()

func (*UomContext) Measure

func (s *UomContext) Measure(i int) IMeasureContext

func (*UomContext) ToStringTree

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