Comments (6)
Hi there!
Yes, I'm currently evaluating the replacement of pest with nom, mainly to see how easy it is to replicate the current parser and if it makes implementing some improvements easier. I'm planning support for emitting the complete AST of an HCL document at one point, mainly to support use cases like #112. This would also include span information.
I'm still undecided if I want this to be part of the general purpose parser that just emits structural elements, expressions and templates (like it does right now). The overhead might harm performance. If this is the case, I might end up with two parsers, one for the common use case, and a specialized one that emits the full AST including comments and whitespace. These two could share a lot of code of course, but the API and data types emitted would differ.
I'm interested to hear what your use case would be for the location spans!
from hcl-rs.
I base my parsing on hcl::structure::body::Body
and having location spans would enrich my error messages
from hcl-rs.
Our use case is very much like a linter. We're building a security scanner for HCL files. So:
- We deserialize to get the attributes, blocks, as data
- We lint the data with a datalog-like language (OPA/rego)
- Then when finding a bad value we want to point the user into the line:col coordinate to check for these issues
As a security linter we're focused on the values inside these files, and the composition of it, meaning the syntax might be perfectly fine.
Having location spans can support any linting usecase and not just a security linting example.
Hope that makes sense - LMK if you'd like some more detail of exactly how we do it 👍
from hcl-rs.
Thanks for the feedback, this makes complete sense to me. I'll try to make span information available as part of the nom
rewrite. I was already aware of nom_locate
and will probably use it to track the spans.
from hcl-rs.
Great!
If I can be of any help -- feel free to pull me in :)
from hcl-rs.
@jondot Hey there, I'm happy to announce that I released the first version of hcl-edit
, which also includes span information (accessible via the hcl_edit::repr::Span
trait). There are still rough edges and usage examples and a lot of docs are missing, but the parser is functional and even over 100% faster than the original one in hcl-rs
.
I'll continue to improve this crate and will also integrate it with hcl-rs
, but this will take some more work. Happy to receive some initial feedback if you want to try it out :).
from hcl-rs.
Related Issues (20)
- Resolve references (eval) HOT 4
- support partial expression evaluation HOT 3
- Error when trying to parse comments starting with `//` HOT 3
- hcl-edit: question/request - display Location from span HOT 3
- unknown variant `${identifier.attr.subattr}`, expected one of `Null`, `Bool`, `Number`... HOT 1
- `$${` should be evaluated to `${` HOT 1
- incorrect handling of interpolation/directive start markers in `Expression::String`
- Deserializing a nested custom struct? HOT 1
- incorrect handling of escaped template interpolations and directives
- hcl-edit: hardcoded newline for Body HOT 6
- Using jsonencode HOT 5
- parser panics instead of returning an error HOT 3
- hcl-edit: attribute key has no span information HOT 2
- Feature parity with go-hcl HOT 6
- Fraction-less floats are coerced into integers HOT 1
- Question: How do you correctly encode references to other terraform resources HOT 2
- Understanding where `EvalError::NoSuchKey` comes from HOT 2
- parser fails when given a multi-line ternary expression within parenthesis HOT 2
- `Deserialize` impl for `Block` is wrong HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hcl-rs.