This commit is contained in:
vadim 2017-12-08 16:54:44 +02:00
parent 32b05a653b
commit 20626ef69b
3 changed files with 985 additions and 954 deletions

25
node/stmt/nop.go Normal file
View 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)
}

File diff suppressed because it is too large Load Diff

View File

@ -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)