#51 saving optional tokes and tokens that have different representation as meta
This commit is contained in:
@@ -65,7 +65,7 @@ func (l *Parser) Parse() int {
|
||||
return yyParse(l)
|
||||
}
|
||||
|
||||
func (l *Parser) listGetFirstNodeMeta(list []node.Node) []meta.Meta {
|
||||
func (l *Parser) listGetFirstNodeMeta(list []node.Node) *meta.Collection {
|
||||
if len(list) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -107,12 +107,34 @@ func isDollar(r rune) bool {
|
||||
return r == '$'
|
||||
}
|
||||
|
||||
func addMeta(n node.Node, mm []meta.Meta, tn meta.TokenName) {
|
||||
for _, m := range mm {
|
||||
m.SetTokenName(tn)
|
||||
func (l *Parser) appendMetaToken(n node.Node, t *scanner.Token, tn meta.TokenName) {
|
||||
if !l.Lexer.WithMeta {
|
||||
return
|
||||
}
|
||||
|
||||
n.AddMeta(mm)
|
||||
m := &meta.Data{
|
||||
Value: t.Value,
|
||||
Type: meta.TokenType,
|
||||
Position: l.positionBuilder.NewTokenPosition(t),
|
||||
TokenName: tn,
|
||||
}
|
||||
|
||||
n.GetMeta().Push(m)
|
||||
}
|
||||
|
||||
func (l *Parser) prependMetaToken(n node.Node, t *scanner.Token, tn meta.TokenName) {
|
||||
if !l.Lexer.WithMeta {
|
||||
return
|
||||
}
|
||||
|
||||
m := &meta.Data{
|
||||
Value: t.Value,
|
||||
Type: meta.TokenType,
|
||||
Position: l.positionBuilder.NewTokenPosition(t),
|
||||
TokenName: tn,
|
||||
}
|
||||
|
||||
n.GetMeta().Unshift(m)
|
||||
}
|
||||
|
||||
func (p *Parser) returnTokenToPool(yyDollar []yySymType, yyVAL *yySymType) {
|
||||
|
||||
2382
php5/php5.go
2382
php5/php5.go
File diff suppressed because it is too large
Load Diff
1360
php5/php5.y
1360
php5/php5.y
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user