X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=src%2Fparse.icl;h=0860819c20748b7d5a3b3a523691250172818c6f;hb=6e527e30012f8809594452cb9559b301b4a8afc6;hp=b3046e0ff3e7b13a7265a4f99e774cdb696cdc20;hpb=798defc398c2e3df810cc8fd3dccf861103006a5;p=cc1516.git diff --git a/src/parse.icl b/src/parse.icl index b3046e0..0860819 100644 --- a/src/parse.icl +++ b/src/parse.icl @@ -12,6 +12,7 @@ import Control.Applicative import Data.Func from Data.List import intercalate, replicate, instance Functor [] from Text import class Text(concat), instance Text String +import GenPrint import yard import lex @@ -171,9 +172,10 @@ trans2 t f = satTok t >>= \(_, r).pure (f r) trans1 :: TokenValue a -> Parser Token a trans1 t r = trans2 t $ const r +derive gPrint TokenValue derive gEq TokenValue satTok :: TokenValue -> Parser Token Token -satTok t = satisfy $ eq t +satTok t = top >>= \tok=:(pos, tv) -> if (eq t tok) (return tok) (fail (printToString t, pos)) where eq (IdentToken _) (_, IdentToken _) = True eq (NumberToken _) (_, NumberToken _) = True