Initial commit of lexer

This commit is contained in:
2022-01-12 10:44:45 +01:00
parent 8c79f0f9a5
commit 80efeb1c7d
7 changed files with 373 additions and 0 deletions

33
lox/lox.go Normal file
View 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("> ")
}
}