haskelltokenlexerhappy

how made token of || in alex


I'm new at Haskell and Alex. I'm trying to make tokens of operators in Lexer.x

here is an example of my code

    \<=                           { \s -> TLE       }
    \==                           { \s -> TEQ       }
    \/=                           { \s -> TNEQ      }
    \&&                           { \s -> TAND      }

but when I wrote

    \||                           { \s -> TOR       }

I got a parse error on this line How I should make token for || ?


Solution

  • You can use string literals to prevent escaping all characters, so you can use:

        "||"                           { \s -> TOR       }