Hello,
I am new to ocamllex lexer generators.
I am trying to capture raw string literal in C++ version 11 using ocamllex. [https://en.cppreference.com/w/cpp/language/string_literal]
I am using below regular expression to achieve this:
(['L' 'u' 'U']|""|"u8")? 'R' '"' ([^ '(' ')' '\\' ' ']*) '(' _* ')' ([^ '(' ')' '\\' ' ']*) '"'
But _* is something which is not good. I am not able to capture all the raw literal string from below c++ code.
#include <iostream>
using namespace std;
void testCpp11String1() {
cout << R"-DELIM-(I can write
a multi-line
string ()
")-DELIM-" << endl;
}
void testCpp11String2() {
cout << R"-DELIM-(I can put double quotes like this " " in the string as long as it is not terminated by )delimiter" where delimiter is -DELIM-)-DELIM-" << endl; // there is an odd number of double quotes in this line
}
int main() {
testCpp11String1();
testCpp11String2();
return 0;
}
Please give me some ideas.
Thank you in advance