Writing a Parser with attoparsec that reads from a list of tokens

Hi there! I want to write some small toy language using attoparsec. So I thought, first step tokenize. Let attoparsec consume the input stream and produce a list of tokens. Second step, parse tokens and produce the AST. Using parsec this would be possible easily and is documented. But I want to use attoparsec for this task, because I am interested in attoparsecs capability to have the input in chunks. TIA Norbert

On Fri, 27 Mar 2015 13:31:03 +0100, Norbert Melzer
Hi there!
I want to write some small toy language using attoparsec.
So I thought, first step tokenize. Let attoparsec consume the input stream and produce a list of tokens. Second step, parse tokens and produce the AST.
Using parsec this would be possible easily and is documented. But I want to use attoparsec for this task, because I am interested in attoparsecs capability to have the input in chunks.
You can use the list of reverse dependencies for attoparsec http://packdeps.haskellers.com/reverse/attoparsec to find usage examples. Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

The thing is you can write parsers for tokens, then write parsers that
consume those tokens by exclusively using the token parsers as the building
blocks rather than the raw steam, all using the same combinators and
mechanisms. This is much more flexible.
Ben
On Fri, 27 Mar 2015 at 15:08 Henk-Jan van Tuyl
On Fri, 27 Mar 2015 13:31:03 +0100, Norbert Melzer
wrote: Hi there!
I want to write some small toy language using attoparsec.
So I thought, first step tokenize. Let attoparsec consume the input stream and produce a list of tokens. Second step, parse tokens and produce the AST.
Using parsec this would be possible easily and is documented. But I want to use attoparsec for this task, because I am interested in attoparsecs capability to have the input in chunks.
You can use the list of reverse dependencies for attoparsec http://packdeps.haskellers.com/reverse/attoparsec to find usage examples.
Regards, Henk-Jan van Tuyl
-- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/
http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (3)
-
Benjamin Edwards
-
Henk-Jan van Tuyl
-
Norbert Melzer