@@ -216,6 +216,12 @@ runParser p = runParserT (junk *> p <* eof) ()
216
216
217
217
-- * Lexical elements
218
218
219
+ --
220
+ -- - Functions which have @parse@ as a prefix simply parse the token
221
+ --
222
+ -- - Functions which have @token@ as a prefix wrap the corresponding @parse@
223
+ -- function with the 'token' function.
224
+
219
225
parseModuleNamePart :: Stream s m Char => Parser s m (ModuleNamePart SourceInfo )
220
226
parseModuleNamePart = withSourceInfo . label' " module part name" $ ModuleNamePart <$> pModuleNamePart
221
227
@@ -391,6 +397,11 @@ parseField :: Stream s m Char => Parser s m (Field SourceInfo)
391
397
parseField = withSourceInfo . label' " record field" $ do
392
398
fn <- tokenFieldName
393
399
_ <- token $ char ' :'
400
+ -- TODO: strictly speaking, there's a bug with this when parsing
401
+ -- > record A a = { fieldName :-- a }
402
+ -- since this will parse the @:--@ as @:@ and @--@ will start a comment.
403
+ -- Technically, the specification says that this should parse as the token
404
+ -- @:-@, and then the remaining @-@ should parse error.
394
405
Field fn <$> parseTyTopLevel
395
406
396
407
parseTyDef :: Stream s m Char => Parser s m (TyDef SourceInfo )
@@ -527,9 +538,11 @@ parseImport = label' "import statement" $ do
527
538
mayNames = fmap snd mayBracketSrcInfoAndNames
528
539
529
540
return $
530
- Import isQual modName mayNames mayModAlias $ -- Get the rightmost position of the rightmost parsed token
541
+ Import isQual modName mayNames mayModAlias $
531
542
srcInfo
532
543
{ to =
544
+ -- Get the rightmost position of the rightmost parsed token
545
+ -- Note: the 'fromJust' clearly never fails.
533
546
fromJust $
534
547
fmap to mayBracketSrcInfo
535
548
<|> ( case mayModAlias of
0 commit comments