listener

package
v0.0.0-...-9b1b795 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstLower

func FirstLower(s string) string

FirstLower 字符串首字母小写

func FirstUpper

func FirstUpper(s string) string

FirstUpper 字符串首字母大写写

func IsNumber

func IsNumber(k string) bool

Types

type GoTarget

type GoTarget struct {
	ConfPath string
	PkgName  string
	ConfName string
}

func (*GoTarget) ExitArr

func (t *GoTarget) ExitArr(typeStr, valStr string) string

func (t*GoTarget)ExitArr is called when production arr is exited.

func (*GoTarget) ExitJson

func (t *GoTarget) ExitJson(typeStr, valStr string) string

func (t*GoTarget)ExitJson is called when production json is exited.

func (*GoTarget) ExitObj

func (t *GoTarget) ExitObj(typeStr, valStr string, isEnd bool, bIsMap bool) string

func (*GoTarget) ExitPair

func (t *GoTarget) ExitPair(index int, keyStr, typeStr, valStr, valType string) (string, string)

func (t*GoTarget)ExitPair is called when production pair is exited.

func (*GoTarget) ExitValue

func (t *GoTarget) ExitValue(typeStr, valStr string) string

func (t*GoTarget)ExitValue is called when production value is exited.

func (*GoTarget) PostExitObj

func (t *GoTarget) PostExitObj(typeStr, valStr string) string

func (*GoTarget) PreExitObj

func (t *GoTarget) PreExitObj(typeStr, valStr string) string

func (t*GoTarget)ExitObj is called when production obj is exited.

type Listener

type Listener struct {
	*parser.BaseJSONListener

	JsonStr    string
	Target     Target
	SubStructs []string
	// contains filtered or unexported fields
}

func NewJsonToGoListener

func NewJsonToGoListener(t Target) *Listener

func (*Listener) EnterArr

func (l *Listener) EnterArr(ctx *parser.ArrContext)

EnterArr is called when production arr is entered.

func (*Listener) EnterEveryRule

func (l *Listener) EnterEveryRule(ctx antlr.ParserRuleContext)

EnterEveryRule is called when any rule is entered.

func (*Listener) EnterJson

func (l *Listener) EnterJson(ctx *parser.JsonContext)

EnterJson is called when production json is entered.

func (*Listener) EnterObj

func (l *Listener) EnterObj(ctx *parser.ObjContext)

EnterObj is called when production obj is entered.

func (*Listener) EnterPair

func (l *Listener) EnterPair(ctx *parser.PairContext)

EnterPair is called when production pair is entered.

func (*Listener) EnterValue

func (l *Listener) EnterValue(ctx *parser.ValueContext)

EnterValue is called when production value is entered.

func (*Listener) ExitArr

func (l *Listener) ExitArr(ctx *parser.ArrContext)

ExitArr is called when production arr is exited.

func (*Listener) ExitEveryRule

func (l *Listener) ExitEveryRule(ctx antlr.ParserRuleContext)

ExitEveryRule is called when any rule is exited.

func (*Listener) ExitJson

func (l *Listener) ExitJson(ctx *parser.JsonContext)

ExitJson is called when production json is exited.

func (*Listener) ExitObj

func (l *Listener) ExitObj(ctx *parser.ObjContext)

ExitObj is called when production obj is exited.

func (*Listener) ExitPair

func (l *Listener) ExitPair(ctx *parser.PairContext)

ExitPair is called when production pair is exited.

func (*Listener) ExitValue

func (l *Listener) ExitValue(ctx *parser.ValueContext)

ExitValue is called when production value is exited.

func (*Listener) PrintGocodeMap

func (l *Listener) PrintGocodeMap()

func (*Listener) VisitErrorNode

func (l *Listener) VisitErrorNode(node antlr.ErrorNode)

VisitErrorNode is called when an error node is visited.

func (*Listener) VisitTerminal

func (l *Listener) VisitTerminal(node antlr.TerminalNode)

VisitTerminal is called when a terminal node is visited.

type Node

type Node struct {
	Type      string
	Value     string
	ValueType string
	KeyIsNum  bool
}

type Target

type Target interface {
	// ExitJson is called when production json is exited.
	ExitJson(typeStr, valStr string) string
	// ExitObj is called when production obj is exited.
	PreExitObj(typeStr, valStr string) string
	ExitObj(typeStr, valStr string, isEnd bool, bIsMap bool) string
	PostExitObj(typeStr, valStr string) string
	// ExitPair is called when production pair is exited.
	ExitPair(index int, ketStr, typeStr, valStr, valType string) (string, string)
	// ExitArr is called when production arr is exited.
	ExitArr(typeStr, valStr string) string
	// ExitValue is called when production value is exited.
	ExitValue(typeStr, valStr string) string
}

Jump to

Keyboard shortcuts

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