halt_compiler node
This commit is contained in:
parent
3584676e43
commit
8cab46a1b4
25
node/stmt/halt_compiler.go
Normal file
25
node/stmt/halt_compiler.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package stmt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
"github.com/z7zmey/php-parser/token"
|
||||||
|
)
|
||||||
|
|
||||||
|
type HaltCompiler struct {
|
||||||
|
node.SimpleNode
|
||||||
|
token token.Token
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewHaltCompiler(token token.Token) node.Node {
|
||||||
|
return HaltCompiler{
|
||||||
|
node.SimpleNode{Name: "HaltCompiler", Attributes: make(map[string]string)},
|
||||||
|
token,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n HaltCompiler) Print(out io.Writer, indent string) {
|
||||||
|
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
|
||||||
|
}
|
@ -2575,7 +2575,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-4 : yypt+1]
|
yyDollar = yyS[yypt-4 : yypt+1]
|
||||||
//line parser/parser.y:271
|
//line parser/parser.y:271
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("THaltCompiler")
|
yyVAL.node = stmt.NewHaltCompiler(yyDollar[1].token)
|
||||||
}
|
}
|
||||||
case 91:
|
case 91:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
@ -2793,7 +2793,7 @@ yydefault:
|
|||||||
yyDollar = yyS[yypt-4 : yypt+1]
|
yyDollar = yyS[yypt-4 : yypt+1]
|
||||||
//line parser/parser.y:365
|
//line parser/parser.y:365
|
||||||
{
|
{
|
||||||
yyVAL.node = node.NewSimpleNode("THaltCompiler")
|
yyVAL.node = stmt.NewHaltCompiler(yyDollar[1].token)
|
||||||
}
|
}
|
||||||
case 129:
|
case 129:
|
||||||
yyDollar = yyS[yypt-3 : yypt+1]
|
yyDollar = yyS[yypt-3 : yypt+1]
|
||||||
|
@ -268,7 +268,7 @@ top_statement:
|
|||||||
| class_declaration_statement { $$ = $1; }
|
| class_declaration_statement { $$ = $1; }
|
||||||
| trait_declaration_statement { $$ = $1; }
|
| trait_declaration_statement { $$ = $1; }
|
||||||
| interface_declaration_statement { $$ = $1; }
|
| interface_declaration_statement { $$ = $1; }
|
||||||
| T_HALT_COMPILER '(' ')' ';' { $$ = node.NewSimpleNode("THaltCompiler") }
|
| T_HALT_COMPILER '(' ')' ';' { $$ = stmt.NewHaltCompiler($1) }
|
||||||
| T_NAMESPACE namespace_name ';' { $$ = node.NewSimpleNode("Namespace").Append(name.NewName($2)); }
|
| T_NAMESPACE namespace_name ';' { $$ = node.NewSimpleNode("Namespace").Append(name.NewName($2)); }
|
||||||
| T_NAMESPACE namespace_name '{' top_statement_list '}'
|
| T_NAMESPACE namespace_name '{' top_statement_list '}'
|
||||||
{ $$ = node.NewSimpleNode("Namespace").Append(name.NewName($2)).Append($4) }
|
{ $$ = node.NewSimpleNode("Namespace").Append(name.NewName($2)).Append($4) }
|
||||||
@ -362,7 +362,7 @@ inner_statement:
|
|||||||
| class_declaration_statement { $$ = $1; }
|
| class_declaration_statement { $$ = $1; }
|
||||||
| trait_declaration_statement { $$ = $1; }
|
| trait_declaration_statement { $$ = $1; }
|
||||||
| interface_declaration_statement { $$ = $1; }
|
| interface_declaration_statement { $$ = $1; }
|
||||||
| T_HALT_COMPILER '(' ')' ';' { $$ = node.NewSimpleNode("THaltCompiler") }
|
| T_HALT_COMPILER '(' ')' ';' { $$ = stmt.NewHaltCompiler($1) }
|
||||||
|
|
||||||
statement:
|
statement:
|
||||||
'{' inner_statement_list '}' { $$ = stmt.NewStmtList($1, $3, $2.(node.SimpleNode).Children) }
|
'{' inner_statement_list '}' { $$ = stmt.NewStmtList($1, $3, $2.(node.SimpleNode).Children) }
|
||||||
|
Loading…
Reference in New Issue
Block a user