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

Failure when encountering links on a new line #7

Open
korrat opened this issue Aug 31, 2022 · 1 comment
Open

Failure when encountering links on a new line #7

korrat opened this issue Aug 31, 2022 · 1 comment

Comments

@korrat
Copy link

korrat commented Aug 31, 2022

When trying to format a transaction containing a link on the line after the narration, beancount-black throws an exception.

Example file:

2022-08-01 "Payee" "Narration"
  ^reference-XXX
  Assets:Checking     -12345.67 EUR
  Expenses:Other

Exception:

$ bean-black --no-backup example.bean
INFO:beancount_black.main:Processing file example.bean
Traceback (most recent call last):
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\lexer.py", line 528, in lex
    yield lexer.next_token(lexer_state, parser_state)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\lexer.py", line 466, in next_token
    raise UnexpectedCharacters(lex_state.text, line_ctr.char_pos, line_ctr.line, line_ctr.column,
lark.exceptions.UnexpectedCharacters: No terminal matches '^' in the current parser context, at line 2 col 3

  ^reference-XXX
  ^
Expected one of:
        * ACCOUNT
        * _NL
        * METADATA_KEY
        * COMMENT
        * SECTION_HEADER
        * DATE
        * FLAG

Previous tokens: Token('_NL', '\n')


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\users\markus\.local\bin\bean-black.exe\__main__.py", line 7, in <module>
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\beancount_black\main.py", line 47, in main
    tree = parser.parse(input_content)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\lark.py", line 625, in parse
    return self.parser.parse(text, start=start, on_error=on_error)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\parser_frontends.py", line 96, in parse
    return self.parser.parse(stream, chosen_start, **kw)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\parsers\lalr_parser.py", line 41, in parse
    return self.parser.parse(lexer, start)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\parsers\lalr_parser.py", line 171, in parse
    return self.parse_from_state(parser_state)
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\parsers\lalr_parser.py", line 188, in parse_from_state
    raise e
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\parsers\lalr_parser.py", line 178, in parse_from_state
    for token in state.lexer.lex(state):
  File "C:\Users\Markus\.local\pipx\venvs\beancount\lib\site-packages\lark\lexer.py", line 537, in lex
    raise UnexpectedToken(token, e.allowed, state=parser_state, token_history=[last_token], terminals_by_name=self.root_lexer.terminals_by_name)
lark.exceptions.UnexpectedToken: Unexpected token Token('LINK', '^reference-XXX') at line 2, column 3.
Expected one of:
        * ACCOUNT
        * $END
        * INCLUDE
        * PLUGIN
        * _NL
        * METADATA_KEY
        * COMMENT
        * OPTION
        * SECTION_HEADER
        * DATE
        * FLAG
Previous tokens: [Token('_NL', '\n')]

@korrat
Copy link
Author

korrat commented Sep 7, 2022

This seems like it's caused by LaunchPlatform/beancount-parser#3

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

1 participant