add `panic` keyword / add contributing section to Readme (#46)

pull/844/head
inoas 2023-03-03 16:38:22 +07:00 committed by GitHub
parent c72df7110b
commit d14acab7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28990 additions and 26409 deletions

@ -37,6 +37,7 @@ Various Gotchas
---------------
There are a few nodes in the generated AST that may be confusing at first:
- `type` :: A very ambiguous name, but this refers to a concrete type such as
`List(#(String, Int))`
- `type_name` :: Refers to essentially the left side of a type declaration and
@ -67,13 +68,21 @@ To-do List
[open an issue]: https://github.com/J3RN/tree-sitter-gleam/issues/new
Contributing
------------
1. Change files such as `grammar.js` and `queries/highlight.scm`.
2. The grammar needs to be generated from the `grammar.js` file by running `npm run generate`.
3. Add parser feature tests to the relevant file(s) in `test/corpus/`, or make a new one.
4. Run `npm run test` and fix any failing tests.
Style
-----
To prevent headaches from stylistic differences, I request that you please
follow these style suggestions. 🙏
- Remove all non-mandatory trailing whitespace
- Remove all non-mandatory trailing whitespace.
- Ensure a final newline is present at the end of all files (this is the default
in Vim, Emacs)
- Format JavaScript by running `npm run format`
in Vim, Emacs).
- Format JavaScript by running `npm run format`.

@ -319,6 +319,7 @@ module.exports = grammar({
$.record,
$.identifier,
$.todo,
$.panic,
$.tuple,
$.list,
alias($._expression_bit_string, $.bit_string),
@ -341,6 +342,7 @@ module.exports = grammar({
),
todo: ($) =>
seq("todo", optional(seq("(", field("message", $.string), ")"))),
panic: (_$) => seq("panic"),
tuple: ($) => seq("#", "(", optional(series_of($._expression, ",")), ")"),
list: ($) =>
seq(

@ -78,6 +78,7 @@
"if"
"import"
"let"
"panic"
"todo"
"try"
"type"

13
src/grammar.json generated

@ -2645,6 +2645,10 @@
"type": "SYMBOL",
"name": "todo"
},
{
"type": "SYMBOL",
"name": "panic"
},
{
"type": "SYMBOL",
"name": "tuple"
@ -2784,6 +2788,15 @@
}
]
},
"panic": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "panic"
}
]
},
"tuple": {
"type": "SEQ",
"members": [

93
src/node-types.json generated

@ -129,6 +129,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -330,6 +334,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -438,6 +446,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -654,6 +666,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -840,6 +856,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -944,6 +964,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -1104,6 +1128,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -1351,6 +1379,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -1644,6 +1676,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -1975,6 +2011,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -2414,6 +2454,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -2510,6 +2554,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -2601,6 +2649,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -2786,6 +2838,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -2817,6 +2873,11 @@
]
}
},
{
"type": "panic",
"named": true,
"fields": {}
},
{
"type": "pattern_spread",
"named": true,
@ -3069,6 +3130,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -3175,6 +3240,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -3358,6 +3427,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -3649,6 +3722,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -3745,6 +3822,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -4261,6 +4342,10 @@
"type": "negation",
"named": true
},
{
"type": "panic",
"named": true
},
{
"type": "record",
"named": true
@ -4541,11 +4626,11 @@
},
{
"type": "float",
"named": false
"named": true
},
{
"type": "float",
"named": true
"named": false
},
{
"type": "fn",
@ -4587,6 +4672,10 @@
"type": "opacity_modifier",
"named": true
},
{
"type": "panic",
"named": false
},
{
"type": "quoted_content",
"named": true

55267
src/parser.c generated

File diff suppressed because it is too large Load Diff

@ -241,6 +241,9 @@ fn funcall() {
fn unfinished() {
todo("Finish me!")
}
fn do_panic() {
panic
}
fn tuple(x) {
#(x, 1)
}
@ -359,6 +362,11 @@ fn field_access(x) {
(todo
message: (string
(quoted_content)))))
(function
name: (identifier)
parameters: (function_parameters)
body: (function_body
(panic)))
(function
name: (identifier)
parameters: (function_parameters