aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo/config1
-rw-r--r--CONTRIBUTING.md25
-rw-r--r--crates/ra_syntax/src/ast/generated.rs3
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera5
-rw-r--r--crates/ra_syntax/src/grammar.ron5
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs3
-rw-r--r--crates/ra_syntax/src/syntax_kinds/generated.rs.tera5
7 files changed, 43 insertions, 4 deletions
diff --git a/.cargo/config b/.cargo/config
index 767045bdb..ac7470c7e 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -1,4 +1,5 @@
1[alias] 1[alias]
2# Automatically generates the ast and syntax kinds files
2gen-kinds = "run --package tools -- gen-kinds" 3gen-kinds = "run --package tools -- gen-kinds"
3gen-tests = "run --package tools -- gen-tests" 4gen-tests = "run --package tools -- gen-tests"
4install-code = "run --package tools -- install-code" 5install-code = "run --package tools -- install-code"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 41954c02e..c044001ca 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,9 +12,9 @@ are some areas where contributions would be **especially** welcome:
12* Porting libsyntax parser to rust-analyzer: currently rust-analyzer parses 12* Porting libsyntax parser to rust-analyzer: currently rust-analyzer parses
13 only a tiny subset of Rust. This should be fixed by porting parsing 13 only a tiny subset of Rust. This should be fixed by porting parsing
14 functions from libsyntax one by one. Take a look at the 14 functions from libsyntax one by one. Take a look at the
15 [libsyntax parser](https://github.com/rust-lang/rust/blob/6b99adeb11313197f409b4f7c4083c2ceca8a4fe/src/libsyntax/parse/parser.rs) 15 [libsyntax parser]
16 for "what to port" and at the 16 for "what to port" and at the
17 [Kotlin parser](https://github.com/JetBrains/kotlin/blob/4d951de616b20feca92f3e9cc9679b2de9e65195/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java) 17 [Kotlin parser]
18 for "how to port". 18 for "how to port".
19 19
20* Writing validators: by design, rust-analyzer is very lax about the 20* Writing validators: by design, rust-analyzer is very lax about the
@@ -35,4 +35,23 @@ are some areas where contributions would be **especially** welcome:
35Do take a look at the issue tracker. 35Do take a look at the issue tracker.
36 36
37If you don't know where to start, or have *any* questions or suggestions, 37If you don't know where to start, or have *any* questions or suggestions,
38don't hesitate to chat at [Gitter](https://gitter.im/libsyntax2/Lobby)! 38don't hesitate to chat at [Gitter]!
39
40# Code generation
41
42Some of the components of this repository are generated through automatic processes. These are outlined below:
43
44 - `gen-kinds`: The kinds of tokens are reused in several places, so a generator is used.
45 This process uses [tera] to generate, using data in [grammar.ron], the files:
46 - [ast/generated.rs][ast generated] in `ra_syntax` based on [ast/generated.tera.rs][ast source]
47 - [syntax_kinds/generated.rs][syntax_kinds generated] in `ra_syntax` based on [syntax_kinds/generated.tera.rs][syntax_kinds source]
48
49[libsyntax parser]: https://github.com/rust-lang/rust/blob/6b99adeb11313197f409b4f7c4083c2ceca8a4fe/src/libsyntax/parse/parser.rs
50[Kotlin parser]: https://github.com/JetBrains/kotlin/blob/4d951de616b20feca92f3e9cc9679b2de9e65195/compiler/frontend/src/org/jetbrains/kotlin/parsing/KotlinParsing.java
51[Gitter]: https://gitter.im/libsyntax2/Lobby
52[tera]: https://tera.netlify.com/
53[grammar.ron]: ./crates/ra_syntax/src/grammar.ron
54[ast generated]: ./crates/ra_syntax/src/ast/generated.rs
55[ast source]: ./crates/ra_syntax/src/ast/generated.tera.rs
56[syntax_kinds generated]: ./crates/ra_syntax/src/syntax_kinds/generated.rs
57[syntax_kinds source]: ./crates/ra_syntax/src/syntax_kinds/generated.tera.rs \ No newline at end of file
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index c945c094a..2db6dff1b 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1,3 +1,6 @@
1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
2// Do not edit manually
3
1use { 4use {
2 ast, 5 ast,
3 SyntaxNodeRef, AstNode, 6 SyntaxNodeRef, AstNode,
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
index a72e9b732..ceb2cd7e2 100644
--- a/crates/ra_syntax/src/ast/generated.rs.tera
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -1,3 +1,8 @@
1{# THIS File is not automatically generated:
2the below applies to the result of this template
3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
4// Do not edit manually
5
1use { 6use {
2 ast, 7 ast,
3 SyntaxNodeRef, AstNode, 8 SyntaxNodeRef, AstNode,
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 77ae4c7db..4b990fd8d 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -1,3 +1,5 @@
1// Stores definitions which must be used in multiple places
2// See `cargo gen-kinds` (defined in crates/tools/src/main.rs)
1Grammar( 3Grammar(
2 single_byte_tokens: [ 4 single_byte_tokens: [
3 [";", "SEMI"], 5 [";", "SEMI"],
@@ -23,8 +25,9 @@ Grammar(
23 ["^", "CARET"], 25 ["^", "CARET"],
24 ["%", "PERCENT"], 26 ["%", "PERCENT"],
25 ], 27 ],
28 // TODO: Confirm surmision: the tokens which cannot be recorded in a single UTF-8 byte
26 multi_byte_tokens: [ 29 multi_byte_tokens: [
27 [".", "DOT"], 30 [".", "DOT"], // Note: DOT is here because <TODO: REASON>
28 ["..", "DOTDOT"], 31 ["..", "DOTDOT"],
29 ["...", "DOTDOTDOT"], 32 ["...", "DOTDOTDOT"],
30 ["..=", "DOTDOTEQ"], 33 ["..=", "DOTDOTEQ"],
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs b/crates/ra_syntax/src/syntax_kinds/generated.rs
index 7882bded9..11e9150bb 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs
@@ -1,3 +1,6 @@
1// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
2// Do not edit manually
3
1#![allow(bad_style, missing_docs, unreachable_pub)] 4#![allow(bad_style, missing_docs, unreachable_pub)]
2#![cfg_attr(rustfmt, rustfmt_skip)] 5#![cfg_attr(rustfmt, rustfmt_skip)]
3use super::SyntaxInfo; 6use super::SyntaxInfo;
diff --git a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
index 90618721a..018564b8a 100644
--- a/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
+++ b/crates/ra_syntax/src/syntax_kinds/generated.rs.tera
@@ -1,3 +1,8 @@
1{# THIS File is not automatically generated:
2the below applies to the result of this template
3#}// This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-kinds` is run
4// Do not edit manually
5
1#![allow(bad_style, missing_docs, unreachable_pub)] 6#![allow(bad_style, missing_docs, unreachable_pub)]
2#![cfg_attr(rustfmt, rustfmt_skip)] 7#![cfg_attr(rustfmt, rustfmt_skip)]
3use super::SyntaxInfo; 8use super::SyntaxInfo;