2013-01-01から1ヶ月間の記事一覧

Parsec 大文字・小文字無視 (Case Insensitive)

Parsec より Attoparsec の方が洗練されている気がする。 Attoparsec パッケージには 大文字・小文字の区別をしない stringCI というものがあり、Parsec にはないようだ。 以下、自作版。 {-# LANGUAGE FlexibleContexts #-} module StringCI where import T…

char oneOf noneOf 失敗しても消費しない

Text.Parsec.Char のパーサー char, oneOf, noneOf は下記の例のとおり、 失敗しても入力文字列を消費しない。Prelude> :m + Text.ParsecPrelude Text.Parsec> parseTest (char 'a' <|> char 'b') "b"'b'Prelude Text.Parsec> parseTest (noneOf "abc" <|> o…