aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-11-22 14:45:55 -0800
committerChristine Dodrill <me@christine.website>2018-11-22 14:45:55 -0800
commit10effa476ed74e4b8a7709f681966ef0918cbab3 (patch)
treecb1fe98da3d7291d0860decca080cf3c63068737
parenta8bc837d3858b82d9b65ca7f1718bc44ab1311fd (diff)
downloadx-10effa476ed74e4b8a7709f681966ef0918cbab3.tar.xz
x-10effa476ed74e4b8a7709f681966ef0918cbab3.zip
jbo/la banbixicns: mi sabji lo tricu je lo .braxes.
-rw-r--r--jbo/la-banbixsicns/main.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/jbo/la-banbixsicns/main.go b/jbo/la-banbixsicns/main.go
index 07cd77d..c05e79d 100644
--- a/jbo/la-banbixsicns/main.go
+++ b/jbo/la-banbixsicns/main.go
@@ -9,6 +9,7 @@ import (
"github.com/eaburns/johaus/parser"
_ "github.com/eaburns/johaus/parser/camxes"
+ "github.com/eaburns/johaus/pretty"
_ "github.com/joho/godotenv/autoload"
)
@@ -21,10 +22,34 @@ func main() {
}
log.Printf("Listening on http://0.0.0.0:%s", p)
- http.ListenAndServe(":"+p, http.HandlerFunc(handle))
+
+ http.DefaultServeMux.HandleFunc("/tree", tree)
+ http.DefaultServeMux.HandleFunc("/braces", braces)
+
+ http.ListenAndServe(":"+p, nil)
}
-func handle(w http.ResponseWriter, r *http.Request) {
+func braces(w http.ResponseWriter, r *http.Request) {
+ data, err := ioutil.ReadAll(r.Body)
+ if err != nil {
+ http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ tree, err := parser.Parse(dialect, string(data))
+ if err != nil {
+ http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ parser.RemoveMorphology(tree)
+ parser.AddElidedTerminators(tree)
+ parser.RemoveSpace(tree)
+ parser.CollapseLists(tree)
+
+ pretty.Braces(w, tree)
+}
+func tree(w http.ResponseWriter, r *http.Request) {
data, err := ioutil.ReadAll(r.Body)
if err != nil {
http.Error(w, "can't parse: "+err.Error(), http.StatusBadRequest)