Created
June 13, 2022 14:02
-
-
Save JordanMartinez/a37247868f0f7aaf3244f8c07fc304f6 to your computer and use it in GitHub Desktop.
Skip Spaces Bug
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
module Main where | |
import Prelude | |
import Control.Alt ((<|>)) | |
import Data.Array as Array | |
import Effect.Console (log) | |
import Effect (Effect) | |
import Parsing as P | |
import Parsing.Combinators as PC | |
import Parsing.String as PS | |
import Parsing.String.Basic as PSB | |
import TryPureScript as TP | |
main :: Effect Unit | |
main = TP.render =<< TP.withConsole do | |
log $ show $ P.runParser content parser | |
content :: String | |
content = Array.intercalate "\n" | |
[ " // ignored line1" | |
, "" | |
, " " | |
, "// ignored line2" | |
, "@value" | |
] | |
parser :: P.Parser String String | |
parser = do | |
void $ PC.many $ (PSB.skipSpaces *> (singleLineComment <|> newline)) | |
PS.string "@" *> PS.string "value" | |
where | |
singleLineComment = PS.string "//" *> untilEndOfLine | |
newline = void $ PS.string "\n" | |
untilEndOfLine = PC.many1 (PS.satisfy (\x -> x /= '\n')) *> newline | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment