%token Ident %token White %token Other %token Colon %token Newline %token Eof %start package %type < (string * (string * string)) list > package %type < string > nonwhite %% package: package2 {List.rev (* If we see a continuation line, a line that starts with whitespace, append the text to the previous entry. *) (List.fold_left (fun l e -> match l, e with ((a1, (w1, v1)) :: tl, ("", (w2, v2))) -> (a1, (w1, v1^"\n"^w2^v2)) :: tl | (lst, next) -> next :: lst) [] $1)} package2: entries sep {$1} | optwhite Newline package2 {$3} entries: lhs optwhite nonwhite opttokens eol {[$1, ($2, $3^$4)]} | lhs optwhite nonwhite opttokens eol entries {($1, ($2, $3^$4)) :: $6} | lhs optwhite eol {[$1, ($2, "")]} | lhs optwhite eol entries {($1, ($2, "")) :: $4} | White opttokens eol {["", ($1, $2)]} | White opttokens eol entries {("", ($1, $2)) :: $4} lhs: nonwhite optwhite Colon {$1} eol: Newline {"\n"} | Eof {""} sep: Newline {"\n"} | Eof {""} opttokens: {""} | token opttokens {$1^$2} token: White {$1} | nonwhite {$1} nonwhite: Other {$1} | Colon {":"} | Ident {$1} optwhite: {""} | White {$1}