Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
hhamud committed Aug 2, 2023
1 parent d0d8955 commit f6dec33
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 36 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,66 @@

Noir grammar and parser for [tree-sitter](https://tree-sitter.github.io/tree-sitter/)

### Emacs
1. Make sure you have Emacs version 29.x and above.


2. Add the grammar to your settings as so:
``` elisp
(add-to-list
'treesit-language-source-alist
'(noir "https://github.com/hhamud/tree-sitter-noir.git"))
```


3. Install the grammar
``` elisp
M-x treesit-install-language-grammar
```


4. Check if it has installed successfully
``` elisp
(treesit-language-available-p 'noir)
```


5. Download `noir-ts-mode.el` from the [GitHub repository](https://github.com/hhamud/tree-sitter-noir).


6. Move `noir-mode.el` to a directory in your Emacs load path.



7. Add the following code to your Emacs configuration file:

```elisp
(require noir-ts-mode)
```



## Other

To install the grammar

```shell
npm i tree-sitter-noir
```

## Usage

Once `noir-mode.el` is installed, it will automatically be enabled when you open a `.nr` file. The major mode will provide syntax highlighting for editing Noir code.

## Examples
You can view a few examples of the syntax highlighting and of `treesit-explore-mode` using `noir-ts-mode.el` in images.


## References

- [Noir Language](https://github.com/noir-lang/noir)
- [Noir Docs](https://noir-lang.org/)

## Contributing

Contributions to tree-sitter-noir are welcome. If you find any issues or have suggestions for improvement, please create a new issue or submit a pull request on the [GitHub repository](https://github.com/hhamud/tree-sitter-noir).
7 changes: 0 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,6 @@ module.exports = grammar({

function_call: ($) => seq($.identifier, $.parameter),

//()
//(n: Field)
// (self)
// (self, n: Field)
// ([pky, pkx])
// (sm[i].signature)
// self, f: fn(T, T) -> T

parameter: ($) =>
seq(
Expand Down
Binary file added images/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 112 additions & 28 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2447,34 +2447,117 @@
}
],
"conflicts": [
["function_call", "self_method"],
["return_type", "generic_type"],
["_array_parameter", "_type"],
["_type", "generic_type"],
["_type", "array"],
["_type", "function_import"],
["array_type", "array"],
["generic_type", "typed_identifier"],
["array_identifier", "_expression", "_type"],
["array_identifier", "_expression"],
["function_call", "struct_expression"],
["_definition", "_expression"],
["_statement", "_expression"],
["struct_function", "struct_expression"],
["struct_function", "_expression"],
["struct_initialization", "single_type"],
["generic_type", "_type", "_expression"],
["function_call", "_type", "_expression"],
["_type", "_expression"],
["function_call", "_expression"],
["_expression", "struct_initialization"],
["_type", "_expression", "struct_initialization"],
["module"],
["_type"],
["typed_identifier"],
["self_method"],
["function_import"],
["let_declaration", "function_import"]
[
"function_call",
"self_method"
],
[
"return_type",
"generic_type"
],
[
"_array_parameter",
"_type"
],
[
"_type",
"generic_type"
],
[
"_type",
"array"
],
[
"_type",
"function_import"
],
[
"array_type",
"array"
],
[
"generic_type",
"typed_identifier"
],
[
"array_identifier",
"_expression",
"_type"
],
[
"array_identifier",
"_expression"
],
[
"function_call",
"struct_expression"
],
[
"_definition",
"_expression"
],
[
"_statement",
"_expression"
],
[
"struct_function",
"struct_expression"
],
[
"struct_function",
"_expression"
],
[
"struct_initialization",
"single_type"
],
[
"generic_type",
"_type",
"_expression"
],
[
"function_call",
"_type",
"_expression"
],
[
"_type",
"_expression"
],
[
"function_call",
"_expression"
],
[
"_expression",
"struct_initialization"
],
[
"_type",
"_expression",
"struct_initialization"
],
[
"module"
],
[
"_type"
],
[
"typed_identifier"
],
[
"self_method"
],
[
"function_import"
],
[
"let_declaration",
"function_import"
]
],
"precedences": [],
"externals": [
Expand All @@ -2486,3 +2569,4 @@
"inline": [],
"supertypes": []
}

2 changes: 1 addition & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2626,4 +2626,4 @@
"type": "}",
"named": false
}
]
]

0 comments on commit f6dec33

Please sign in to comment.