File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "bufio"
5+ "fmt"
6+ "os"
7+ "os/user"
8+
9+ "github.com/okazaki-kk/miniDB/internal/parser"
10+ "github.com/okazaki-kk/miniDB/internal/parser/lexer"
11+ )
12+
13+ const PROMPT = "miniDB >>"
14+
15+ func main () {
16+ user , err := user .Current ()
17+ if err != nil {
18+ panic (err )
19+ }
20+ fmt .Println ("Hello " + user .Name + "!" )
21+ fmt .Println ("This is the miniDB!" )
22+ fmt .Println ("Feel free to type in commands" )
23+ Start ()
24+ }
25+
26+ func Start () {
27+ scanner := bufio .NewScanner (os .Stdin )
28+
29+ for {
30+ fmt .Print (PROMPT )
31+ scanned := scanner .Scan ()
32+ if ! scanned {
33+ return
34+ }
35+
36+ line := scanner .Text ()
37+ p := parser .New (lexer .New (line ))
38+ stmts , err := p .Parse ()
39+
40+ if err != nil {
41+ fmt .Println (err )
42+ continue
43+ }
44+ fmt .Println (stmts )
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments