Checkpoint some existing changes.
This commit is contained in:
47
src/Main.idr
47
src/Main.idr
@@ -1,18 +1,35 @@
|
||||
module Main
|
||||
|
||||
import Data.String
|
||||
import Lib.Tokenizer
|
||||
import Lib.Layout
|
||||
import Lib.Token
|
||||
import Lib.Parser.Impl
|
||||
import Lib.Parser
|
||||
import Syntax
|
||||
import System
|
||||
import System.File
|
||||
import System.Directory
|
||||
import Control.App
|
||||
|
||||
-- Put stuff in attic
|
||||
-- Error printing
|
||||
-- Review surface syntax
|
||||
-- Prettier printer
|
||||
-- First pass at typecheck
|
||||
-- Just do it in zoo order
|
||||
|
||||
|
||||
-- showPError : String ->
|
||||
|
||||
test : Show a => Parser a -> String -> IO ()
|
||||
test pa src = do
|
||||
_ <- putStrLn "--"
|
||||
_ <- putStrLn $ src
|
||||
let toks = tokenise src
|
||||
putStrLn "- Toks"
|
||||
printLn $ toks
|
||||
putStrLn "- Parse"
|
||||
let res = parse pa toks
|
||||
printLn res
|
||||
-- let toks2 = layout toks
|
||||
@@ -20,11 +37,15 @@ test pa src = do
|
||||
|
||||
-- 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.
|
||||
testFile : String -> IO ()
|
||||
testFile fn = do
|
||||
putStrLn ("***" ++ fn)
|
||||
Right text <- readFile $ "eg/" ++ fn
|
||||
| Left err => printLn err
|
||||
test parseMod text
|
||||
|
||||
olderTests : IO ()
|
||||
olderTests = do
|
||||
test letExpr "let x = 1\n y = 2\n in x + y"
|
||||
test term "let x = 1 in x + 2"
|
||||
printLn "BREAK"
|
||||
@@ -35,3 +56,19 @@ main = do
|
||||
test term "x y z"
|
||||
test parseMod "module Foo\nfoo : Int -> Int\nfoo = \\ x . x"
|
||||
test lamExpr "\\ x . x"
|
||||
test parseMod "module Foo\nimport Foo.Bar\nfoo = 1\n"
|
||||
test parseDef "foo = 1"
|
||||
test parseSig "foo : Bar -> Int"
|
||||
test parseMod "module Test\nid : a -> a\nid = \\ x => x\n"
|
||||
|
||||
foo : Maybe Int -> Int
|
||||
foo Nothing = ?foo_rhs_0
|
||||
foo (Just x) = ?foo_rhs_1
|
||||
|
||||
|
||||
main : IO ()
|
||||
main = do
|
||||
Right files <- listDir "eg"
|
||||
| Left err => printLn err
|
||||
traverse_ testFile (filter (".newt" `isSuffixOf`) files)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user