Skip to content

Commit aa08249

Browse files
committed
Grammar cleanup
* Use 'PartialTypeSignatures' instead of type variables for parametrized productions * Add signature to 'binding'
1 parent 4e3191d commit aa08249

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Language/Rust/Parser/Internal.y

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To get information about transition states and such, run
2424
[2]: https://doc.rust-lang.org/grammar.html
2525
-}
2626
{-# OPTIONS_HADDOCK hide, not-home #-}
27-
{-# LANGUAGE OverloadedStrings, OverloadedLists #-}
27+
{-# LANGUAGE OverloadedStrings, OverloadedLists, PartialTypeSignatures #-}
2828

2929
module Language.Rust.Parser.Internal (
3030
parseLit, parseAttr, parseTy, parsePat, parseStmt, parseExpr, parseItem, parseSourceFile,
@@ -325,33 +325,33 @@ gt :: { () }
325325
-------------
326326

327327
-- | One or more occurences of 'p'
328-
some(p) :: { Reversed NonEmpty a }
328+
some(p) :: { Reversed NonEmpty _ }
329329
: some(p) p { let Reversed xs = $1 in Reversed ($2 <| xs) }
330330
| p { [$1] }
331331

332332
-- | Zero or more occurences of 'p'
333-
many(p) :: { [a] }
333+
many(p) :: { [_] }
334334
: some(p) { toList $1 }
335335
| {- empty -} { [] }
336336

337337
-- | One or more occurences of 'p', seperated by 'sep'
338-
sep_by1(p,sep) :: { Reversed NonEmpty a }
338+
sep_by1(p,sep) :: { Reversed NonEmpty _ }
339339
: sep_by1(p,sep) sep p { let Reversed xs = $1 in Reversed ($3 <| xs) }
340340
| p { [$1] }
341341

342342
-- | Zero or more occurrences of 'p', separated by 'sep'
343-
sep_by(p,sep) :: { [a] }
343+
sep_by(p,sep) :: { [ _ ] }
344344
: sep_by1(p,sep) { toList $1 }
345345
| {- empty -} { [] }
346346

347347
-- | One or more occurrences of 'p', seperated by 'sep', optionally ending in 'sep'
348-
sep_by1T(p,sep) :: { Reversed NonEmpty a }
348+
sep_by1T(p,sep) :: { Reversed NonEmpty _ }
349349
: sep_by1(p,sep) sep { $1 }
350350
| sep_by1(p,sep) { $1 }
351351

352352
-- | Zero or more occurences of 'p', seperated by 'sep', optionally ending in 'sep' (only if there
353353
-- is at least one 'p')
354-
sep_byT(p,sep) :: { [a] }
354+
sep_byT(p,sep) :: { [ _ ] }
355355
: sep_by1T(p,sep) { toList $1 }
356356
| {- empty -} { [] }
357357

@@ -361,7 +361,7 @@ sep_byT(p,sep) :: { [a] }
361361
--------------------------
362362

363363
-- shebang is dealt with at the top level, outside Happy/Alex
364-
source_file :: { ([Attribute a],[Item a]) }
364+
source_file :: { ([Attribute Span],[Item Span]) }
365365
: inner_attrs many(mod_item) { (toList $1, $2) }
366366
| many(mod_item) { ([], $1) }
367367

@@ -449,7 +449,8 @@ generic_values :: { Spanned ([Lifetime Span], [Ty Span], [(Ident, Ty Span)]) }
449449
| lt_ty_qual_path ',' sep_by1T(binding,',') gt '>' { Spanned ([], [unspan $1],toList $3) ($1 # $>) }
450450
| lt_ty_qual_path gt '>' { Spanned ([], [unspan $1],[] ) ($1 # $>) }
451451

452-
binding : ident '=' ty { (unspan $1, $3) }
452+
binding :: { (Ident, Ty Span) }
453+
: ident '=' ty { (unspan $1, $3) }
453454

454455

455456
-- Type related:

0 commit comments

Comments
 (0)