1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build gccgo_examples
19 const expr
= "(6+2*3)/4"
21 // parser.ParseExpr parses the argument and returns the
22 // corresponding ast.Node.
23 node
, err
:= parser
.ParseExpr(expr
)
28 // Create a FileSet for node. Since the node does not come
29 // from a real source file, fset will be empty.
30 fset
:= token
.NewFileSet()
33 err
= format
.Node(&buf
, fset
, node
)
38 fmt
.Println(buf
.String())
40 // Output: (6 + 2*3) / 4