First shot at a lexer.
This commit is contained in:
commit
9ba796161d
2 changed files with 337 additions and 0 deletions
24
mk.go
Normal file
24
mk.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
input, _ := ioutil.ReadAll(os.Stdin)
|
||||
l, tokens := lex(string(input))
|
||||
|
||||
for t := range tokens {
|
||||
if t.typ == tokenError {
|
||||
fmt.Printf("Error: %s", l.errmsg)
|
||||
break
|
||||
}
|
||||
|
||||
fmt.Println(t.String())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue