#51 saving optional tokes and tokens that have different representation as meta
This commit is contained in:
+27
-5
@@ -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) {
|
||||
|
||||
+1272
-1110
File diff suppressed because it is too large
Load Diff
+761
-599
File diff suppressed because it is too large
Load Diff
+358
-16
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user