Skip to content

Commit 45588d8

Browse files
committed
---
yaml --- r: 124924 b: refs/heads/auto c: 76a1552 h: refs/heads/master v: v3
1 parent 0be0d23 commit 45588d8

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 1a1a9d54456355cc0ebdd397fd04871abe27f78c
16+
refs/heads/auto: 76a15520212b1b9a72c099e0a163a31c102fcde4
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/grammar/RustLexer.g4

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
lexer grammar RustLexer;
22

3+
tokens {
4+
EQ, LT, LE, EQEQ, NE, GE, GT, ANDAND, OROR, NOT, TILDE, PLUT,
5+
MINUS, STAR, SLASH, PERCENT, CARET, AND, OR, SHL, SHR, BINOP,
6+
BINOPEQ, AT, DOT, DOTDOT, DOTDOTDOT, COMMA, SEMI, COLON,
7+
MOD_SEP, RARROW, FAT_ARROW, LPAREN, RPAREN, LBRACKET, RBRACKET,
8+
LBRACE, RBRACE, POUND, DOLLAR, UNDERSCORE, LIT_CHAR,
9+
LIT_INTEGER, LIT_FLOAT, LIT_STR, LIT_STR_RAW, LIT_BINARY,
10+
LIT_BINARY_RAW, IDENT, LIFETIME, WHITESPACE, DOC_COMMENT,
11+
COMMENT
12+
}
13+
314
/* Note: due to antlr limitations, we can't represent XID_start and
415
* XID_continue properly. ASCII-only substitute. */
516

617
fragment XID_start : [_a-zA-Z] ;
718
fragment XID_continue : [_a-zA-Z0-9] ;
819

20+
921
/* Expression-operator symbols */
1022

1123
EQ : '=' ;
@@ -83,7 +95,7 @@ LIT_CHAR
8395
: '\'' ( '\\' CHAR_ESCAPE | ~[\\'\n\t\r] ) '\''
8496
;
8597

86-
INT_SUFFIX
98+
fragment INT_SUFFIX
8799
: 'i'
88100
| 'i8'
89101
| 'i16'
@@ -141,25 +153,28 @@ LIFETIME : '\'' IDENT ;
141153

142154
WHITESPACE : [ \r\n\t]+ ;
143155

144-
COMMENT
145-
: '//' ~[\r\n]*
146-
| '////' ~[\r\n]*
147-
| BLOCK_COMMENT
148-
;
156+
LINE_COMMENT_NOT_A_TOKEN : '//' -> more, pushMode(LINE_COMMENT) ;
149157

150-
mode DOCCOMMENT;
151158

152-
fragment DOC_BLOCK_COMMENT
153-
: ('/**' | '/*!') (DOC_BLOCK_COMMENT | .)*? '*/'
159+
DOC_BLOCK_COMMENT
160+
: ('/**' | '/*!') (DOC_BLOCK_COMMENT | .)*? '*/' -> type(DOC_COMMENT)
154161
;
155162

156-
DOC_COMMENT
157-
: '///' ~[\r\n]*
158-
| '//!' ~[\r\n]*
159-
| DOC_BLOCK_COMMENT
163+
BLOCK_COMMENT : '/*' (BLOCK_COMMENT | .)*? '*/' -> type(COMMENT) ;
164+
165+
mode LINE_COMMENT;
166+
167+
MAYBE_DOC_COMMENT
168+
: '/' -> more, pushMode(LINE_DOC_COMMENT)
160169
;
161170

162-
fragment BLOCK_COMMENT
163-
: '/*' (BLOCK_COMMENT | .)*? '*/'
171+
MAYBE_OUTER_DOC_COMMENT
172+
: '!' ~[\r\n]* -> type(LINE_DOC_COMMENT), popMode
164173
;
165174

175+
COMMENT : ~[\r\n]* -> popMode ;
176+
177+
mode LINE_DOC_COMMENT;
178+
179+
ACTUALLY_A_COMMENT : '/' ~[\r\n]* -> type(COMMENT), popMode ;
180+
REALLY_A_DOC_COMMENT : ~[\r\n]* -> type(DOC_COMMENT), popMode ;

0 commit comments

Comments
 (0)