0

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.

2
  • You don't need to escape | inside []. Commented Apr 28, 2023 at 15:23
  • 1
    Not reproducible -- include a minimal reproducible example Commented Apr 28, 2023 at 23:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.