From 78d78ff74fb37b55952f16959bb884c1696e3edb Mon Sep 17 00:00:00 2001 From: Jesse Donat Date: Sun, 17 Jun 2018 21:16:05 -0500 Subject: [PATCH 1/3] Corrects README example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b998659..5b92b65 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ nodes := &stmt.StmtList{ file := os.Stdout p := printer.NewPrinter(file, " ") -p.PrintFile(nodes) +p.Print(nodes) ``` It prints to stdout: From 10c63a30ae6a55e03abb29eebc28247001484c29 Mon Sep 17 00:00:00 2001 From: z7zmey Date: Tue, 26 Jun 2018 11:57:17 +0300 Subject: [PATCH 2/3] #44: fix crash on an empty list item --- node/expr/t_list_test.go | 32 +++++++++++++ php5/parser.go | 3 ++ php5/php5.go | 99 +++++++++++++++++++++------------------- php5/php5.y | 8 +++- php7/parser.go | 3 ++ php7/php7.go | 70 ++++++++++++++-------------- php7/php7.y | 4 +- 7 files changed, 137 insertions(+), 82 deletions(-) diff --git a/node/expr/t_list_test.go b/node/expr/t_list_test.go index ecdabbd..de00d55 100644 --- a/node/expr/t_list_test.go +++ b/node/expr/t_list_test.go @@ -141,3 +141,35 @@ func TestListList(t *testing.T) { actual = php5parser.GetRootNode() assertEqual(t, expected, actual) } + +func TestListEmptyItem(t *testing.T) { + src := ` Date: Tue, 26 Jun 2018 12:22:51 +0300 Subject: [PATCH 3/3] #44: do not trim last nil if array item list ends by a comma --- node/expr/t_array_test.go | 1 + node/expr/t_list_test.go | 34 ++++++++++++++ node/expr/t_short_array_test.go | 1 + php5/php5.go | 82 +++++++++++++++++---------------- php5/php5.y | 4 ++ php5/php5_test.go | 2 + php7/php7.go | 4 +- php7/php7.y | 4 +- php7/php7_test.go | 2 + 9 files changed, 91 insertions(+), 43 deletions(-) diff --git a/node/expr/t_array_test.go b/node/expr/t_array_test.go index 99d997a..2a8f5d4 100644 --- a/node/expr/t_array_test.go +++ b/node/expr/t_array_test.go @@ -81,6 +81,7 @@ func TestArrayItems(t *testing.T) { &expr.ArrayItem{ Val: &expr.Reference{Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}}}, }, + nil, }, }, }, diff --git a/node/expr/t_list_test.go b/node/expr/t_list_test.go index de00d55..8d362ac 100644 --- a/node/expr/t_list_test.go +++ b/node/expr/t_list_test.go @@ -173,3 +173,37 @@ func TestListEmptyItem(t *testing.T) { actual = php5parser.GetRootNode() assertEqual(t, expected, actual) } + +func TestListEmptyItems(t *testing.T) { + src := `