Home > OS >  how made token of || in alex
how made token of || in alex

Time:12-26

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 || ?

CodePudding user response:

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

    "||"                           { \s -> TOR       }
  • Related