26 lines
360 B
Go
26 lines
360 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)
|
|
}
|
|
|
|
ast, err := lexer(string(content))
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
log.Printf("%+#v\n", ast)
|
|
}
|