1/*
2Copyright 2017 Google Inc. All rights reserved.
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6	http://www.apache.org/licenses/LICENSE-2.0
7Unless required by applicable law or agreed to in writing, software
8distributed under the License is distributed on an "AS IS" BASIS,
9WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10See the License for the specific language governing permissions and
11limitations under the License.
12*/
13
14package main
15
16import (
17	"fmt"
18	"io/ioutil"
19	"os"
20	"path/filepath"
21
22	"github.com/google/go-jsonnet/internal/dump"
23	"github.com/google/go-jsonnet/internal/program"
24)
25
26func main() {
27	if len(os.Args) != 2 {
28		fmt.Fprintf(os.Stderr, "usage: %s <file>\n", filepath.Base(os.Args[0]))
29		os.Exit(2)
30	}
31	buf, err := ioutil.ReadFile(os.Args[1])
32	if err != nil {
33		panic(err)
34	}
35
36	node, err := program.SnippetToAST("<std>", string(buf))
37	if err != nil {
38		panic(err)
39	}
40
41	dump.Config.HidePrivateFields = false
42	dump.Config.VariableName = "StdAst"
43	dump.Config.VariableDescription = "StdAst is the AST for the standard library."
44	ast := dump.Sdump(node)
45
46	dst := os.Stdout
47	dst.WriteString(header)
48	dst.WriteString(ast)
49}
50
51var header = `
52///////////////////////////////////////////////////////////
53// This file was auto-generated by cmd/dumpstdlibast.go. //
54// https://github.com/google/go-jsonnet#generated-stdlib //
55//                                                       //
56// --------------- DO NOT EDIT BY HAND! ---------------  //
57///////////////////////////////////////////////////////////
58
59package astgen
60
61import (
62	"github.com/google/go-jsonnet/ast"
63)
64
65`[1:]
66