I'm trying to modifying this grammar to parse Solidity comments.
I want to obtain two type of comment: multi-line comment, that is in the form '/* any string */', and the single-line comment, that is in the form '// any string NEWLINE'.
I modified the comments line with the following code:
comment
: '/*' (. | '@' | '\'' | '¯' | '┌' | '┐' | '│' | '└' | '┘' | '─' | '┬' | '├' | '▼' | '►')*? '*/';
LINE_COMMENT
: '//' ~[\r\n]*
;
lineComment
: LINE_COMMENT
;
The first problem is that it seems I have to insert manually several special characters, like '@', using OR, because the wildcard '.' seems not work.
The second is that i'm not able to correctly intercept comment lines like:
/*//////////////////////////////////////////////////////////////
COMMENT
//////////////////////////////////////////////////////////////*/
because the parser doesn't correctly analyze the close character '*/'
.does not match "any character", but matches "any token". Why doe you want to move this from the lexer to the parser?