cgo: implement prefix parsing

This implements expressions such as "-5" and "-5 - 2", in other words,
negative numbers.
This commit is contained in:
Ayke van Laethem
2021-05-20 16:43:22 +02:00
committed by Ron Evans
parent 70f8eeaca0
commit 711889bc3f
4 changed files with 19 additions and 0 deletions
+4
View File
@@ -44,6 +44,10 @@ func TestParseConst(t *testing.T) {
{`(1 - 2) * 3`, `(1 - 2) * 3`},
{`1 * 2 - 3`, `1*2 - 3`},
{`1 * (2 - 3)`, `1 * (2 - 3)`},
// Unary operators.
{`-5`, `-5`},
{`-5-2`, `-5 - 2`},
{`5 - - 2`, `5 - -2`},
} {
fset := token.NewFileSet()
startPos := fset.AddFile("", -1, 1000).Pos(0)