-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `astcatalog` and use it in `ast-gen-pos` It also fixes some errors in `ast` docs. * Fix to handle const types correctly * Add ByteType * Update tool usages
- Loading branch information
1 parent
d885fe3
commit 7a98aad
Showing
7 changed files
with
499 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/MakeNowJust/heredoc/v2" | ||
"github.com/cloudspannerecosystem/memefish/tools/util/astcatalog" | ||
"github.com/k0kubun/pp/v3" | ||
) | ||
|
||
var usage = heredoc.Doc(` | ||
Usage of tools/astcatalog | ||
An utility to show the AST catalog. | ||
Example: | ||
$ go run ./tools/astcatalog/main.go -astfile ast/ast.go -constfile ast/ast_const.go | ||
Print the AST catalog of ast/ast.go and ast/ast_const.go. | ||
Flags: | ||
`) | ||
|
||
var ( | ||
astfile = flag.String("astfile", "ast/ast.go", "path to ast/ast.go") | ||
constfile = flag.String("constfile", "ast/ast_const.go", "path to ast/ast_const.go") | ||
) | ||
|
||
func main() { | ||
flag.Usage = func() { | ||
fmt.Print(usage) | ||
flag.PrintDefaults() | ||
} | ||
|
||
flag.Parse() | ||
|
||
catalog, err := astcatalog.Load(*astfile, *constfile) | ||
if err != nil { | ||
log.Fatalf("failed to load: %v", err) | ||
} | ||
pprinter := pp.New() | ||
pprinter.SetOmitEmpty(true) | ||
_, _ = pprinter.Println(catalog) | ||
} |
Oops, something went wrong.