inline_html node

This commit is contained in:
vadim 2017-12-08 11:42:50 +02:00
parent 8cab46a1b4
commit 02ce2bec9a
3 changed files with 27 additions and 2 deletions

25
node/stmt/inline_html.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 InlineHtml struct {
node.SimpleNode
token token.Token
}
func NewInlineHtml(token token.Token) node.Node {
return InlineHtml{
node.SimpleNode{Name: "InlineHtml", Attributes: make(map[string]string)},
token,
}
}
func (n InlineHtml) 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)
}

View File

@ -2879,7 +2879,7 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line parser/parser.y:387 //line parser/parser.y:387
{ {
yyVAL.node = node.NewSimpleNode("Echo").Append(node.NewSimpleNode("InlineHtml").Attribute("value", yyDollar[1].token.String())) yyVAL.node = stmt.NewInlineHtml(yyDollar[1].token)
} }
case 143: case 143:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]

View File

@ -384,7 +384,7 @@ statement:
| T_GLOBAL global_var_list ';' { $$ = stmt.NewGlobal($1, $2) } | T_GLOBAL global_var_list ';' { $$ = stmt.NewGlobal($1, $2) }
| T_STATIC static_var_list ';' { $$ = $2; } | T_STATIC static_var_list ';' { $$ = $2; }
| T_ECHO echo_expr_list ';' { $$ = stmt.NewEcho($1, $2) } | T_ECHO echo_expr_list ';' { $$ = stmt.NewEcho($1, $2) }
| T_INLINE_HTML { $$ = node.NewSimpleNode("Echo").Append(node.NewSimpleNode("InlineHtml").Attribute("value", $1.String())) } | T_INLINE_HTML { $$ = stmt.NewInlineHtml($1) }
| expr ';' { $$ = stmt.NewExpression($1); } | expr ';' { $$ = stmt.NewExpression($1); }
| T_UNSET '(' unset_variables possible_comma ')' ';' | T_UNSET '(' unset_variables possible_comma ')' ';'
{ $$ = node.NewSimpleNode("Unset").Append($3); } { $$ = node.NewSimpleNode("Unset").Append($3); }