Initial commit of lexer
This commit is contained in:
33
lox/lox.go
Normal file
33
lox/lox.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package lox
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
func RunFile(filename string) {
|
||||
bytes, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
lexer := newLexer(string(bytes))
|
||||
lexer.lex()
|
||||
}
|
||||
|
||||
func RunFormat(filename string) {
|
||||
|
||||
}
|
||||
|
||||
func RunPrompt() {
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Split(bufio.ScanLines)
|
||||
fmt.Print("> ")
|
||||
|
||||
for scanner.Scan() {
|
||||
text := scanner.Text()
|
||||
fmt.Printf("Input was: %s\n", text)
|
||||
fmt.Print("> ")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user