diff options
author | Camil Staps | 2017-11-22 09:19:47 +0100 |
---|---|---|
committer | Camil Staps | 2017-11-22 09:19:47 +0100 |
commit | e25f34bbaa5f147dcee7b68397de85ffacdf76c3 (patch) | |
tree | df5b8f46855ef00983e942f28d7b09798983aff7 /Yard.dcl | |
parent | Deal with functions using an argument more than once (diff) |
Add parser
Diffstat (limited to 'Yard.dcl')
-rw-r--r-- | Yard.dcl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Yard.dcl b/Yard.dcl new file mode 100644 index 0000000..9e42b22 --- /dev/null +++ b/Yard.dcl @@ -0,0 +1,55 @@ +definition module Yard + +// Taken from https://github.com/dopefishh/cc1516/blob/master/yard.dcl +// To this file, an other license applies: + +/* +The MIT License (MIT) + +Copyright (c) 2016 Pim Jager & Mart Lubbers + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +from StdString import class toString +from Data.Either import :: Either +from StdClass import class ==, class Eq +from Data.Functor import class Functor +from Control.Monad import class Monad +from Control.Applicative import class Applicative, class Alternative +from Data.Void import :: Void + +:: Parser a b = Parser ([a] -> (Either String b, [a])) + +instance Functor (Parser a) +instance Applicative (Parser a) +instance Monad (Parser a) +instance Alternative (Parser a) + +runParser :: (Parser a b) [a] -> (Either String b, [a]) +(<?>) :: (Parser a b) String -> 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 | Eq a +list :: [a] -> Parser a [a] | Eq a +eof :: Parser a Void |