Add Tree-sitter grammar for Decodal
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
==================
|
||||
Top-level fields
|
||||
==================
|
||||
host = String;
|
||||
port = Int & > 443 default 8080;
|
||||
---
|
||||
|
||||
(source_file
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (identifier))
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (default_expression
|
||||
base: (binary_expression
|
||||
left: (identifier)
|
||||
right: (comparison_constraint
|
||||
value: (integer)))
|
||||
fallback: (literal (integer)))))
|
||||
|
||||
==================
|
||||
Import and function
|
||||
==================
|
||||
let
|
||||
schema = import "./schema.dcdl";
|
||||
mk = (cfg: schema.Service) => cfg;
|
||||
in
|
||||
mk({ name = "api"; })
|
||||
---
|
||||
|
||||
(source_file
|
||||
(let_expression
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (import_expression
|
||||
specifier: (string)))
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (function_expression
|
||||
(parameter
|
||||
name: (identifier)
|
||||
constraint: (path_expression
|
||||
object: (identifier)
|
||||
field: (identifier)))
|
||||
body: (identifier)))
|
||||
body: (call_expression
|
||||
function: (identifier)
|
||||
(object
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (literal (string)))))))
|
||||
|
||||
==================
|
||||
Match and patch
|
||||
==================
|
||||
base // {
|
||||
summary = match env {
|
||||
"prod": "production";
|
||||
_: "other";
|
||||
};
|
||||
}
|
||||
---
|
||||
|
||||
(source_file
|
||||
(binary_expression
|
||||
left: (identifier)
|
||||
right: (object
|
||||
(field_definition
|
||||
path: (field_path (identifier))
|
||||
value: (match_expression
|
||||
scrutinee: (identifier)
|
||||
(match_arm
|
||||
pattern: (literal (string))
|
||||
body: (literal (string)))
|
||||
(match_arm
|
||||
body: (literal (string))))))))
|
||||
Reference in New Issue
Block a user