parser

package
v0.0.0-...-e9866e7 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.

Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.

Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.

Copyright (c) 2021 Ke Yuchang(aceking.ke@gmail.com). All rights reserved. Use of this source code is governed by MIT license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	TERMID = iota + 1
	NONTERMID
)
View Source
const (
	LeftAssocType = iota + 1
	RightAssocype
	NonAssocType
)
View Source
const (
	RightSyType = iota + 1
	RightActionType
)

Variables

This section is empty.

Functions

func ActionQuoteState

func ActionQuoteState(l *lexer) stateFn

{ xxx }

func ActionState

func ActionState(l *lexer) stateFn

func CodeQuoteBegin

func CodeQuoteBegin(l *lexer) stateFn

func CommentState

func CommentState(l *lexer) stateFn

func DirectiveOtherState

func DirectiveOtherState(l *lexer) stateFn

func DirectiveState

func DirectiveState(l *lexer) stateFn

func DirectiveUnionState

func DirectiveUnionState(l *lexer) stateFn
%uinon {

}

func IdentifyState

func IdentifyState(l *lexer) stateFn

func Lex

func Lex(source string) *lexer

func RemoveTempName

func RemoveTempName(in string) string

func TestPrefix

func TestPrefix(in string) bool

Types

type Base

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

func (*Base) Location

func (b *Base) Location() Location

func (*Base) SetLocation

func (b *Base) SetLocation(l Location)

type DeclareNode

type DeclareNode struct {
	Base
	CodeList     string
	TokenDefList []TokenDef
	PrecDefList  [][]PrecDef
	TypeDefList  []TypeDef
	Union        string
	StartSym     string
}

type IDType

type IDType int

type Idendity

type Idendity struct {
	Name  string // ID
	IDTyp IDType
	Value int //value
	Tag   string
	Alias string
}

type Kind

type Kind string
const (
	Identifier Kind = "Identifier"
	Number     Kind = "Number"
	Section    Kind = "Section"

	CodeQuote   Kind = "CodeQuote"
	ActionQuote Kind = "ActionQuote"
	EOF         Kind = "EOF"

	TypeDirective  Kind = "TypeDirective"
	TokenDirective Kind = "TokenDirective"
	UnionDirective Kind = "UnionDirective"
	LeftAssoc      Kind = "LeftAssoc"
	RightAssoc     Kind = "RightAssoc"
	NoneAssoc      Kind = "NoneAssoc"
	PrecDirective  Kind = "PrecDirective"
	Precedence     Kind = "Precedence"
	StartDirective Kind = "StartDirective"

	ActionSelf   Kind = "ActionSelf"
	ActionN      Kind = "ActionN"
	ActionAccept Kind = "ActionAccept"
	ActionEnd    Kind = "ActionEnd"

	RuleOR     Kind = "RuleOR"     // |
	RuleDefine Kind = "RuleDefine" // :
	RuleEnd    Kind = "RuleEnd"    // ;

	LeftAngleBracket  Kind = "LeftAngleBracket"  // Aangle brackets <
	RightAngleBracket Kind = "RightAngleBracket" // RightAngleBracket >

	Charater   Kind = "Charater"
	StringKind Kind = "StringKind"
)

type Location

type Location struct {
	Line   int // The 1-based line of the location.
	Column int // The 0-based column number of the location.
}

func (Location) Empty

func (l Location) Empty() bool

type NilNode

type NilNode struct {
	Base
}

type Node

type Node interface {
	Location() Location
	SetLocation(Location)
}

type PrecAssocType

type PrecAssocType int

type PrecDef

type PrecDef struct {
	Prec      int
	AssocType PrecAssocType
	IdName    string
}

prec

type RightSymActType

type RightSymActType int

type RightSymOrAction

type RightSymOrAction struct {
	ElemType RightSymActType
	Element  string
}

type RootNode

type RootNode struct {
	Base
	Declare Node
	Rules   Node
	// contains filtered or unexported fields
}

Root

func Parse

func Parse(input string) (*RootNode, error)

type RootVistor

type RootVistor struct {
	*RuleVistor
	CodeCpy string
	*lalr.LALR1
}

func (*RootVistor) GetCode

func (v *RootVistor) GetCode() string

func (*RootVistor) GetCodeCopy

func (v *RootVistor) GetCodeCopy() string

func (*RootVistor) GetIdsymtabl

func (v *RootVistor) GetIdsymtabl() map[string]*Idendity

func (*RootVistor) GetRules

func (v *RootVistor) GetRules(index int) *oneRule

func (*RootVistor) GetUion

func (v *RootVistor) GetUion() string

func (*RootVistor) Process

func (v *RootVistor) Process(node *Node)

type RuleDef

type RuleDef struct {
	LineNo    int
	LeftPart  string
	RightPart []RightSymOrAction
	PrecSym   string // which prec symbol
}

Rules

type RuleDefNode

type RuleDefNode struct {
	Base
	RuleDefList []RuleDef
}

RuleDefNode

type RuleVistor

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

func (*RuleVistor) Process

func (v *RuleVistor) Process(node *Node)

type Token

type Token struct {
	Location
	Kind  Kind
	Value string
	EndAt int
}

func (Token) Is

func (t Token) Is(kind Kind, values ...string) bool

type TokenDef

type TokenDef struct {
	IdentifyList []Idendity
}

token define

type TypeDef

type TypeDef struct {
	Tag    string
	IdName string
}

type %type <num> expr expr1 expr2 expr3

type Vistor

type Vistor interface {
	Process(node *Node)
}

type Walker

type Walker struct {
	VistorNode Vistor
}

func DoWalker

func DoWalker(node *Node, vistor Vistor) *Walker

func ParseAndBuild

func ParseAndBuild(input string) (*Walker, error)

func (*Walker) BuildLALR1

func (w *Walker) BuildLALR1() *lalr.LALR1

func (*Walker) Walk

func (w *Walker) Walk(node *Node)

Jump to

Keyboard shortcuts

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