Match bitwise operators in lex

42 Views Asked by At

I am implementing the lexical and syntax analyzer for a c++ like programming language I have the following line in the regular expressions' section in lex file

arithm_op       [/+*%-]
bitwise_op      [&^~|]
punctuators     [()=;{}]

For the following input in the parser file:

int a;
int c;
print(a|c);

The bitwise operator is not matched. The program terminates just before the lex file reaches the '|' symbol in the print statement

I have tried to escape the pipe '|' in the regex but didn't work yet.

0

There are 0 best solutions below