diff --git a/parse2/grammar.go b/parse2/grammar.go index fb1ea49..a404c97 100644 --- a/parse2/grammar.go +++ b/parse2/grammar.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "io/ioutil" "log" "math" "os" @@ -12,16 +13,23 @@ import ( ) func main() { + bytes, _ := ioutil.ReadAll(os.Stdin) + input := string(bytes) + toml := BuildGrammar() - fmt.Printf("Reading TOML document from STDIN ...\n") + t := profile.Start() //profile.CPUProfile) - result, err := toml.Match(os.Stdin) + var result *tokenize.Result + var err error + for i := 0; i < 10; i++ { + fmt.Printf(".") + result, err = toml.Match(input) + } t.Stop() - fmt.Printf("Completed reading document.\n") + if err != nil { log.Fatalf("Error in parsing TOML: %s\n", err) } else { - fmt.Printf("Result:\n") for i, t := range result.Tokens() { fmt.Printf("[%d] %v\n", i, t) } diff --git a/parse2/parse2 b/parse2/parse2 index 3bac932..790d473 100755 Binary files a/parse2/parse2 and b/parse2/parse2 differ diff --git a/parse2/profile.sh b/parse2/profile.sh index 86a638f..aafb6bc 100755 --- a/parse2/profile.sh +++ b/parse2/profile.sh @@ -9,11 +9,7 @@ #ppfile=` | ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2` -echo "Building ..." go build -echo "Running ..." -time cat long.toml | ./parse2 2>&1 -echo "Profiling ..." -ppfile=`cat long.toml | time ./parse2 2>&1 | grep "cpu profiling enabled" | cut -d, -f2` +ppfile=`cat long.toml | time ./parse2 2>&1 | grep "profiling enabled" | cut -d, -f2` go tool pprof -http 0.0.0.0:8888 ./parse2 $ppfile diff --git a/parse2/short.toml b/parse2/short.toml index 9129f2b..bafc5d9 100644 --- a/parse2/short.toml +++ b/parse2/short.toml @@ -1 +1 @@ -c=[1] +x=1