From: Mart Lubbers Date: Fri, 26 Feb 2016 13:48:28 +0000 (+0100) Subject: werkt X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=4766205e7035a58c8a1fa1557b6e14577ed26f32;p=cc1516.git werkt --- diff --git a/lex.dcl b/lex.dcl index 438e547..a887374 100644 --- a/lex.dcl +++ b/lex.dcl @@ -1,6 +1,6 @@ definition module lex -import Data.Either +from Data.Either import :: Either :: Token :== (Int, TokenValue) :: TokenValue diff --git a/main.icl b/main.icl index 67ab090..ef5566a 100644 --- a/main.icl +++ b/main.icl @@ -3,15 +3,16 @@ module main import StdFile import StdBool -import lex import parse +import lex //Start :: *World -> (ParserOutput, *World) -Start w -# (out, w) = stdio w -# (toparse, out) = readEntireFile out -# (_, w) = fclose out w -= (lexer toparse, w) +Start = "" +//Start w +//# (out, w) = stdio w +//# (toparse, out) = readEntireFile out +//# (_, w) = fclose out w +//= (lexer toparse, w) /* Start :: *World -> (ParserOutput, *World) Start w diff --git a/main.prj b/main.prj index 5ccec5d..1880ded 100644 --- a/main.prj +++ b/main.prj @@ -84,6 +84,20 @@ OtherModules ReadableABC: False ReuseUniqueNodes: True Fusion: False + Module + Name: yard + Dir: {Project} + Compiler + NeverMemoryProfile: False + NeverTimeProfile: False + StrictnessAnalysis: True + ListTypes: StrictExportTypes + ListAttributes: True + Warnings: True + Verbose: True + ReadableABC: False + ReuseUniqueNodes: True + Fusion: False Module Name: StdArray Dir: {Application}/lib/StdEnv diff --git a/parse.dcl b/parse.dcl index a3640fa..785dfbc 100644 --- a/parse.dcl +++ b/parse.dcl @@ -1,9 +1,10 @@ definition module parse -import lex +from Data.Either import :: Either + +from lex import :: LexerOutput, :: Token, :: TokenValue :: ParserOutput :== Either String AST :: AST = If | While //stub -:: Error = ParseException parse :: LexerOutput -> ParserOutput diff --git a/parse.icl b/parse.icl index 1a7fb85..5551f20 100644 --- a/parse.icl +++ b/parse.icl @@ -1,10 +1,11 @@ implementation module parse import StdString -import yard +import Data.Either +import yard import lex parse :: LexerOutput -> ParserOutput parse (Left e) = Left ("Lexer error: " +++ e) -parse (Right r) = Left "Parser not yet implemented" \ No newline at end of file +parse (Right r) = Left "Parser not yet implemented" diff --git a/yard.dcl b/yard.dcl index 9f40539..a1bb2a3 100644 --- a/yard.dcl +++ b/yard.dcl @@ -6,8 +6,8 @@ from Data.Functor import class Functor from Control.Monad import class Monad from Control.Applicative import class Applicative, class Alternative -:: Parser a b = Parser ([a] -> (Either Error b, [a])) :: Error = ParseException +:: Parser a b = Parser ([a] -> (Either Error b, [a])) runParser :: (Parser a b) [a] -> (Either Error b, [a]) @@ -20,4 +20,4 @@ fail :: Parser a b top :: Parser a a satisfy :: (a -> Bool) -> Parser a a item :: a -> Parser a a | Eq a -list :: [a] -> Parser a [a] | Eq a \ No newline at end of file +list :: [a] -> Parser a [a] | Eq a diff --git a/yard.icl b/yard.icl index 59b4e8c..1443325 100644 --- a/yard.icl +++ b/yard.icl @@ -1,8 +1,9 @@ implementation module yard import StdTuple -from StdClass import Eq +import StdClass import Data.Functor +import Data.Either import Control.Monad import Control.Applicative from Data.Func import $ @@ -44,10 +45,10 @@ top = Parser \i -> case i of [x:xs] = (Right x, xs) satisfy :: (a -> Bool) -> Parser a a -satisfy f = one >>= \r -> if (f r) (return r) fail +satisfy f = top >>= \r -> if (f r) (return r) fail item :: a -> Parser a a | Eq a item a = satisfy ((==)a) list :: [a] -> Parser a [a] | Eq a -list as = mapM item as \ No newline at end of file +list as = mapM item as