[refactoring] update ast structure of "Lnumber" and "Dnumber" nodes
This commit is contained in:
parent
7e2965f53b
commit
e3ad9747f4
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -4493,23 +4493,23 @@ ctor_arguments:
|
|||||||
common_scalar:
|
common_scalar:
|
||||||
T_LNUMBER
|
T_LNUMBER
|
||||||
{
|
{
|
||||||
$$ = &ast.ScalarLnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarLnumber{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
// save comments
|
Value: $1.Value,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_DNUMBER
|
| T_DNUMBER
|
||||||
{
|
{
|
||||||
$$ = &ast.ScalarDnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarDnumber{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
// save comments
|
Value: $1.Value,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_CONSTANT_ENCAPSED_STRING
|
| T_CONSTANT_ENCAPSED_STRING
|
||||||
{
|
{
|
||||||
@ -6146,7 +6146,13 @@ encaps_var_offset:
|
|||||||
{
|
{
|
||||||
// TODO: add option to handle 64 bit integer
|
// TODO: add option to handle 64 bit integer
|
||||||
if _, err := strconv.Atoi(string($1.Value)); err == nil {
|
if _, err := strconv.Atoi(string($1.Value)); err == nil {
|
||||||
$$ = &ast.ScalarLnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarLnumber{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$$ = &ast.ScalarString{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarString{ast.Node{}, $1.Value}
|
||||||
}
|
}
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -3940,23 +3940,23 @@ dereferencable_scalar:
|
|||||||
scalar:
|
scalar:
|
||||||
T_LNUMBER
|
T_LNUMBER
|
||||||
{
|
{
|
||||||
$$ = &ast.ScalarLnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarLnumber{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
// save comments
|
Value: $1.Value,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_DNUMBER
|
| T_DNUMBER
|
||||||
{
|
{
|
||||||
$$ = &ast.ScalarDnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarDnumber{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewTokenPosition($1),
|
||||||
$$.GetNode().Position = position.NewTokenPosition($1)
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
// save comments
|
Value: $1.Value,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
}
|
}
|
||||||
| T_LINE
|
| T_LINE
|
||||||
{
|
{
|
||||||
@ -4785,7 +4785,13 @@ encaps_var_offset:
|
|||||||
{
|
{
|
||||||
// TODO: add option to handle 64 bit integer
|
// TODO: add option to handle 64 bit integer
|
||||||
if _, err := strconv.Atoi(string($1.Value)); err == nil {
|
if _, err := strconv.Atoi(string($1.Value)); err == nil {
|
||||||
$$ = &ast.ScalarLnumber{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarLnumber{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($1),
|
||||||
|
},
|
||||||
|
NumberTkn: $1,
|
||||||
|
Value: $1.Value,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$$ = &ast.ScalarString{ast.Node{}, $1.Value}
|
$$ = &ast.ScalarString{ast.Node{}, $1.Value}
|
||||||
}
|
}
|
||||||
@ -4798,13 +4804,17 @@ encaps_var_offset:
|
|||||||
}
|
}
|
||||||
| '-' T_NUM_STRING
|
| '-' T_NUM_STRING
|
||||||
{
|
{
|
||||||
var lnumber *ast.ScalarLnumber
|
|
||||||
// TODO: add option to handle 64 bit integer
|
|
||||||
_, err := strconv.Atoi(string($2.Value));
|
_, err := strconv.Atoi(string($2.Value));
|
||||||
isInt := err == nil
|
isInt := err == nil
|
||||||
|
|
||||||
if isInt {
|
if isInt {
|
||||||
lnumber = &ast.ScalarLnumber{ast.Node{}, $2.Value}
|
lnumber := &ast.ScalarLnumber{
|
||||||
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokenPosition($2),
|
||||||
|
},
|
||||||
|
NumberTkn: $2,
|
||||||
|
Value: $2.Value,
|
||||||
|
}
|
||||||
$$ = &ast.ExprUnaryMinus{ast.Node{}, lnumber}
|
$$ = &ast.ExprUnaryMinus{ast.Node{}, lnumber}
|
||||||
} else {
|
} else {
|
||||||
$2.Value = append([]byte("-"), $2.Value...)
|
$2.Value = append([]byte("-"), $2.Value...)
|
||||||
@ -4812,9 +4822,6 @@ encaps_var_offset:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save position
|
// save position
|
||||||
if isInt {
|
|
||||||
lnumber.GetNode().Position = position.NewTokensPosition($1, $2)
|
|
||||||
}
|
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $2)
|
$$.GetNode().Position = position.NewTokensPosition($1, $2)
|
||||||
|
|
||||||
// save comments
|
// save comments
|
||||||
|
@ -115,7 +115,8 @@ func (n *Argument) Accept(v NodeVisitor) {
|
|||||||
// ScalarDnumber node
|
// ScalarDnumber node
|
||||||
type ScalarDnumber struct {
|
type ScalarDnumber struct {
|
||||||
Node
|
Node
|
||||||
Value []byte
|
NumberTkn *token.Token
|
||||||
|
Value []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *ScalarDnumber) Accept(v NodeVisitor) {
|
func (n *ScalarDnumber) Accept(v NodeVisitor) {
|
||||||
@ -156,7 +157,8 @@ func (n *ScalarHeredoc) Accept(v NodeVisitor) {
|
|||||||
// ScalarLnumber node
|
// ScalarLnumber node
|
||||||
type ScalarLnumber struct {
|
type ScalarLnumber struct {
|
||||||
Node
|
Node
|
||||||
Value []byte
|
NumberTkn *token.Token
|
||||||
|
Value []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *ScalarLnumber) Accept(v NodeVisitor) {
|
func (n *ScalarLnumber) Accept(v NodeVisitor) {
|
||||||
|
Loading…
Reference in New Issue
Block a user