You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"No terminal matches '|' in the current parser context" when parsing multi-line conditional #142
my_local = {
for k, v in local.map_a : k => v
if lookup(local.map_b[v.id], "enabled", false)
|| (
contains(local.map_c, v.id)
&& contains(local.map_d, v.id)
)
}
It returns the following error when I attempt to parse the file:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/lark/lexer.py", line 590, in lex
yield lexer.next_token(lexer_state, parser_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/lark/lexer.py", line 528, 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 20 col 5
|| (
^
Expected one of:
* /<<(?P<heredoc>[a-zA-Z][a-zA-Z0-9._-]+)\n(?:.|\n)*?(?P=heredoc)/
* BANG
* /#.*\n/
* COLON
* RSQB
* /[a-zA-Z_][a-zA-Z0-9_-]*/
* LBRACE
* STRING_LIT
* RBRACE
* DECIMAL
* LSQB
* /\n/
* /<<-(?P<heredoc_trim>[a-zA-Z][a-zA-Z0-9._-]+)\n(?:.|\n)*?(?P=heredoc_trim)/
* MINUS
* /\/\/.*\n/
* LPAR
* COMMA
* RPAR
Previous tokens: Token('__ANON_0', '\n')
I can fix this by moving the entire local on to a single line, or adjusting it like this:
my_local = {
for k, v in local.map_a : k => v
if lookup(local.map_b[v.id], "enabled", false) || (
contains(local.map_c, v.id) && (
contains(local.map_d, v.id))
)
}
Seems like as long as I put || or && at the start or end of a line it produces this error.
Also having this problem where we split lines on "." accessor inside braces when writing hcl test conditions. The conditions are accessing deeply nested json documents. We can workaround by removing the line breaks but we end up with ridiculously long lines.
Activity
jskirde commentedon Oct 30, 2024
Also having this problem where we split lines on "." accessor inside braces when writing hcl test conditions. The conditions are accessing deeply nested json documents. We can workaround by removing the line breaks but we end up with ridiculously long lines.
kkozik-amplify commentedon Apr 7, 2026
Fixed in the latest release:
https://github.com/amplify-education/python-hcl2/releases/tag/v8.1.0