The input to Happy is a text file containing the grammar of the language you want to parse, together with some annotations that help the parser generator make a legal Haskell module that can be included in your program. This section gives the exact syntax of grammar files.
The overall format of the grammar file is given below:
<optional module header> <directives> %% <grammar> <optional module trailer>
If the name of the grammar file ends in .ly
, then
it is assumed to be a literate script. All lines except those
beginning with a >
will be ignored, and the
>
will be stripped from the beginning of all the code
lines. There must be a blank line between each code section
(lines beginning with >
) and comment section.
Grammars not using the literate notation must be in a file with
the .y
suffix.