remove meta.NumStringToken
This commit is contained in:
parent
ef14a6c56b
commit
ad5deef4f3
@ -7,7 +7,6 @@ type TokenName int
|
||||
const (
|
||||
NodeStart TokenName = iota
|
||||
NodeEnd
|
||||
NumStringToken
|
||||
WhileToken
|
||||
EndwhileToken
|
||||
ForInitSemicolonToken
|
||||
|
@ -4,9 +4,9 @@ package meta
|
||||
|
||||
import "strconv"
|
||||
|
||||
const _TokenName_name = "NodeStartNodeEndNumStringTokenWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenEndforTokenEndforeachTokenEnddeclareTokenAsTokenEndswitchTokenFunctionTokenConstTokenInsteadofTokenClassTokenExtendsTokenImplementsTokenDoubleArrowTokenPaamayimNekudotayimTokenUseLeadingNsSeparatorTokenNsSeparatorTokenEllipsisTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenEndifTokenIncTokenDecTokenObjectOperatorTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenCaseSeparatorTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
|
||||
const _TokenName_name = "NodeStartNodeEndWhileTokenEndwhileTokenForInitSemicolonTokenForCondSemicolonTokenEndforTokenEndforeachTokenEnddeclareTokenAsTokenEndswitchTokenFunctionTokenConstTokenInsteadofTokenClassTokenExtendsTokenImplementsTokenDoubleArrowTokenPaamayimNekudotayimTokenUseLeadingNsSeparatorTokenNsSeparatorTokenEllipsisTokenLogicalOrTokenLogicalXorTokenLogicalAndTokenInstanceofTokenEndifTokenIncTokenDecTokenObjectOperatorTokenCoalesceTokenSpaceshipTokenPlusEqualTokenMinusEqualTokenMulEqualTokenPowEqualTokenDivEqualTokenConcatEqualTokenModEqualTokenAndEqualTokenOrEqualTokenXorEqualTokenSlEqualTokenSrEqualTokenBooleanOrTokenBooleanAndTokenPowTokenSlTokenSrTokenIsIdenticalTokenIsNotIdenticalTokenIsEqualTokenIsNotEqualTokenIsSmallerOrEqualTokenIsGreaterOrEqualTokenCaseSeparatorTokenOpenCurlyBracesTokenCloseCurlyBracesTokenSemiColonTokenColonTokenOpenParenthesisTokenCloseParenthesisTokenOpenSquareBracketCloseSquareBracketQuestionMarkTokenAmpersandTokenMinusTokenPlusTokenCommaTokenVerticalBarTokenEqualTokenCaretTokenAsteriskTokenSlashTokenPercentTokenLessTokenGreaterTokenDotToken"
|
||||
|
||||
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}
|
||||
var _TokenName_index = [...]uint16{0, 9, 16, 26, 39, 60, 81, 92, 107, 122, 129, 143, 156, 166, 180, 190, 202, 217, 233, 257, 283, 299, 312, 326, 341, 356, 371, 381, 389, 397, 416, 429, 443, 457, 472, 485, 498, 511, 527, 540, 553, 565, 578, 590, 602, 616, 631, 639, 646, 653, 669, 688, 700, 715, 736, 757, 775, 795, 816, 830, 840, 860, 881, 898, 916, 933, 947, 957, 966, 976, 992, 1002, 1012, 1025, 1035, 1047, 1056, 1068, 1076}
|
||||
|
||||
func (i TokenName) String() string {
|
||||
if i < 0 || i >= TokenName(len(_TokenName_index)-1) {
|
||||
|
39
php5/php5.go
39
php5/php5.go
@ -348,7 +348,7 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php5/php5.y:6991
|
||||
//line php5/php5.y:6988
|
||||
type simpleIndirectReference struct {
|
||||
all []*expr.Variable
|
||||
last *expr.Variable
|
||||
@ -9345,14 +9345,11 @@ yydefault:
|
||||
// save position
|
||||
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token))
|
||||
|
||||
// save comments
|
||||
yyDollar[1].token.Meta.SetTokenName(meta.NumStringToken).AppendTo(yyVAL.node.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
case 504:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6766
|
||||
//line php5/php5.y:6763
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -9369,7 +9366,7 @@ yydefault:
|
||||
}
|
||||
case 505:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6784
|
||||
//line php5/php5.y:6781
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -9385,7 +9382,7 @@ yydefault:
|
||||
}
|
||||
case 506:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6798
|
||||
//line php5/php5.y:6795
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9401,7 +9398,7 @@ yydefault:
|
||||
}
|
||||
case 507:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6812
|
||||
//line php5/php5.y:6809
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9417,7 +9414,7 @@ yydefault:
|
||||
}
|
||||
case 508:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6826
|
||||
//line php5/php5.y:6823
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -9431,7 +9428,7 @@ yydefault:
|
||||
}
|
||||
case 509:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6838
|
||||
//line php5/php5.y:6835
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -9445,7 +9442,7 @@ yydefault:
|
||||
}
|
||||
case 510:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6850
|
||||
//line php5/php5.y:6847
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -9461,7 +9458,7 @@ yydefault:
|
||||
}
|
||||
case 511:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6864
|
||||
//line php5/php5.y:6861
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -9475,7 +9472,7 @@ yydefault:
|
||||
}
|
||||
case 512:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6876
|
||||
//line php5/php5.y:6873
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -9489,7 +9486,7 @@ yydefault:
|
||||
}
|
||||
case 513:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6891
|
||||
//line php5/php5.y:6888
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -9497,7 +9494,7 @@ yydefault:
|
||||
}
|
||||
case 514:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6897
|
||||
//line php5/php5.y:6894
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -9508,7 +9505,7 @@ yydefault:
|
||||
}
|
||||
case 515:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6909
|
||||
//line php5/php5.y:6906
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9516,7 +9513,7 @@ yydefault:
|
||||
}
|
||||
case 516:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6915
|
||||
//line php5/php5.y:6912
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9524,7 +9521,7 @@ yydefault:
|
||||
}
|
||||
case 517:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6924
|
||||
//line php5/php5.y:6921
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9541,7 +9538,7 @@ yydefault:
|
||||
}
|
||||
case 518:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6939
|
||||
//line php5/php5.y:6936
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9558,7 +9555,7 @@ yydefault:
|
||||
}
|
||||
case 519:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6957
|
||||
//line php5/php5.y:6954
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9575,7 +9572,7 @@ yydefault:
|
||||
}
|
||||
case 520:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6975
|
||||
//line php5/php5.y:6972
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
|
@ -6757,9 +6757,6 @@ encaps_var_offset:
|
||||
// save position
|
||||
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1))
|
||||
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.NumStringToken).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| T_VARIABLE
|
||||
|
34
php7/php7.go
34
php7/php7.go
@ -348,7 +348,7 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php7/php7.y:5464
|
||||
//line php7/php7.y:5456
|
||||
|
||||
//line yacctab:1
|
||||
var yyExca = [...]int{
|
||||
@ -7970,14 +7970,11 @@ yydefault:
|
||||
// save position
|
||||
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition(yyDollar[1].token))
|
||||
|
||||
// save comments
|
||||
yyDollar[1].token.Meta.SetTokenName(meta.NumStringToken).AppendTo(yyVAL.node.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
case 478:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5291
|
||||
//line php7/php7.y:5288
|
||||
{
|
||||
var lnumber *scalar.Lnumber
|
||||
// TODO: add option to handle 64 bit integer
|
||||
@ -8000,17 +7997,12 @@ yydefault:
|
||||
|
||||
// save comments
|
||||
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
|
||||
if isInt {
|
||||
yyDollar[2].token.Meta.SetTokenName(meta.NumStringToken).AppendTo(lnumber.GetMeta())
|
||||
} else {
|
||||
yyDollar[2].token.Meta.SetTokenName(meta.NumStringToken).AppendTo(yyVAL.node.GetMeta())
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
case 479:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5322
|
||||
//line php7/php7.y:5314
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -8027,7 +8019,7 @@ yydefault:
|
||||
}
|
||||
case 480:
|
||||
yyDollar = yyS[yypt-5 : yypt+1]
|
||||
//line php7/php7.y:5340
|
||||
//line php7/php7.y:5332
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -8047,7 +8039,7 @@ yydefault:
|
||||
}
|
||||
case 481:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5358
|
||||
//line php7/php7.y:5350
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -8063,7 +8055,7 @@ yydefault:
|
||||
}
|
||||
case 482:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5372
|
||||
//line php7/php7.y:5364
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -8077,7 +8069,7 @@ yydefault:
|
||||
}
|
||||
case 483:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5384
|
||||
//line php7/php7.y:5376
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -8091,7 +8083,7 @@ yydefault:
|
||||
}
|
||||
case 484:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5396
|
||||
//line php7/php7.y:5388
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -8107,7 +8099,7 @@ yydefault:
|
||||
}
|
||||
case 485:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5410
|
||||
//line php7/php7.y:5402
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -8121,7 +8113,7 @@ yydefault:
|
||||
}
|
||||
case 486:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5422
|
||||
//line php7/php7.y:5414
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -8135,7 +8127,7 @@ yydefault:
|
||||
}
|
||||
case 487:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5437
|
||||
//line php7/php7.y:5429
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -8143,7 +8135,7 @@ yydefault:
|
||||
}
|
||||
case 488:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5443
|
||||
//line php7/php7.y:5435
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -8154,7 +8146,7 @@ yydefault:
|
||||
}
|
||||
case 489:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5455
|
||||
//line php7/php7.y:5447
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
|
@ -5282,9 +5282,6 @@ encaps_var_offset:
|
||||
// save position
|
||||
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokenPosition($1))
|
||||
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.NumStringToken).AppendTo($$.GetMeta())
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| '-' T_NUM_STRING
|
||||
@ -5310,11 +5307,6 @@ encaps_var_offset:
|
||||
|
||||
// save comments
|
||||
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
|
||||
if isInt {
|
||||
$2.Meta.SetTokenName(meta.NumStringToken).AppendTo(lnumber.GetMeta())
|
||||
} else {
|
||||
$2.Meta.SetTokenName(meta.NumStringToken).AppendTo($$.GetMeta())
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
|
@ -1342,6 +1342,7 @@ func TestParseAndPrintPhp5ComplexString1(t *testing.T) {
|
||||
src := `<?php
|
||||
// "test $foo" ;
|
||||
"test $foo[1]" ;
|
||||
"test $foo[112345678901234567890] " ;
|
||||
"test $foo[a]" ;
|
||||
"test $foo[$bar]" ;
|
||||
"test $foo->bar" ;
|
||||
|
@ -1451,6 +1451,9 @@ func TestParseAndPrintComplexString1(t *testing.T) {
|
||||
src := `<?php
|
||||
// "test $foo" ;
|
||||
"test $foo[1]" ;
|
||||
"test $foo[-1]" ;
|
||||
"test $foo[112345678901234567890] " ;
|
||||
"test $foo[-112345678901234567890] " ;
|
||||
"test $foo[a]" ;
|
||||
"test $foo[$bar]" ;
|
||||
"test $foo->bar" ;
|
||||
|
Loading…
Reference in New Issue
Block a user