grammars-v4
grammars-v4 copied to clipboard
Antlr4 Terraform Grammer Is not able parse nested EOF
Terraform Language grammar is having following parser issues.
Args:
line 105:18 extraneous input '/' expecting {'data', 'module', 'local', 'var', 'for', 'jsonencode', '[', 'file', '+', '-', 'variable', 'provider', 'in', '*', '{', '(', EOF_, 'nul', NATURAL_NUMBER, BOOL, DESCRIPTION, MULTILINESTRING, STRING, IDENTIFIER}
line 105:22 mismatched input '/' expecting '.'
line 107:12 token recognition error at: '$'
line 107:10 extraneous input ':' expecting {'data', 'module', 'local', 'var', ',', 'variable', 'provider', 'in', '*', '}', NATURAL_NUMBER, IDENTIFIER}
line 108:6 missing '=' at 'IP'
line 108:10 token recognition error at: '$'
line 108:8 extraneous input ':' expecting {'data', 'module', 'local', 'var', ',', 'variable', 'provider', 'in', '*', '}', NATURAL_NUMBER, IDENTIFIER}
line 109:6 missing '=' at 'Metadata'
line 109:16 token recognition error at: '$'
line 109:14 extraneous input ':' expecting {'data', 'module', 'local', 'var', ',', 'variable', 'provider', 'in', '*', '}', NATURAL_NUMBER, IDENTIFIER}
line 110:6 mismatched input '<' expecting '='
line 110:7 extraneous input '/' expecting {'data', 'module', 'local', 'var', 'for', 'jsonencode', '[', 'file', '+', '-', 'variable', 'provider', 'in', '*', '{', '(', EOF_, 'nul', NATURAL_NUMBER, BOOL, DESCRIPTION, MULTILINESTRING, STRING, IDENTIFIER}
line 113:2 no viable alternative at input 'EOF1}'
Terraform File: https://github.com/terraform-google-modules/terraform-docs-samples/blob/main/external_http_lb_mig_backend_custom_header/main.tf
As I understand this could be a rare case scenario, can you please provide any quick hack for my case?
The "here doc" syntax is messed up. The id following the << must be matched. Right now it's a hardwired "EOF" string. To fix this, the lexer will need to get the starting ID, then scan forward until it's found again, presumably on a single line.