elysium/main.go

34 lines
528 B
Go

// The compiler
package main
import (
"log"
"os"
)
func main() {
if len(os.Args) != 2 {
log.Fatalln("Usage: " + os.Args[0] + " <file>")
}
content, err := os.ReadFile(os.Args[1])
if err != nil {
log.Fatalln("Cannot open input file.", err)
}
tokens, err := lexer(string(content))
if err != nil {
log.Fatalln(err)
}
log.Printf("Tokens:\n%+#v\n\n", tokens)
parser := Parser{Tokens: tokens}
parsed, err := parser.parseFile()
if err != nil {
log.Fatalln(err)
}
log.Printf("Parsed:\n%+#v\n\n", parsed)
}