Sfoglia il codice sorgente

New: Basic entrypoint

Leonardo Di Donato 8 anni fa
parent
commit
498acf0962
1 ha cambiato i file con 24 aggiunte e 0 eliminazioni
  1. 24 0
      main.go

+ 24 - 0
main.go

@@ -0,0 +1,24 @@
+package main
+
+import (
+	"fmt"
+	"log"
+	"os"
+)
+
+func main() {
+	if len(os.Args) < 2 {
+		name := os.Args[0]
+		fmt.Printf("Usage: %v \"expression\"\n", name)
+		os.Exit(1)
+	}
+	expression := os.Args[1]
+
+	inst := &URN{Buffer: expression}
+	inst.Init()
+	if err := inst.Parse(); err != nil {
+		log.Fatal(err)
+	}
+
+	inst.PrettyPrintSyntaxTree(inst.Buffer)
+}