@@ -4,12 +4,12 @@ CodeMirror.defineMode("rust", function() {
4
4
"if" : "if-style" , "while" : "if-style" , "else" : "else-style" ,
5
5
"do" : "else-style" , "ret" : "else-style" , "fail" : "else-style" ,
6
6
"break" : "atom" , "cont" : "atom" , "const" : "let" , "resource" : "fn" ,
7
- "let" : "let" , "fn" : "fn" , "for" : "for" , "alt" : "alt" , "obj " : "fn " ,
8
- "lambda " : "fn " , "type" : "type" , "tag" : "tag" , "mod" : "mod" ,
7
+ "let" : "let" , "fn" : "fn" , "for" : "for" , "alt" : "alt" , "iface " : "iface " ,
8
+ "impl " : "impl " , "type" : "type" , "tag" : "tag" , "mod" : "mod" ,
9
9
"as" : "op" , "true" : "atom" , "false" : "atom" , "assert" : "op" , "check" : "op" ,
10
10
"claim" : "op" , "native" : "ignore" , "unsafe" : "ignore" , "import" : "else-style" ,
11
11
"export" : "else-style" , "copy" : "op" , "log" : "op" , "log_err" : "op" ,
12
- "use" : "op" , "bind" : "op"
12
+ "use" : "op" , "bind" : "op" , "self" : "atom"
13
13
} ;
14
14
var typeKeywords = function ( ) {
15
15
var keywords = { "fn" : "fn" , "block" : "fn" , "obj" : "obj" } ;
@@ -169,13 +169,18 @@ CodeMirror.defineMode("rust", function() {
169
169
} ;
170
170
}
171
171
172
+ function stat_of ( comb , tag ) {
173
+ return cont ( pushlex ( "stat" , tag ) , comb , poplex , block ) ;
174
+ }
172
175
function block ( type ) {
173
176
if ( type == "}" ) return cont ( ) ;
174
- if ( type == "let" ) return cont ( pushlex ( "stat" , "let" ) , letdef1 , poplex , block ) ;
175
- if ( type == "fn" ) return cont ( pushlex ( "stat" ) , fndef , poplex , block ) ;
177
+ if ( type == "let" ) return stat_of ( letdef1 , "let" ) ;
178
+ if ( type == "fn" ) return stat_of ( fndef ) ;
176
179
if ( type == "type" ) return cont ( pushlex ( "stat" ) , tydef , endstatement , poplex , block ) ;
177
- if ( type == "tag" ) return cont ( pushlex ( "stat" ) , tagdef , poplex , block ) ;
178
- if ( type == "mod" ) return cont ( pushlex ( "stat" ) , mod , poplex , block ) ;
180
+ if ( type == "tag" ) return stat_of ( tagdef ) ;
181
+ if ( type == "mod" ) return stat_of ( mod ) ;
182
+ if ( type == "iface" ) return stat_of ( iface ) ;
183
+ if ( type == "impl" ) return stat_of ( impl ) ;
179
184
if ( type == "open-attr" ) return cont ( pushlex ( "]" ) , commasep ( expression , "]" ) , poplex ) ;
180
185
if ( type == "ignore" || type . match ( / [ \] \) ; , ] / ) ) return cont ( block ) ;
181
186
return pass ( pushlex ( "stat" ) , expression , poplex , endstatement , block ) ;
@@ -253,11 +258,13 @@ CodeMirror.defineMode("rust", function() {
253
258
return pass ( ) ;
254
259
}
255
260
function fndef ( type ) {
261
+ if ( content == "@" || content == "~" ) { cx . marked = "keyword" ; return cont ( fndef ) ; }
256
262
if ( type == "name" ) { cx . marked = "def" ; return cont ( fndef ) ; }
257
263
if ( content == "<" ) return cont ( typarams , fndef ) ;
258
264
if ( type == "{" ) return pass ( expression ) ;
259
265
if ( type == "(" ) return cont ( pushlex ( ")" ) , commasep ( argdef , ")" ) , poplex , fndef ) ;
260
266
if ( type == "->" ) return cont ( typecx , rtype , valcx , fndef ) ;
267
+ if ( type == ";" ) return cont ( ) ;
261
268
return cont ( fndef ) ;
262
269
}
263
270
function tydef ( type ) {
@@ -284,9 +291,23 @@ CodeMirror.defineMode("rust", function() {
284
291
if ( type == "{" ) return cont ( pushlex ( "}" ) , block , poplex ) ;
285
292
return pass ( ) ;
286
293
}
294
+ function iface ( type ) {
295
+ if ( type == "name" ) { cx . marked = "def" ; return cont ( iface ) ; }
296
+ if ( content == "<" ) return cont ( typarams , iface ) ;
297
+ if ( type == "{" ) return cont ( pushlex ( "}" ) , block , poplex ) ;
298
+ return pass ( ) ;
299
+ }
300
+ function impl ( type ) {
301
+ if ( content == "<" ) return cont ( typarams , impl ) ;
302
+ if ( content == "of" || content == "for" ) { cx . marked = "keyword" ; return cont ( rtype , impl ) ; }
303
+ if ( type == "name" ) { cx . marked = "def" ; return cont ( impl ) ; }
304
+ if ( type == "{" ) return cont ( pushlex ( "}" ) , block , poplex ) ;
305
+ return pass ( ) ;
306
+ }
287
307
function typarams ( type ) {
288
308
if ( content == ">" ) return cont ( ) ;
289
309
if ( content == "," ) return cont ( typarams ) ;
310
+ if ( content == ":" ) return cont ( rtype , typarams ) ;
290
311
return pass ( rtype , typarams ) ;
291
312
}
292
313
function argdef ( type ) {
0 commit comments