@@ -265,22 +265,45 @@ impl Lexer {
265
265
let ret = keyword ( "return" ) ;
266
266
let assign = just ( '=' ) . padded ( ) ;
267
267
268
+ // obj = ID (prop)+ "="
269
+ // fn = ID (prop | colon_op)
270
+ // prop = (dot_op)+ ("(" | colon_op)
271
+ // dot_op = "." ID
272
+ // colon_op = ":" ID "("
273
+ let colon_op = just ( ':' )
274
+ . ignore_then ( ident ( ) )
275
+ . then_ignore ( just ( '(' ) )
276
+ . map ( Op :: Colon ) ;
277
+
278
+ let dot_op = just ( '.' )
279
+ . ignore_then ( ident ( ) . map ( Op :: Dot ) )
280
+ . repeated ( )
281
+ . at_least ( 1 ) ;
282
+
283
+ let prop = dot_op
284
+ . then ( choice ( ( just ( '(' ) . to ( None ) , colon_op. map ( Some ) ) ) )
285
+ . map ( |( mut props, meth) | {
286
+ if let Some ( x) = meth {
287
+ props. push ( x)
288
+ }
289
+ Op :: Deep ( props)
290
+ } ) ;
291
+
268
292
let dotted = ident ( )
269
- . then ( choice ( ( just ( '.' ) . to ( Kind :: Dot ) , just ( ':' ) . to ( Kind :: Colon ) ) ) )
270
- . then ( ident ( ) )
271
- . map ( |( ( prefix, scope) , name) | ( Some ( prefix) , scope, name) ) ;
293
+ . then ( choice ( ( prop, colon_op) ) )
294
+ . map ( |( prefix, op) | ( prefix, op) ) ;
272
295
273
- let expr = dotted . clone ( ) . then_ignore ( assign) ;
296
+ let expr = ident ( ) . then ( dot_op ) . then_ignore ( assign) ;
274
297
275
298
choice ( (
276
299
triple. ignore_then ( choice ( ( tag, variant, comment. map ( TagType :: Comment ) ) ) ) ,
277
300
func. clone ( )
278
301
. ignore_then ( dotted)
279
- . map ( |( prefix, kind , name ) | TagType :: Func { prefix, name , kind } ) ,
302
+ . map ( |( prefix, op ) | TagType :: Func ( prefix, op ) ) ,
280
303
expr. then ( func. or_not ( ) )
281
- . map ( |( ( prefix, kind , name ) , is_func ) | match is_func {
282
- Some ( _) => TagType :: Func { prefix, name , kind } ,
283
- None => TagType :: Expr { prefix, name , kind } ,
304
+ . map ( |( ( prefix, op ) , is_fn ) | match is_fn {
305
+ Some ( _) => TagType :: Func ( prefix, Op :: Deep ( op ) ) ,
306
+ None => TagType :: Expr ( prefix, Op :: Deep ( op ) ) ,
284
307
} ) ,
285
308
ret. ignore_then ( ident ( ) . padded ( ) )
286
309
. then_ignore ( end ( ) )
0 commit comments