Show instances, fixed a bunch of bugs in parsing

- The case / let / indent stuff actually works
- Needed a bunch of defers
- Idris silently builds loops in immediate definitions
This commit is contained in:
2022-09-10 22:10:35 -07:00
parent 39deff1465
commit 1ed884eff9
10 changed files with 305 additions and 55 deletions

View File

@@ -3,26 +3,33 @@ module Main
import Lib.Tokenizer
import Lib.Layout
import Lib.Token
import Lib.Parser.Impl
import Lib.Parser
import Syntax
src = "let x = 1\n y = 2\n in x + y"
check : String -> IO ()
check src = do
putStrLn "--"
printLn $ src
check : Show a => Parser a -> String -> IO ()
check pa src = do
_ <- putStrLn "--"
_ <- putStrLn $ src
let toks = tokenise src
printLn $ toks
let toks2 = layout toks
printLn $ map value toks2
let res = parse pa toks
printLn res
-- let toks2 = layout toks
-- printLn $ map value toks2
-- gotta fix up error messages. Show it with some source
main : IO ()
main = do
-- this stuff is working with layout, should I bother with col.
-- downside is that it will be somewhat picky about the indentation of `in`
-- The sixty stuff looks promising. I might want my own tokenizer though.
check "let x = 1\n y = 2\n in x + y"
check "let x = 1 in x + 2"
check "case x of\n True => something\n False => let\n x = 1\n y = 2\n in x + y"
check letExpr "let x = 1\n y = 2\n in x + y"
check term "let x = 1 in x + 2"
printLn "BREAK"
check term "case x of\n True => something\n False => let\n x = 1\n y = 2\n in x + y"
check term "x + y * z + w"
check term "y * z + w"
check term "x -> y -> z"
check term "x y z"