nop node
This commit is contained in:
parent
32b05a653b
commit
20626ef69b
25
node/stmt/nop.go
Normal file
25
node/stmt/nop.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 Nop struct {
|
||||
node.SimpleNode
|
||||
token token.Token
|
||||
}
|
||||
|
||||
func NewNop(token token.Token) node.Node {
|
||||
return Nop{
|
||||
node.SimpleNode{Name: "Nop", Attributes: make(map[string]string)},
|
||||
token,
|
||||
}
|
||||
}
|
||||
|
||||
func (n Nop) 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)
|
||||
}
|
1911
parser/parser.go
1911
parser/parser.go
File diff suppressed because it is too large
Load Diff
@ -171,6 +171,7 @@ func Parse(src io.Reader, fName string) node.Node {
|
||||
%token <token> '`'
|
||||
%token <token> '{'
|
||||
%token <token> '}'
|
||||
%token <token> ';'
|
||||
|
||||
%type <value> is_reference
|
||||
%type <value> is_variadic
|
||||
@ -393,7 +394,7 @@ statement:
|
||||
| T_FOREACH '(' expr T_AS foreach_variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement
|
||||
{ $$ = stmt.NewForeach($1, $3, $5, $7, $9); }
|
||||
| T_DECLARE '(' const_list ')' declare_statement { $$ = stmt.NewDeclare($1, $3, $5) }
|
||||
| ';' /* empty statement */ { $$ = node.NewSimpleNode(""); }
|
||||
| ';' { $$ = stmt.NewNop($1) }
|
||||
| T_TRY '{' inner_statement_list '}' catch_list finally_statement
|
||||
{
|
||||
$$ = stmt.NewTry($1, $3.(node.SimpleNode).Children, $5, $6)
|
||||
|
Loading…
Reference in New Issue
Block a user