File tree 2 files changed +14
-9
lines changed
grammars/org/antlr/intellij/plugin/parser
java/org/antlr/intellij/plugin
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -103,19 +103,15 @@ tokens {
103
103
}
104
104
105
105
DOC_COMMENT
106
- : ' /**' .*? ' */'
106
+ : ' /**' .*? ( ' */' | EOF )
107
107
;
108
108
109
109
BLOCK_COMMENT
110
- : ' /*' .*? ' */' // -> channel(HIDDEN)
110
+ : ' /*' .*? ( ' */' | EOF ) -> channel(HIDDEN )
111
111
;
112
112
113
113
LINE_COMMENT
114
- : ' //' ~[\r\n]* // -> channel(HIDDEN)
115
- ;
116
-
117
- DOUBLE_QUOTE_STRING_LITERAL
118
- : ' "' (' \\ ' . | ~' "' )*? ' "'
114
+ : ' //' ~[\r\n]* -> channel(HIDDEN )
119
115
;
120
116
121
117
BEGIN_ARG_ACTION
@@ -209,7 +205,11 @@ INT : [0-9]+
209
205
// may contain unicode escape sequences of the form \uxxxx, where x
210
206
// is a valid hexadecimal number (as per Java basically).
211
207
STRING_LITERAL
212
- : ' \' ' (ESC_SEQ | ~[' \\ ])* ' \' '
208
+ : ' \' ' (ESC_SEQ | ~[' \r\n\\ ])* ' \' '
209
+ ;
210
+
211
+ UNTERMINATED_STRING_LITERAL
212
+ : ' \' ' (ESC_SEQ | ~[' \r\n\\ ])*
213
213
;
214
214
215
215
// Any kind of escaped character that we can embed within ANTLR
@@ -221,6 +221,10 @@ ESC_SEQ
221
221
[btnfr"' \\]
222
222
| // A Java style Unicode escape sequence
223
223
UNICODE_ESC
224
+ | // Invalid escape
225
+ .
226
+ | // Invalid escape at end of file
227
+ EOF
224
228
)
225
229
;
226
230
Original file line number Diff line number Diff line change @@ -65,7 +65,8 @@ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
65
65
else if ( tokenType == ANTLRv4TokenTypes .TOKEN_ELEMENT_TYPES .get (ANTLRv4Lexer .RULE_REF ) ) {
66
66
return new TextAttributesKey []{RULENAME };
67
67
}
68
- else if (tokenType == ANTLRv4TokenTypes .TOKEN_ELEMENT_TYPES .get (ANTLRv4Lexer .STRING_LITERAL )) {
68
+ else if (tokenType == ANTLRv4TokenTypes .TOKEN_ELEMENT_TYPES .get (ANTLRv4Lexer .STRING_LITERAL )
69
+ || tokenType == ANTLRv4TokenTypes .TOKEN_ELEMENT_TYPES .get (ANTLRv4Lexer .UNTERMINATED_STRING_LITERAL )) {
69
70
return STRING_KEYS ;
70
71
}
71
72
else if (tokenType == ANTLRv4TokenTypes .TOKEN_ELEMENT_TYPES .get (ANTLRv4Lexer .BLOCK_COMMENT )) {
You can’t perform that action at this time.
0 commit comments