I have a javaCC rule for identifier_chain (fully qualified name) as:
private void identifier_chain() #Identifier :
{}
{
try {
identifier_part() ( <Colon> identifier_part() )? ( <Period> identifier_part() )*
} catch (ParseException e1) {
if (exception_skip(-1, e1)) {
identifier_chain();
}
} catch (TokenMgrError e2) {
error_skip(-1, e2);
}
}
private void identifier_part() #IdentifierPart :
{
Token valueToken = null;
}
{
valueToken=<DOUBLE_QUOTED_STRING_LITERAL> {
jjtThis.jjtSetValue(valueToken.getValue());
}
}
< DOUBLE_QUOTED_STRING_LITERAL: "\"" (~["\""])* "\"" >
{ matchedToken.value = LiteralUtil.convertFromDoubleQuotedString(image.toString()); }
It successfully works for the identifier_chain (Fully qualified name):
"logicalColumn":"Core"."Dim - AR Payment Terms"."Payment Terms ID"
Note that each part is within a pair of double quotes.
Now I have a case that each individual part can contain one or more double quotes, as in :
"logicalColumn":"Core"."Dim - AR "" Payment Terms"."Payment Terms ID"
where a double-quote (in a part) is escaped with another double-quote as ("")
Failed to write the new rule for this use case.
How about:
< DOUBLE_QUOTED_STRING_LITERAL: "\"" (~["\""] | "\"\"")* "\"" >