Skip to content

Instantly share code, notes, and snippets.

@Xe
Last active February 3, 2019 16:00
Show Gist options
  • Save Xe/e6d00d250e34c55229c4525d6b9b3242 to your computer and use it in GitHub Desktop.
Save Xe/e6d00d250e34c55229c4525d6b9b3242 to your computer and use it in GitHub Desktop.
~/go/src/github.com/Xe/johaus:master? λ time GOOS=js GOARCH=wasm go1.12beta2 build -o johaus.wasm wasm_main.go
0.372 secs
~/go/src/github.com/Xe/johaus:master? λ time go_js_wam_exec johaus.wasm
parsed in 187.348ms
(ni'o ((ti melbi) (i (((la jo'aus) cu) (jimpe (le (gerna (be (le jbobau)))))))))
text_eof
├────NIhO["ni'o"]
└────paragraph
├──sentence
│ ├────KOhA["ti"]
│ └────BRIVLA["melbi"]
└──────┐
├────I["i"]
└────sentence
├────────┐
│ ├──────sumti_6
│ │ ├──LA["la"]
│ │ └──CMEVLA["jo'aus"]
│ └──────CU["cu"]
└──bridi_tail_3
├──────BRIVLA["jimpe"]
└──────sumti_6
├───LE["le"]
└───tanru_unit_1
├──BRIVLA["gerna"]
└──linkargs_1
├───BE["be"]
└───sumti_6
├──LE["le"]
└──BRIVLA["jbobau"]
7.248 secs
~/go/src/github.com/Xe/johaus:master? λ time go1.12beta2 run wasm_main.go
parsed in 2.724521ms
(ni'o [{ti melbi} {i <([la jo'aus] cu) (jimpe [le {gerna <be (le jbobau)>}])>}])
text_eof
├────NIhO["ni'o"]
└────paragraph
├──sentence
│ ├────KOhA["ti"]
│ └────BRIVLA["melbi"]
└──────┐
├────I["i"]
└────sentence
├────────┐
│ ├──────sumti_6
│ │ ├──LA["la"]
│ │ └──CMEVLA["jo'aus"]
│ └──────CU["cu"]
└──bridi_tail_3
├──────BRIVLA["jimpe"]
└──────sumti_6
├───LE["le"]
└───tanru_unit_1
├──BRIVLA["gerna"]
└──linkargs_1
├───BE["be"]
└───sumti_6
├──LE["le"]
└──BRIVLA["jbobau"]
1.119 secs
// +build ignore
package main
import (
"fmt"
"os"
"time"
"within.website/johaus/parser"
"within.website/johaus/pretty"
// Register camxes in init().
_ "within.website/johaus/parser/camxes"
)
var (
dialect = "camxes"
keepMorph = false
addTerminators = false
)
const (
papri = `ni'o ti melbi .i la jo'aus cu jimpe le gerna be le jbobau`
)
func main() {
begin := time.Now()
tree, err := parser.Parse(dialect, papri)
fmt.Println("parsed in", time.Since(begin))
if err != nil {
err.(*parser.Error).FilePath = "papri"
fmt.Println(err)
os.Exit(1)
}
if !keepMorph {
parser.RemoveMorphology(tree)
}
if addTerminators {
parser.AddElidedTerminators(tree)
}
parser.RemoveSpace(tree)
parser.CollapseLists(tree)
pretty.Braces(os.Stdout, tree)
fmt.Println("")
pretty.Tree(os.Stdout, tree)
fmt.Println("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment