[Haskell-cafe] Parsing Haskell with Layout
Benjamin Redelings
benjamin.redelings at gmail.com
Thu Aug 30 12:00:37 UTC 2018
Great, thanks!
On 08/29/2018 12:32 PM, J. Garrett Morris wrote:
> On Tue, Aug 28, 2018 at 2:53 PM Benjamin Redelings
> <benjamin.redelings at gmail.com> wrote:
>> I'm not sure of the theory behind implementing Note 5 in section 10.3.
>> This says roughly that we insert a "}" token after token t[n] if the
>> tokens t[1]...t[n+1] have no valid parses, and the sequence of tokens
>> t[1] ... t[n] followed by "}" DO have a valid parse.
>>
>> I think this allows you to write
>>
>> f z = let x=2;y=3 in x+y+z
> Yes.
>
>> (a) what concepts are assumed by the report that would make it "obvious"
>> how Note 5 is supposed to be implemented?
> I don't think the report is intending to suggest a particular
> implementation approach. GHC's is described at
> https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Parser.
>
>> (b) a simple (hopefully) implementation strategy for implementing it?
>> I'm looking for a language-independent approach for parsing.
> Perhaps you would find Michael Adams "Principled parsing for
> indentation-sensitive languages: Revisiting Landin’s offside rule"
> helpful. http://dx.doi.org/10.1145/2429069.2429129
>
> That approach is implemented by the "indentation" library on Hackage,
> for either Parsec or Trifecta.
>
> /g
>
More information about the Haskell-Cafe
mailing list