ParseTemplate parses the given buffer as a standalone HCL template, returning it as an instance of Expression.
(src []byte, filename string, start hcl.Pos)
| 76 | // ParseTemplate parses the given buffer as a standalone HCL template, |
| 77 | // returning it as an instance of Expression. |
| 78 | func ParseTemplate(src []byte, filename string, start hcl.Pos) (Expression, hcl.Diagnostics) { |
| 79 | tokens, diags := LexTemplate(src, filename, start) |
| 80 | peeker := newPeeker(tokens, false) |
| 81 | parser := &parser{peeker: peeker} |
| 82 | expr, parseDiags := parser.ParseTemplate() |
| 83 | diags = append(diags, parseDiags...) |
| 84 | |
| 85 | // Panic if the parser uses incorrect stack discipline with the peeker's |
| 86 | // newlines stack, since otherwise it will produce confusing downstream |
| 87 | // errors. |
| 88 | peeker.AssertEmptyIncludeNewlinesStack() |
| 89 | |
| 90 | return expr, diags |
| 91 | } |
| 92 | |
| 93 | // ParseTraversalAbs parses the given buffer as a standalone absolute traversal. |
| 94 | // |