Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"syntax error, unexpected ASTERISK" on a comment line with just asterisk #741

Open
bstpierre opened this issue Dec 16, 2022 · 2 comments
Open

Comments

@bstpierre
Copy link

I recently upgraded an installation from beancount 2.0rc1 on 2.3.5 and several of my files started getting syntax error, unexpected ASTERISK from bean-check test.bean. (With python 3.9 on debian.)

Line 2 gets the error, it is just an asterisk on a line by itself.

Line 6 does NOT get the error, it is an asterisk followed by a space.

test.bean:

* this is a comment
*
* The line above is part of a commented-series of lines, it does not have a
* trailing space. The line below has a trailing space.
* 

2022-01-01 open Assets:Cash USD
2022-01-01 open Expenses:Misc USD

2022-01-02 * "blah"
    Assets:Cash   -1.00 USD
    Expenses:Misc  1.00 USD

The workaround appears to be to replace a lone asterisk on a line with asterisk+space (:%s/^\*$/* /) -- or delete these lines.

I created a python 3.9 venv to test, and it appears that this change occurred between 2.3.2 and 2.3.3.

@dnicolodi
Copy link
Collaborator

This works as intended. Comments in Beancount are introduced by a semicolon ; or an hash # character. The asterisk * is allowed only for org-mode-style sectioning headers.

@bstpierre
Copy link
Author

According to the documentation, # is not a comment character -- ; is the only comment character, except for other characters that work as comment characters:

Any line that does not begin as a valid Beancount syntax directive (e.g. with a date) is silently ignored.

While experimenting with various things that may or may not be treated as comments across the 2.0/2.3.3 version boundary, I found that this file would parse as valid in 2.0 but not in 2.3.3:

  ; this is an indented comment, which is valid in 2.0 but a syntax error in 2.3.3

2022-01-01 open Assets:Cash USD
2022-01-01 open Expenses:Misc USD

2022-01-02 * "blah"
    Assets:Cash   -1.00 USD
    Expenses:Misc  1.00 USD

This yields the error message: test.bean:1: syntax error, unexpected INDENT. This contradicts the documentation:

Any text on a line after the character “;” is ignored

Note that replacing the semicolon with a hash on line 1 of that file becomes a syntax error (unexpected HASH) in both 2.0 and 2.3.3.

I don't really expect these issues to get fixed, but I thought it might save someone a few minutes if they search for this error message.

Though I suppose you could consider this as a documentation error about what is considered valid syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants