-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow whitespace before world DSL terms!
- Loading branch information
Showing
4 changed files
with
27 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- | | ||
-- SPDX-License-Identifier: BSD-3-Clause | ||
-- | ||
-- Parsing utilities for Swarm. | ||
module Swarm.Util.Parse where | ||
|
||
import Control.Applicative (optional) | ||
import Text.Megaparsec (MonadParsec, eof) | ||
|
||
-- | Run a parser "fully", consuming leading whitespace and ensuring | ||
-- that the parser extends all the way to eof. | ||
fully :: (MonadParsec e s f) => f () -> f a -> f a | ||
fully sc p = sc *> p <* eof | ||
|
||
-- | Run a parser "fully", consuming leading whitespace (including the | ||
-- possibility that the input is nothing but whitespace) and | ||
-- ensuring that the parser extends all the way to eof. | ||
fullyMaybe :: (MonadParsec e s f) => f () -> f a -> f (Maybe a) | ||
fullyMaybe sc = fully sc . optional |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters