Question

I am compiling on Windows using GHC. Here is my code for reference http://hpaste.org/86539

The problem is that the following expression does not parse: 3+2 < 1+-4 <= -3 << 1. It should parse as:

enter image description here

.. however, I get unexpected - when it is clearly the highest operator. I suspect it's because of my usage of try on line 55, however without it < and << and operators that are repetitions of one symbol do not parse correctly.

I am seeking advice or hints.

Was it helpful?

Solution

The problem is on line 56:

P.lexeme <$ string s

Should read:

P.lexeme gmlLexer $ string s

The former construct was matching s, then returning the function P.lexeme as the result of the parse! The subsequent >> threw the result away, hence it type checked.

What you wanted to do was the later line: Apply the P.lexeme for your language gmlLexer to the parser for matching s.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top