Skip to content

Instantly share code, notes, and snippets.

@andrevidela
Created March 5, 2019 10:32
Show Gist options
  • Save andrevidela/24ec8dd316df132e4b3cba1c310ce6d9 to your computer and use it in GitHub Desktop.
Save andrevidela/24ec8dd316df132e4b3cba1c310ce6d9 to your computer and use it in GitHub Desktop.
import TParsec
except : (Alternative mn, Monad mn, Inspect (Toks p) (Tok p), Eq (Tok p)) =>
Tok p -> All (Parser mn p (Tok p))
except t = guard (\t' => (t /= t')) anyTok
notChar : (Alternative mn, Monad mn, Subset Char (Tok p), Eq (Tok p), Inspect (Toks p) (Tok p)) =>
Char -> All (Parser mn p (Tok p))
notChar = except . into
skip : Parser mn p a -> Parser mn p ()
skip = ?skiphole
-- skipMany : ???
-- skipMany = ?skipMany_rhs
comments : (Alternative mn, Monad mn, Subset Char (Tok p), Inspect (Toks p) (Tok p), Eq (Tok p)) =>
All (Parser mn p ())
comments = between (char ';') (char '\n') (skipMany $ notChar '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment