@@ -258,17 +258,14 @@ impl Lexer {
258258 . map ( TagType :: Export ) ,
259259 ) ) ) ;
260260
261- let local = keyword ( "local" ) . padded ( ) ;
262261 let func = keyword ( "function" ) . padded ( ) ;
262+ let ret = keyword ( "return" ) ;
263263 let assign = just ( '=' ) . padded ( ) ;
264264
265- let dotted = choice ( (
266- ident ( )
267- . then ( choice ( ( just ( '.' ) . to ( Kind :: Dot ) , just ( ':' ) . to ( Kind :: Colon ) ) ) )
268- . then ( ident ( ) )
269- . map ( |( ( prefix, scope) , name) | ( Some ( prefix) , scope, name) ) ,
270- ident ( ) . map ( |name| ( None , Kind :: Local , name) ) ,
271- ) ) ;
265+ let dotted = ident ( )
266+ . then ( choice ( ( just ( '.' ) . to ( Kind :: Dot ) , just ( ':' ) . to ( Kind :: Colon ) ) ) )
267+ . then ( ident ( ) )
268+ . map ( |( ( prefix, scope) , name) | ( Some ( prefix) , scope, name) ) ;
272269
273270 let expr = dotted. clone ( ) . then_ignore ( assign) ;
274271
@@ -279,29 +276,15 @@ impl Lexer {
279276 newline ( ) . to ( TagType :: Comment ( String :: new ( ) ) ) ,
280277 comment. map ( TagType :: Comment ) ,
281278 ) ) ) ,
282- local. ignore_then ( choice ( (
283- func. clone ( ) . ignore_then ( ident ( ) ) . map ( |name| TagType :: Func {
284- name,
285- prefix : None ,
286- kind : Kind :: Local ,
287- } ) ,
288- ident ( ) . then_ignore ( assign) . map ( |name| TagType :: Expr {
289- name,
290- prefix : None ,
291- kind : Kind :: Local ,
292- } ) ,
293- ) ) ) ,
294279 func. clone ( )
295280 . ignore_then ( dotted)
296281 . map ( |( prefix, kind, name) | TagType :: Func { prefix, name, kind } ) ,
297- choice ( (
298- expr. clone ( )
299- . then_ignore ( func)
300- . map ( |( prefix, kind, name) | TagType :: Func { prefix, name, kind } ) ,
301- expr. map ( |( prefix, kind, name) | TagType :: Expr { prefix, name, kind } ) ,
302- ) ) ,
303- keyword ( "return" )
304- . ignore_then ( ident ( ) . padded ( ) )
282+ expr. then ( func. or_not ( ) )
283+ . map ( |( ( prefix, kind, name) , is_func) | match is_func {
284+ Some ( _) => TagType :: Func { prefix, name, kind } ,
285+ None => TagType :: Expr { prefix, name, kind } ,
286+ } ) ,
287+ ret. ignore_then ( ident ( ) . padded ( ) )
305288 . then_ignore ( end ( ) )
306289 . map ( TagType :: Export ) ,
307290 till_eol. to ( TagType :: Skip ) ,
0 commit comments