tree-sitter-hcl
tree-sitter-hcl copied to clipboard
Allow dots in identifiers
Describe the bug Grafana Alloy is a telemetry collector that uses a HCL-like language for configuration. Their configuration language "alloy" is almost exactly like HCL, except that it also seems to support dots in block identifiers.
Example, copied from their documentation:
// Collection: mount a local directory with a certain path spec
local.file_match "applogs" {
path_targets = [{"__path__" = "/tmp/app-logs/app.log"}]
}
// Collection: Take the file match as input, and scrape those mounted log files
loki.source.file "local_files" {
targets = local.file_match.applogs.targets
// This specifies which component should process the logs next, the "link in the chain"
forward_to = [loki.process.add_new_label.receiver]
}
// Transformation: pull some data out of the log message, and turn it into a label
loki.process "add_new_label" {
stage.logfmt {
mapping = {
"extracted_level" = "level",
}
}
// Add the value of "extracted_level" from the extracted map as a "level" label
stage.labels {
values = {
"level" = "extracted_level",
}
}
// The next link in the chain is the local_loki "receiver" (receives the telemetry)
forward_to = [loki.write.local_loki.receiver]
}
// Anything that comes into this component gets written to the loki remote API
loki.write "local_loki" {
endpoint {
url = "http://loki:3100/loki/api/v1/push"
}
}
It would be nice if this could be supported by this tree-sitter syntax. I know it's not exactly HCL, but I am not sure whether it already makes sense to fork this repo just for this minor addition.
To Reproduce Steps to reproduce the behavior:
- Write HCL-like syntax like above.
- The tree-sitter marks this as invalid syntax.
Expected behavior I'd like to see the dots supported in identifiers.
Screenshots None.
Additional context None.