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

Unexpected token for ~ #159

Open
pzalews opened this issue Apr 10, 2024 · 1 comment
Open

Unexpected token for ~ #159

pzalews opened this issue Apr 10, 2024 · 1 comment

Comments

@pzalews
Copy link

pzalews commented Apr 10, 2024

With latest version 4.3.3:

File "/home/piotrzal/SRC/DEVOPS/modules-manager/docs_venv/lib/python3.8/site-packages/lark/lexer.py", line 598, 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 65 col 34

%{for role in var.ADMIN_ROLES_ARN~}
                                 ^
Expected one of:
        * /[a-zA-Z_][a-zA-Z0-9_-]*/
        * "=="
        * QMARK
        * /#.*\n/
        * COMMA
        * LPAR
        * MORETHAN
        * "<="
        * "[*]"
        * LESSTHAN
        * RBRACE
        * ">="
        * RPAR
        * STRING_LIT
        * PLUS
        * LBRACE
        * RSQB
        * /\/\/.*\n/
        * "..."
        * "!="
        * LSQB
        * COLON
        * SLASH
        * PERCENT
        * MINUS
        * /\n/
        * "||"
        * "&&"
        * EQUAL
        * STAR
        * DOT
        * "=>"
        * ".*"

Previous tokens: Token('__ANON_3', '_ARN')

Example terraform code:

name = <<EOT
%{for role in var.ADMIN_ROLES_ARN~}
- rolearn: ${role}
  username: ${join("-", slice(split("/", role), 1, length(split("/", role))))}
  groups:
    - system:masters
%{endfor}
EOT
@DevGumbo
Copy link

DevGumbo commented Jun 7, 2024

The tilde ~ at the end of for might not be necessary unless it is part of a specific syntax or requirement. Typically, for loops in Heredocs do not use it.
Ensure proper spacing and alignment for readability and consistency.
Ensure that the closing EOT matches the opening <<EOT without any additional spaces or characters.
Here's a corrected and properly formatted version of your Heredoc syntax:

name = <<EOT
%{for role in var.ADMIN_ROLES_ARN}
- rolearn: ${role}
  username: ${join("-", slice(split("/", role), 1, length(split("/", role))))}
  groups:
    - system:masters
%{endfor}
EOT

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