Re: [Haskell-cafe] Expression parsing problem

2009-05-20 Thread leledumbo
Haha... yes, thanks. It was a mistake, I thought I did it too fast. -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23632282.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread Malcolm Wallace
The grammar: expression = get | [ + | - ] term { ( + | - ) term } term = factor { ( * | / ) factor } factor = IDENTIFIER | VALUE | ( expression ) I can't make term parse, for instance 1 * 2 / 3 Indeed, the grammar does not admit 1*2/3 as a sentence of that language although it

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread leledumbo
Indeed, the grammar does not admit 1*2/3 as a sentence ... Huh? Why not? 1 * 2 / 3 should match factor * factor / factor. Remember that { } is repetition, so it should be able to handle such term. expression ::= term | term + expression term ::= factor | factor * term factor ::= constant |

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread Ryan Ingram
Why is Symbol = (String, Token)? A more sensible token type would include values in the Value constructor and string identifiers in the Identifier constructor; the strings in everything else seem redundant. A more pure/monadic parser would have a type like this: data Result a = Error String |

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread leledumbo
Why is Symbol = (String, Token)? A more sensible token type would include values in the Value constructor and string identifiers in the Identifier constructor; the strings in everything else seem redundant. Surely you didn't read my original post, do you? I have a very limited knowledge of

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread Ryan Ingram
Surely you didn't read my original post, do you? I have a very limited knowledge of Monad and I try to find a solution using my current skills because the due date is within two weeks. Therefore, I don't think I can create a Monadic parser for this. I think you're giving up way too easily.

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread leledumbo
I hope you're right. 7 pages... 1-2 nights should be enough. Thanks for all. -- View this message in context: http://www.nabble.com/Expression-parsing-problem-tp23610457p23614011.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

Re: [Haskell-cafe] Expression parsing problem

2009-05-19 Thread Loup Vaillant
Hello, 2009/5/19 leledumbo leledumbo_c...@yahoo.co.id: expression ::= term | term + expression term ::= factor | factor * term factor ::= constant | variable | ( expression ) Oh, left recursion. Well, it should be easy to transform: expression ::= term | moreTerm term ::= factor |