Open stephen-smith opened 1 month ago
Can vanilla Idris parse multiline comments?
To my surprise: No, at least not version 0.7.0-53f448c0d.
% idris2 --build okasaki-pfds.ipkg
Uncaught error: Error: Can't recognise token.
"okasaki-pfds.ipkg":3:1--3:2
1 | package okasaki-pfds
2 |
3 | {-
^
So, I guess this is more of an Idris2 documentation bug.
Multi line comments are supported and have at least at times worked so this is a compiler bug rather than a documentation bug. Worth fixing I’m guessing at least for idr files if not ipkg files. Of course if we can’t fix it for ipkg files then we absolutely should fix the docs.
Worth fixing I’m guessing at least for idr files if not ipkg files
Multiline commens worth perfectly fine in .idr files:
% idris2 -c Queue.idr
1/1: Building Queue (Queue.idr)
bss@monster % cat Queue.idr
module Queue
{-
- Testing multiline
- -}
%default total
...
This is just about ipkg files, which seem to only handle comments in the lexer, and only using the Parser.Lexer.Common.comment form which is only good for single-line comments (though it does refuse to match multiline comment closing).
I do think adding multiline comment support to ipkg would be nice.
Oh yeah, I misunderstood your comment and misread the example. My bad!
I do think adding multiline comment support to ipkg would be nice.
I tried just moving blockComment
and the mutual
block above it into .Common
from .Source
and using it in the rawTokens
for .Package
, but I got a unification error I couldn't figure out.
But, I think someone a bit more familiar with the codebase should be able to wedge it in without too much problem. Capturing the content of the multiline comment for pretty-printing during debugging might require rewriting blockComment
, tho.
The Idris 2 documentation says that ipkg files support multiline comments, but when I attempt to use them I get the error:
[ fatal ] Failed to parse .ipkg file:
(followed by the absolute pathname of the ipkg file).Minimal working:
Minimal failure: