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

Parsec --- 2.5 Sequences and separators (3)

sepBy1を使うことで「英語の文」を単語のリストに分解するパーサをsentenceを作ります. word:: Parser String word = many1 (letter <|> digit) sentence:: Parser [String] sentence = do words <- sepBy1 word separator oneOf ".?!" return words separa…

Parsec --- 2.5 Sequences and separators (2)

many/many1はパースしたものを返しますが,パースしたものを返さないskipMany/skipMany1というパーサコンビネータも用意されています. skipMany :: GenParser tok st a -> GenParser tok st () skipMany1 :: GenParser tok st a -> GenParser tok st () |ha…