diff --git a/internal/php5/php5.go b/internal/php5/php5.go index 5392ff0..e87357e 100644 Binary files a/internal/php5/php5.go and b/internal/php5/php5.go differ diff --git a/internal/php5/php5.y b/internal/php5/php5.y index 343df17..fb42de1 100644 --- a/internal/php5/php5.y +++ b/internal/php5/php5.y @@ -1062,13 +1062,13 @@ unticked_statement: } | T_INLINE_HTML { - $$ = &ast.StmtInlineHtml{ast.Node{}, $1.Value} - - // save position - $$.GetNode().Position = position.NewTokenPosition($1) - - // save comments - yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) + $$ = &ast.StmtInlineHtml{ + Node: ast.Node{ + Position: position.NewTokenPosition($1), + }, + InlineHtmlTkn: $1, + Value: $1.Value, + } } | expr ';' { diff --git a/internal/php7/php7.go b/internal/php7/php7.go index 4734582..ab2cdc4 100644 Binary files a/internal/php7/php7.go and b/internal/php7/php7.go differ diff --git a/internal/php7/php7.y b/internal/php7/php7.y index 6f37de7..613408f 100644 --- a/internal/php7/php7.y +++ b/internal/php7/php7.y @@ -976,13 +976,13 @@ statement: } | T_INLINE_HTML { - $$ = &ast.StmtInlineHtml{ast.Node{}, $1.Value} - - // save position - $$.GetNode().Position = position.NewTokenPosition($1) - - // save comments - yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) + $$ = &ast.StmtInlineHtml{ + Node: ast.Node{ + Position: position.NewTokenPosition($1), + }, + InlineHtmlTkn: $1, + Value: $1.Value, + } } | expr ';' { diff --git a/pkg/ast/node.go b/pkg/ast/node.go index 16aa214..e83b438 100644 --- a/pkg/ast/node.go +++ b/pkg/ast/node.go @@ -535,7 +535,8 @@ func (n *StmtIf) Accept(v NodeVisitor) { // StmtInlineHtml node type StmtInlineHtml struct { Node - Value []byte + InlineHtmlTkn *token.Token + Value []byte } func (n *StmtInlineHtml) Accept(v NodeVisitor) { diff --git a/pkg/ast/visitor/filter_tokens.go b/pkg/ast/visitor/filter_tokens.go index ef9f1b3..f3c440e 100644 --- a/pkg/ast/visitor/filter_tokens.go +++ b/pkg/ast/visitor/filter_tokens.go @@ -200,3 +200,7 @@ func (v *FilterTokens) StmtEcho(n *ast.StmtEcho) { n.SeparatorTkns = nil n.SemiColonTkn = nil } + +func (v *FilterTokens) StmtInlineHtml(n *ast.StmtInlineHtml) { + n.InlineHtmlTkn = nil +} diff --git a/pkg/printer/printer.go b/pkg/printer/printer.go index 20df694..b35840d 100644 --- a/pkg/printer/printer.go +++ b/pkg/printer/printer.go @@ -2555,18 +2555,13 @@ func (p *Printer) printStmtAltIf(n *ast.StmtIf) { p.printToken(n.SemiColonTkn, ";") } -func (p *Printer) printStmtInlineHTML(n ast.Vertex) { - nn := n.(*ast.StmtInlineHtml) - p.printFreeFloating(nn, token.Start) - +func (p *Printer) printStmtInlineHTML(n *ast.StmtInlineHtml) { if p.s == PhpState && !bytes.Contains(p.lastWrite, []byte("?>")) { p.write([]byte("?>")) } p.SetState(HtmlState) - p.write(nn.Value) - - p.printFreeFloating(nn, token.End) + p.printToken(n.InlineHtmlTkn, string(n.Value)) } func (p *Printer) printStmtInterface(n ast.Vertex) {