#51 saving optional tokes and tokens that have different representation as meta
This commit is contained in:
@@ -98,12 +98,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) {
|
||||
|
||||
1932
php7/php7.go
1932
php7/php7.go
File diff suppressed because it is too large
Load Diff
1136
php7/php7.y
1136
php7/php7.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