z_mirror/luapls
git clone https://git.raiguard.me/z_mirror/luapls
010381d
main
1package repl 2 3import ( 4"encoding/json" 5"fmt" 6 7"github.com/raiguard/luapls/lua/lexer" 8"github.com/raiguard/luapls/lua/parser" 9 10"github.com/chzyer/readline" 11) 12 13func Run () { 14rl ,err := readline .New ("(luapls) " ) 15if err != nil { 16panic (err ) 17 } 18defer rl .Close () 19 20for { 21line ,err := rl .Readline () 22if err != nil { 23break 24 } 25 26fmt .Println ("TOKENS:" ) 27tokens ,_ := lexer .Run (line ) 28for _ ,tok := range tokens { 29fmt .Println (tok .String ()) 30 } 31 32fmt .Println ("AST:" ) 33 34p := parser .New (line ) 35file := p .ParseFile () 36bytes ,_ := json .MarshalIndent (file ,"" ," " ) 37fmt .Println (string (bytes )) 38 } 39}