2014-08-05 16:17:40 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2015-10-26 16:09:07 -04:00
|
|
|
"github.com/docker/docker/builder/dockerfile/parser"
|
2014-08-05 16:17:40 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var f *os.File
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if len(os.Args) < 2 {
|
|
|
|
fmt.Println("please supply filename(s)")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, fn := range os.Args[1:] {
|
|
|
|
f, err = os.Open(fn)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2016-06-27 16:20:47 -04:00
|
|
|
d := parser.Directive{LookingForDirectives: true}
|
|
|
|
parser.SetEscapeToken(parser.DefaultEscapeToken, &d)
|
|
|
|
|
|
|
|
ast, err := parser.Parse(f, &d)
|
2014-08-05 16:17:40 -04:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
} else {
|
2014-08-29 15:49:16 -04:00
|
|
|
fmt.Println(ast.Dump())
|
2014-08-05 16:17:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|