Documentation ¶
Overview ¶
Package parser implements a parser for yacc source files.
Note: Rule.Body element's type
int Eg. 65 represents literal 'A' string Eg. "Start" represents rule component Start *Action Mid rule action or rule semantic action
Index ¶
Constants ¶
const ( // ActionValueGo is used for a Go code fragment ActionValueGo = iota // ActionValueDlrDlr is used for $$. ActionValueDlrDlr // ActionValueDlrTagDlr is used for $<tag>$. ActionValueDlrTagDlr // ActionValueDlrNum is used for $num. ActionValueDlrNum // ActionValueDlrTagNum is used for $<tag>num. ActionValueDlrTagNum )
const ( COMMENT = 57346 C_IDENTIFIER = 57347 ERROR_VERBOSE = 57348 IDENTIFIER = 57349 LCURL = 57350 LEFT = 57351 MARK = 57352 NONASSOC = 57353 NUMBER = 57354 PREC = 57355 PRECEDENCE = 57356 RCURL = 57357 RIGHT = 57358 START = 57359 STRING_LITERAL = 57360 TOKEN = 57361 TYPE = 57362 UNION = 57363 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { Values []*ActionValue // For backward compatibility. Token *Token Token2 *Token }
Action represents data reduced by production:
Action: '{' '}'
type ActionValue ¶
type ActionValue struct { Num int // The number in $num. Pos token.Pos // Position of the start of the ActionValue. Src string // Source for this value. Tag string // The tag in $<tag>$ or $<tag>num. Type int // One of ActionValue{Go,DlrDlr,DlrTagDlr,DlrNum,DlrTagNum} constants. }
ActionValue is an item of Action.Value
type Definition ¶
type Definition struct { Nlist []*Name // For backward compatibility. Value string Case int NameList *NameList ReservedWord *ReservedWord Tag *Tag Token *Token Token2 *Token }
Definition represents data reduced by productions:
Definition: START IDENTIFIER | UNION // Case 1 | LCURL RCURL // Case 2 | ReservedWord Tag NameList // Case 3 | ReservedWord Tag // Case 4 | ERROR_VERBOSE // Case 5
func (*Definition) Pos ¶
func (n *Definition) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
type DefinitionList ¶
type DefinitionList struct { Definition *Definition DefinitionList *DefinitionList }
DefinitionList represents data reduced by productions:
DefinitionList: /* empty */ | DefinitionList Definition // Case 1
func (*DefinitionList) Pos ¶
func (n *DefinitionList) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
func (*DefinitionList) String ¶
func (n *DefinitionList) String() string
String implements fmt.Stringer.
type LiteralStringOpt ¶
type LiteralStringOpt struct {
Token *Token
}
LiteralStringOpt represents data reduced by productions:
LiteralStringOpt: /* empty */ | STRING_LITERAL // Case 1
func (*LiteralStringOpt) Pos ¶
func (n *LiteralStringOpt) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
func (*LiteralStringOpt) String ¶
func (n *LiteralStringOpt) String() string
String implements fmt.Stringer.
type Name ¶
type Name struct { Identifier interface{} // For backward compatibility. Number int // For backward compatibility. Case int LiteralStringOpt *LiteralStringOpt Token *Token Token2 *Token }
Name represents data reduced by productions:
Name: IDENTIFIER LiteralStringOpt | IDENTIFIER NUMBER LiteralStringOpt // Case 1
type NameList ¶
NameList represents data reduced by productions:
NameList: Name | NameList Name // Case 1 | NameList ',' Name // Case 2
type Precedence ¶
type Precedence struct { Identifier interface{} // Name string or literal int. Action *Action Case int Precedence *Precedence Token *Token Token2 *Token }
Precedence represents data reduced by productions:
Precedence: /* empty */ | PREC IDENTIFIER // Case 1 | PREC IDENTIFIER Action // Case 2 | Precedence ';' // Case 3
func (*Precedence) Pos ¶
func (n *Precedence) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
type ReservedWord ¶
ReservedWord represents data reduced by productions:
ReservedWord: TOKEN | LEFT // Case 1 | RIGHT // Case 2 | NONASSOC // Case 3 | TYPE // Case 4 | PRECEDENCE // Case 5
func (*ReservedWord) Pos ¶
func (n *ReservedWord) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
func (*ReservedWord) String ¶
func (n *ReservedWord) String() string
String implements fmt.Stringer.
type Rule ¶
type Rule struct { Body []interface{} // For backward compatibility. Name *Token Case int Precedence *Precedence RuleItemList *RuleItemList Token *Token }
Rule represents data reduced by productions:
Rule: C_IDENTIFIER RuleItemList Precedence | '|' RuleItemList Precedence // Case 1
type RuleItemList ¶
type RuleItemList struct { Action *Action Case int RuleItemList *RuleItemList Token *Token }
RuleItemList represents data reduced by productions:
RuleItemList: /* empty */ | RuleItemList IDENTIFIER // Case 1 | RuleItemList Action // Case 2 | RuleItemList STRING_LITERAL // Case 3
func (*RuleItemList) Pos ¶
func (n *RuleItemList) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
func (*RuleItemList) String ¶
func (n *RuleItemList) String() string
String implements fmt.Stringer.
type RuleList ¶
type RuleList struct { Case int Precedence *Precedence Rule *Rule RuleItemList *RuleItemList RuleList *RuleList Token *Token }
RuleList represents data reduced by productions:
RuleList: C_IDENTIFIER RuleItemList Precedence | RuleList Rule // Case 1
type Specification ¶
type Specification struct { Defs []*Definition // For backward compatibility. Rules []*Rule // For backward compatibility. DefinitionList *DefinitionList RuleList *RuleList Tail *Tail Token *Token }
Specification represents data reduced by production:
Specification: DefinitionList "%%" RuleList Tail
func Parse ¶
Parse parses src as a single yacc source file fname and returns the corresponding Specification. If the source couldn't be read, the returned Specification is nil and the error indicates all of the specific failures.
func (*Specification) Pos ¶
func (n *Specification) Pos() token.Pos
Pos reports the position of the first component of n or zero if it's empty.
func (*Specification) String ¶
func (n *Specification) String() string
String implements fmt.Stringer.
type Tag ¶
Tag represents data reduced by productions:
Tag: /* empty */ | '<' IDENTIFIER '>' // Case 1
type Tail ¶
Tail represents data reduced by productions:
Tail: "%%" | /* empty */ // Case 1