I'm writing JavaCC parser for a character stream like this
Abc \(Def\) Gh (Ij; Kl); Mno (Pqr)
and should get it tokenized like this
- Abc \(Def\) Gh
- LPAREN
- Ij
- SEMICOLON
- Kl
- RPAREN
- SEMICOLON
- Mno
- LPAREN
- Pqr
- RPAREN
The current token definition is
TOKEN:
{
< WORDCHAR : (~[";", "(", ")"])+ >
| <LPAREN: "(">
| <RPAREN: ")">
| <SEMICOLON: ";">
}
How should I change the WORDCHAR token to include backslash escaped parentheses but not parentheses without leading backslash?