From d2b12fdf5681a71f1f6a295b0591e4d8213fb41d Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 10 May 2016 21:12:44 +0200 Subject: Straightforward While lexer, parser and interpreter --- paper/While/Yard.dcl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 paper/While/Yard.dcl (limited to 'paper/While/Yard.dcl') diff --git a/paper/While/Yard.dcl b/paper/While/Yard.dcl new file mode 100644 index 0000000..1fcbfea --- /dev/null +++ b/paper/While/Yard.dcl @@ -0,0 +1,27 @@ +definition module Yard + +// Stolen from https://github.com/dopefishh/cc1516/blob/master/yard.dcl; +// minor changes made to not depend on clean-platform + +from StdString import class toString +from StdClass import class == + +import Common + +:: Parser a b = Parser ([a] -> (Either Error b, [a])) + +instance Functor (Parser a) +instance Applicative (Parser a) +instance Monad (Parser a) +instance Alternative (Parser a) + +runParser :: (Parser a b) [a] -> (Either Error b, [a]) +() :: (Parser a b) Error -> Parser a b +fail :: Parser a b +top :: Parser a a +peek :: Parser a a +satisfy :: (a -> Bool) -> Parser a a +check :: (a -> Bool) -> Parser a a +(until) infix 2 :: (Parser a b) (Parser a c) -> Parser a [b] +item :: a -> Parser a a | == a +list :: [a] -> Parser a [a] | == a -- cgit v1.2.3