const_fetch node
This commit is contained in:
parent
2703c00374
commit
52638e6654
29
node/expr/const_fetch.go
Normal file
29
node/expr/const_fetch.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package expr
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ConstFetch struct {
|
||||||
|
node.SimpleNode
|
||||||
|
name node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewConstFetch(name node.Node) node.Node {
|
||||||
|
return ConstFetch{
|
||||||
|
node.SimpleNode{Name: "ConstFetch", Attributes: make(map[string]string)},
|
||||||
|
name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n ConstFetch) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [- -]", indent, n.Name)
|
||||||
|
|
||||||
|
if n.name != nil {
|
||||||
|
fmt.Fprintf(out, "\n%vname:", indent+" ")
|
||||||
|
n.name.Print(out, indent+" ")
|
||||||
|
}
|
||||||
|
}
|
@ -4506,7 +4506,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-1 : yypt+1]
|
yyDollar = yyS[yypt-1 : yypt+1]
|
||||||
//line parser/parser.y:981
|
//line parser/parser.y:981
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("Const").Append(yyDollar[1].node)
|
yyVAL.node = expr.NewConstFetch(yyDollar[1].node)
|
||||||
}
|
}
|
||||||
case 412:
|
case 412:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
|
@ -978,7 +978,7 @@ scalar:
|
|||||||
;
|
;
|
||||||
|
|
||||||
constant:
|
constant:
|
||||||
name { $$ = node.NewSimpleNode("Const").Append($1) }
|
name { $$ = expr.NewConstFetch($1) }
|
||||||
| class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = expr.NewClassConstFetch($1, $3) }
|
| class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = expr.NewClassConstFetch($1, $3) }
|
||||||
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier
|
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM identifier
|
||||||
{ $$ = expr.NewClassConstFetch($1, $3) }
|
{ $$ = expr.NewClassConstFetch($1, $3) }
|
||||||
|
Loading…
Reference in New Issue
Block a user