Small question here

So I used parseExpr on x+y+z == 890, and it printed:
&{0xc000060270 7 == 0xc00000c140}

What does 7 mean?
And if are these memory addresses? Since I haven’t defined x,y,z as variables, these are null ?

You’re getting an *ast.BinaryExpr. If you take a look at the definition of that struct, you’ll see the 2nd field is “OpPos” of type token.Pos which is a compact encoding of a token’s position in source code. The parser.ParseExpr function’s documentation says that this position is undefined. The addresses are not the addresses of actual values, they’re addresses of other AST nodes. You’ll probably find another *ast.BinaryExpr under the X node of the outermost *ast.BinaryExpr and another under that for ((x+y)+z). I’m not sure what x, y and z will be. Probably *ast.Idents, but I’m not sure what their Object field would be.

1 Like

I see what you mean about the binExprTree. Thanks

Also apparently fmt.Printf("%#v",f) gives details of each token… :smiley:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.