075ead0f

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Add comments within declarations

A comment used to be a declaration of its own, so a comment between the lines
of a transaction was either a parse error or was moved onto its own line by
the formatter.

A comment can now be written on an indented line of its own within a
declaration, where it belongs to the line below it.  That means a comment
cannot be the last line of a declaration: it would belong to no line at all,
which is an error that points at the comment.

A comment at the first column still starts a new declaration, so the lines
that a declaration cannot contain, an import, a currency, a tag, a price, an
account line and a timestamp line, hold no comment of their own: a comment
above those is a comment declaration already.

A run of comment lines is one comment, so 'Commented' holds at most one and a
run of comment lines at the first column is one declaration.

Note that both the lines of a transaction and the declarations of a module are
a chain of productions rather than a list.  The comment above a line has to be
read before it is known which kind of line follows it, so a list makes the
description/posting and posting/extra boundaries reduce/reduce conflicts, and a
list of declarations that each start with a comment run makes another comment
line either extend the run or start the next declaration.

Fix two bugs in the process:

  * A comment whose text was only whitespace swallowed the declaration below
    it.  Nothing could match the rest of the line, so '$white+' matched the
    newline instead and left the lexer in the comment start code, reading the
    next declaration as comment text.  A comment line is now a single token, so
    there is no start code left to be stranded in.

  * A description could be empty, or contain an empty line, neither of which
    can be written down: an empty description formatted to no line at all and
    was silently lost.

Suite timing

Time to Start Worker time Duration Time to finish Idle
Config 0s 1s 1s 1s 0s
Eval 1s 12s 12s 13s 0s
Build 12s 0s 0s 13s 0s
Suite 0s 13s 13s 13s 0s

Timeline

0s10s