remove meta.StringVarnameToken
This commit is contained in:
parent
03f6b9e419
commit
ef14a6c56b
@ -7,7 +7,6 @@ type TokenName int
|
||||
const (
|
||||
NodeStart TokenName = iota
|
||||
NodeEnd
|
||||
StringVarnameToken
|
||||
NumStringToken
|
||||
WhileToken
|
||||
EndwhileToken
|
||||
|
@ -4,9 +4,9 @@ package meta
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _TokenName_name = "NodeStartNodeEndStringVarnameTokenNumStringTokenWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenEndforTokenEndforeachTokenEnddeclareTokenAsTokenEndswitchTokenFunctionTokenConstTokenInsteadofTokenClassTokenExtendsTokenImplementsTokenDoubleArrowTokenPaamayimNekudotayimTokenUseLeadingNsSeparatorTokenNsSeparatorTokenEllipsisTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenEndifTokenIncTokenDecTokenObjectOperatorTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenCaseSeparatorTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
|
||||
const _TokenName_name = "NodeStartNodeEndNumStringTokenWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenEndforTokenEndforeachTokenEnddeclareTokenAsTokenEndswitchTokenFunctionTokenConstTokenInsteadofTokenClassTokenExtendsTokenImplementsTokenDoubleArrowTokenPaamayimNekudotayimTokenUseLeadingNsSeparatorTokenNsSeparatorTokenEllipsisTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenEndifTokenIncTokenDecTokenObjectOperatorTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenCaseSeparatorTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
|
||||
|
||||
var _TokenName_index = [...]uint16{0, 9, 16, 34, 48, 58, 71, 92, 113, 124, 139, 154, 161, 175, 188, 198, 212, 222, 234, 249, 265, 289, 315, 331, 344, 358, 373, 388, 403, 413, 421, 429, 448, 461, 475, 489, 504, 517, 530, 543, 559, 572, 585, 597, 610, 622, 634, 648, 663, 671, 678, 685, 701, 720, 732, 747, 768, 789, 807, 827, 848, 862, 872, 892, 913, 930, 948, 965, 979, 989, 998, 1008, 1024, 1034, 1044, 1057, 1067, 1079, 1088, 1100, 1108}
|
||||
var _TokenName_index = [...]uint16{0, 9, 16, 30, 40, 53, 74, 95, 106, 121, 136, 143, 157, 170, 180, 194, 204, 216, 231, 247, 271, 297, 313, 326, 340, 355, 370, 385, 395, 403, 411, 430, 443, 457, 471, 486, 499, 512, 525, 541, 554, 567, 579, 592, 604, 616, 630, 645, 653, 660, 667, 683, 702, 714, 729, 750, 771, 789, 809, 830, 844, 854, 874, 895, 912, 930, 947, 961, 971, 980, 990, 1006, 1016, 1026, 1039, 1049, 1061, 1070, 1082, 1090}
|
||||
|
||||
func (i TokenName) String() string {
|
||||
if i < 0 || i >= TokenName(len(_TokenName_index)-1) {
|
||||
|
43
php5/php5.go
43
php5/php5.go
@ -348,7 +348,7 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php5/php5.y:6992
|
||||
//line php5/php5.y:6991
|
||||
type simpleIndirectReference struct {
|
||||
all []*expr.Variable
|
||||
last *expr.Variable
|
||||
@ -9294,7 +9294,6 @@ yydefault:
|
||||
// save comments
|
||||
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken(yyVAL.node, yyDollar[1].token, meta.NodeStart)
|
||||
yyDollar[2].token.Meta.SetTokenName(meta.StringVarnameToken).AppendTo(variable.GetMeta())
|
||||
yyDollar[3].token.Meta.SetTokenName(meta.OpenSquareBracket).AppendTo(yyVAL.node.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken(yyVAL.node, yyDollar[3].token, meta.OpenSquareBracket)
|
||||
yyDollar[5].token.Meta.SetTokenName(meta.CloseSquareBracket).AppendTo(yyVAL.node.GetMeta())
|
||||
@ -9306,7 +9305,7 @@ yydefault:
|
||||
}
|
||||
case 501:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6723
|
||||
//line php5/php5.y:6722
|
||||
{
|
||||
yyVAL.node = yyDollar[2].node
|
||||
|
||||
@ -9320,7 +9319,7 @@ yydefault:
|
||||
}
|
||||
case 502:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6738
|
||||
//line php5/php5.y:6737
|
||||
{
|
||||
yyVAL.node = scalar.NewString(yyDollar[1].token.Value)
|
||||
|
||||
@ -9334,7 +9333,7 @@ yydefault:
|
||||
}
|
||||
case 503:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6750
|
||||
//line php5/php5.y:6749
|
||||
{
|
||||
// TODO: add option to handle 64 bit integer
|
||||
if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil {
|
||||
@ -9353,7 +9352,7 @@ yydefault:
|
||||
}
|
||||
case 504:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6767
|
||||
//line php5/php5.y:6766
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -9370,7 +9369,7 @@ yydefault:
|
||||
}
|
||||
case 505:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6785
|
||||
//line php5/php5.y:6784
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -9386,7 +9385,7 @@ yydefault:
|
||||
}
|
||||
case 506:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6799
|
||||
//line php5/php5.y:6798
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9402,7 +9401,7 @@ yydefault:
|
||||
}
|
||||
case 507:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6813
|
||||
//line php5/php5.y:6812
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9418,7 +9417,7 @@ yydefault:
|
||||
}
|
||||
case 508:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6827
|
||||
//line php5/php5.y:6826
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -9432,7 +9431,7 @@ yydefault:
|
||||
}
|
||||
case 509:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6839
|
||||
//line php5/php5.y:6838
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -9446,7 +9445,7 @@ yydefault:
|
||||
}
|
||||
case 510:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6851
|
||||
//line php5/php5.y:6850
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -9462,7 +9461,7 @@ yydefault:
|
||||
}
|
||||
case 511:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6865
|
||||
//line php5/php5.y:6864
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -9476,7 +9475,7 @@ yydefault:
|
||||
}
|
||||
case 512:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6877
|
||||
//line php5/php5.y:6876
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -9490,7 +9489,7 @@ yydefault:
|
||||
}
|
||||
case 513:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6892
|
||||
//line php5/php5.y:6891
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -9498,7 +9497,7 @@ yydefault:
|
||||
}
|
||||
case 514:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6898
|
||||
//line php5/php5.y:6897
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -9509,7 +9508,7 @@ yydefault:
|
||||
}
|
||||
case 515:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6910
|
||||
//line php5/php5.y:6909
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9517,7 +9516,7 @@ yydefault:
|
||||
}
|
||||
case 516:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6916
|
||||
//line php5/php5.y:6915
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9525,7 +9524,7 @@ yydefault:
|
||||
}
|
||||
case 517:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6925
|
||||
//line php5/php5.y:6924
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9542,7 +9541,7 @@ yydefault:
|
||||
}
|
||||
case 518:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6940
|
||||
//line php5/php5.y:6939
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9559,7 +9558,7 @@ yydefault:
|
||||
}
|
||||
case 519:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6958
|
||||
//line php5/php5.y:6957
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9576,7 +9575,7 @@ yydefault:
|
||||
}
|
||||
case 520:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6976
|
||||
//line php5/php5.y:6975
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
|
@ -6709,7 +6709,6 @@ encaps_var:
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $1, meta.NodeStart)
|
||||
$2.Meta.SetTokenName(meta.StringVarnameToken).AppendTo(variable.GetMeta())
|
||||
$3.Meta.SetTokenName(meta.OpenSquareBracket).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $3, meta.OpenSquareBracket)
|
||||
$5.Meta.SetTokenName(meta.CloseSquareBracket).AppendTo($$.GetMeta())
|
||||
|
33
php7/php7.go
33
php7/php7.go
@ -348,7 +348,7 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php7/php7.y:5465
|
||||
//line php7/php7.y:5464
|
||||
|
||||
//line yacctab:1
|
||||
var yyExca = [...]int{
|
||||
@ -7919,7 +7919,6 @@ yydefault:
|
||||
// save comments
|
||||
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken(yyVAL.node, yyDollar[1].token, meta.NodeStart)
|
||||
yyDollar[2].token.Meta.SetTokenName(meta.StringVarnameToken).AppendTo(variable.GetMeta())
|
||||
yyDollar[3].token.Meta.SetTokenName(meta.OpenSquareBracket).AppendTo(yyVAL.node.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken(yyVAL.node, yyDollar[3].token, meta.OpenSquareBracket)
|
||||
yyDollar[5].token.Meta.SetTokenName(meta.CloseSquareBracket).AppendTo(yyVAL.node.GetMeta())
|
||||
@ -7931,7 +7930,7 @@ yydefault:
|
||||
}
|
||||
case 475:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5248
|
||||
//line php7/php7.y:5247
|
||||
{
|
||||
yyVAL.node = yyDollar[2].node
|
||||
|
||||
@ -7945,7 +7944,7 @@ yydefault:
|
||||
}
|
||||
case 476:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5263
|
||||
//line php7/php7.y:5262
|
||||
{
|
||||
yyVAL.node = scalar.NewString(yyDollar[1].token.Value)
|
||||
|
||||
@ -7959,7 +7958,7 @@ yydefault:
|
||||
}
|
||||
case 477:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5275
|
||||
//line php7/php7.y:5274
|
||||
{
|
||||
// TODO: add option to handle 64 bit integer
|
||||
if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil {
|
||||
@ -7978,7 +7977,7 @@ yydefault:
|
||||
}
|
||||
case 478:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5292
|
||||
//line php7/php7.y:5291
|
||||
{
|
||||
var lnumber *scalar.Lnumber
|
||||
// TODO: add option to handle 64 bit integer
|
||||
@ -8011,7 +8010,7 @@ yydefault:
|
||||
}
|
||||
case 479:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5323
|
||||
//line php7/php7.y:5322
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -8028,7 +8027,7 @@ yydefault:
|
||||
}
|
||||
case 480:
|
||||
yyDollar = yyS[yypt-5 : yypt+1]
|
||||
//line php7/php7.y:5341
|
||||
//line php7/php7.y:5340
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -8048,7 +8047,7 @@ yydefault:
|
||||
}
|
||||
case 481:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5359
|
||||
//line php7/php7.y:5358
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -8064,7 +8063,7 @@ yydefault:
|
||||
}
|
||||
case 482:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5373
|
||||
//line php7/php7.y:5372
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -8078,7 +8077,7 @@ yydefault:
|
||||
}
|
||||
case 483:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5385
|
||||
//line php7/php7.y:5384
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -8092,7 +8091,7 @@ yydefault:
|
||||
}
|
||||
case 484:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5397
|
||||
//line php7/php7.y:5396
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -8108,7 +8107,7 @@ yydefault:
|
||||
}
|
||||
case 485:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5411
|
||||
//line php7/php7.y:5410
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -8122,7 +8121,7 @@ yydefault:
|
||||
}
|
||||
case 486:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5423
|
||||
//line php7/php7.y:5422
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -8136,7 +8135,7 @@ yydefault:
|
||||
}
|
||||
case 487:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5438
|
||||
//line php7/php7.y:5437
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -8144,7 +8143,7 @@ yydefault:
|
||||
}
|
||||
case 488:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5444
|
||||
//line php7/php7.y:5443
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -8155,7 +8154,7 @@ yydefault:
|
||||
}
|
||||
case 489:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5456
|
||||
//line php7/php7.y:5455
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
|
@ -5234,7 +5234,6 @@ encaps_var:
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $1, meta.NodeStart)
|
||||
$2.Meta.SetTokenName(meta.StringVarnameToken).AppendTo(variable.GetMeta())
|
||||
$3.Meta.SetTokenName(meta.OpenSquareBracket).AppendTo($$.GetMeta())
|
||||
yylex.(*Parser).appendMetaToken($$, $3, meta.OpenSquareBracket)
|
||||
$5.Meta.SetTokenName(meta.CloseSquareBracket).AppendTo($$.GetMeta())
|
||||
|
@ -1356,8 +1356,6 @@ func TestParseAndPrintPhp5ComplexString1(t *testing.T) {
|
||||
|
||||
func TestParseAndPrintPhp5ComplexString2(t *testing.T) {
|
||||
src := `<?php
|
||||
"test ${foo}" ;
|
||||
"test ${foo[0]}";
|
||||
"test ${ foo }" ;
|
||||
"test ${ foo . 'bar' }" ;
|
||||
"test ${ foo [ ] }" ;
|
||||
@ -1377,6 +1375,26 @@ func TestParseAndPrintPhp5ComplexString2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseAndPrintPhp5ComplexString3(t *testing.T) {
|
||||
src := `<?php
|
||||
"test ${foo }" ;
|
||||
"test ${foo . 'bar' }" ;
|
||||
"test ${foo [ ] }" ;
|
||||
"test ${foo [ 1 ] }" ;
|
||||
"test ${foo [ 'expr' . $bar ] }" ;
|
||||
"test ${$foo }" ;
|
||||
"test ${$foo -> bar }" ;
|
||||
"test ${$foo -> bar ( ) }" ;
|
||||
"test ${$a . '' }" ;
|
||||
`
|
||||
|
||||
actual := printPhp5(parsePhp5(src))
|
||||
|
||||
if src != actual {
|
||||
t.Errorf("\nexpected: %s\ngot: %s\n", src, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAndPrintPhp5ComplexString4(t *testing.T) {
|
||||
src := `<?php
|
||||
"test {$foo }" ;
|
||||
"test {$foo [ ] }" ;
|
||||
|
@ -1465,11 +1465,10 @@ func TestParseAndPrintComplexString1(t *testing.T) {
|
||||
|
||||
func TestParseAndPrintComplexString2(t *testing.T) {
|
||||
src := `<?php
|
||||
"test ${foo}" ;
|
||||
"test ${foo[0]}";
|
||||
"test ${ foo }" ;
|
||||
"test ${ foo . 'bar' }" ;
|
||||
"test ${ foo [ ] }" ;
|
||||
"test ${ foo [ $b ] }" ;
|
||||
"test ${ foo [ 1 ] }" ;
|
||||
"test ${ foo [ 'expr' . $bar ] }" ;
|
||||
"test ${ $foo }" ;
|
||||
@ -1486,6 +1485,29 @@ func TestParseAndPrintComplexString2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseAndPrintComplexString3(t *testing.T) {
|
||||
src := `<?php
|
||||
"test ${foo}" ;
|
||||
"test ${foo[0]}";
|
||||
"test ${foo }" ;
|
||||
"test ${foo . 'bar' }" ;
|
||||
"test ${foo [ ] }" ;
|
||||
"test ${foo [ $b ] }" ;
|
||||
"test ${foo [ 1 ] }" ;
|
||||
"test ${foo [ 'expr' . $bar ] }" ;
|
||||
"test ${$foo }" ;
|
||||
"test ${$foo -> bar }" ;
|
||||
"test ${$foo -> bar ( ) }" ;
|
||||
"test ${$a . '' }" ;
|
||||
`
|
||||
|
||||
actual := print(parse(src))
|
||||
|
||||
if src != actual {
|
||||
t.Errorf("\nexpected: %s\ngot: %s\n", src, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseAndPrintComplexString4(t *testing.T) {
|
||||
src := `<?php
|
||||
"test {$foo }" ;
|
||||
"test {$foo [ ] }" ;
|
||||
|
Loading…
Reference in New Issue
Block a user