X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=src%2Fparse.icl;h=f57c5e536c22934cf438c374ed1907b436c7d63d;hb=3944a17b55128c2b75bf1948bbf0561a4b6ca783;hp=0f0f42c4dd3e97e4aba44ec5ea9dab232de7b132;hpb=1e30f02a706b29dae471b6526e7fd0e4bf5bf483;p=cc1516.git diff --git a/src/parse.icl b/src/parse.icl index 0f0f42c..f57c5e5 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 @@ -172,9 +173,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 tv, pos)) where eq (IdentToken _) (_, IdentToken _) = True eq (NumberToken _) (_, NumberToken _) = True