[refactoring] update ast structure of "InlinHtml" node

This commit is contained in:
Vadym Slizov 2020-09-14 16:36:01 +03:00
parent 7678303cb9
commit 8b4d65ac4d
7 changed files with 36 additions and 36 deletions

14
internal/php5/php5.go generated

@ -3190,13 +3190,13 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php5/php5.y:1064 // line internal/php5/php5.y:1064
{ {
yyVAL.node = &ast.StmtInlineHtml{ast.Node{}, yyDollar[1].token.Value} yyVAL.node = &ast.StmtInlineHtml{
Node: ast.Node{
// save position Position: position.NewTokenPosition(yyDollar[1].token),
yyVAL.node.GetNode().Position = position.NewTokenPosition(yyDollar[1].token) },
InlineHtmlTkn: yyDollar[1].token,
// save comments Value: yyDollar[1].token.Value,
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Start, yyDollar[1].token.SkippedTokens) }
} }
case 66: case 66:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]

@ -1062,13 +1062,13 @@ unticked_statement:
} }
| T_INLINE_HTML | T_INLINE_HTML
{ {
$$ = &ast.StmtInlineHtml{ast.Node{}, $1.Value} $$ = &ast.StmtInlineHtml{
Node: ast.Node{
// save position Position: position.NewTokenPosition($1),
$$.GetNode().Position = position.NewTokenPosition($1) },
InlineHtmlTkn: $1,
// save comments Value: $1.Value,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| expr ';' | expr ';'
{ {

14
internal/php7/php7.go generated

@ -3314,13 +3314,13 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php7/php7.y:978 // line internal/php7/php7.y:978
{ {
yyVAL.node = &ast.StmtInlineHtml{ast.Node{}, yyDollar[1].token.Value} yyVAL.node = &ast.StmtInlineHtml{
Node: ast.Node{
// save position Position: position.NewTokenPosition(yyDollar[1].token),
yyVAL.node.GetNode().Position = position.NewTokenPosition(yyDollar[1].token) },
InlineHtmlTkn: yyDollar[1].token,
// save comments Value: yyDollar[1].token.Value,
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Start, yyDollar[1].token.SkippedTokens) }
} }
case 146: case 146:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]

@ -976,13 +976,13 @@ statement:
} }
| T_INLINE_HTML | T_INLINE_HTML
{ {
$$ = &ast.StmtInlineHtml{ast.Node{}, $1.Value} $$ = &ast.StmtInlineHtml{
Node: ast.Node{
// save position Position: position.NewTokenPosition($1),
$$.GetNode().Position = position.NewTokenPosition($1) },
InlineHtmlTkn: $1,
// save comments Value: $1.Value,
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens) }
} }
| expr ';' | expr ';'
{ {

@ -535,7 +535,8 @@ func (n *StmtIf) Accept(v NodeVisitor) {
// StmtInlineHtml node // StmtInlineHtml node
type StmtInlineHtml struct { type StmtInlineHtml struct {
Node Node
Value []byte InlineHtmlTkn *token.Token
Value []byte
} }
func (n *StmtInlineHtml) Accept(v NodeVisitor) { func (n *StmtInlineHtml) Accept(v NodeVisitor) {

@ -200,3 +200,7 @@ func (v *FilterTokens) StmtEcho(n *ast.StmtEcho) {
n.SeparatorTkns = nil n.SeparatorTkns = nil
n.SemiColonTkn = nil n.SemiColonTkn = nil
} }
func (v *FilterTokens) StmtInlineHtml(n *ast.StmtInlineHtml) {
n.InlineHtmlTkn = nil
}

@ -2555,18 +2555,13 @@ func (p *Printer) printStmtAltIf(n *ast.StmtIf) {
p.printToken(n.SemiColonTkn, ";") p.printToken(n.SemiColonTkn, ";")
} }
func (p *Printer) printStmtInlineHTML(n ast.Vertex) { func (p *Printer) printStmtInlineHTML(n *ast.StmtInlineHtml) {
nn := n.(*ast.StmtInlineHtml)
p.printFreeFloating(nn, token.Start)
if p.s == PhpState && !bytes.Contains(p.lastWrite, []byte("?>")) { if p.s == PhpState && !bytes.Contains(p.lastWrite, []byte("?>")) {
p.write([]byte("?>")) p.write([]byte("?>"))
} }
p.SetState(HtmlState) p.SetState(HtmlState)
p.write(nn.Value) p.printToken(n.InlineHtmlTkn, string(n.Value))
p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printStmtInterface(n ast.Vertex) { func (p *Printer) printStmtInterface(n ast.Vertex) {