aboutsummaryrefslogtreecommitdiff
path: root/crates/parser/src/grammar
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-27 17:42:37 +0100
committerGitHub <[email protected]>2020-08-27 17:42:37 +0100
commitdddc4c6370ab8e7684352302a5ff282673c6e8ec (patch)
tree07b240aeff385331e1e39cb68b068b5b780ce11b /crates/parser/src/grammar
parent6f6580dec764e136148f3fe55c203a9452176bdd (diff)
parent4b989009e3839cfc6f021d1552a46561cee6cde2 (diff)
Merge #5899
5899: Add track_env_var to the proc macro server r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/parser/src/grammar')
-rw-r--r--crates/parser/src/grammar/expressions.rs2
-rw-r--r--crates/parser/src/grammar/expressions/atom.rs12
-rw-r--r--crates/parser/src/grammar/items.rs4
-rw-r--r--crates/parser/src/grammar/paths.rs2
-rw-r--r--crates/parser/src/grammar/patterns.rs17
-rw-r--r--crates/parser/src/grammar/types.rs8
6 files changed, 27 insertions, 18 deletions
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs
index e72929f8c..5f885edfd 100644
--- a/crates/parser/src/grammar/expressions.rs
+++ b/crates/parser/src/grammar/expressions.rs
@@ -316,7 +316,7 @@ fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMark
316} 316}
317 317
318const LHS_FIRST: TokenSet = 318const LHS_FIRST: TokenSet =
319 atom::ATOM_EXPR_FIRST.union(token_set![T![&], T![*], T![!], T![.], T![-]]); 319 atom::ATOM_EXPR_FIRST.union(TokenSet::new(&[T![&], T![*], T![!], T![.], T![-]]));
320 320
321fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 321fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
322 let m; 322 let m;
diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs
index ba6dd2fbc..66a92a4e1 100644
--- a/crates/parser/src/grammar/expressions/atom.rs
+++ b/crates/parser/src/grammar/expressions/atom.rs
@@ -15,7 +15,7 @@ use super::*;
15// let _ = b"e"; 15// let _ = b"e";
16// let _ = br"f"; 16// let _ = br"f";
17// } 17// }
18pub(crate) const LITERAL_FIRST: TokenSet = token_set![ 18pub(crate) const LITERAL_FIRST: TokenSet = TokenSet::new(&[
19 TRUE_KW, 19 TRUE_KW,
20 FALSE_KW, 20 FALSE_KW,
21 INT_NUMBER, 21 INT_NUMBER,
@@ -25,8 +25,8 @@ pub(crate) const LITERAL_FIRST: TokenSet = token_set![
25 STRING, 25 STRING,
26 RAW_STRING, 26 RAW_STRING,
27 BYTE_STRING, 27 BYTE_STRING,
28 RAW_BYTE_STRING 28 RAW_BYTE_STRING,
29]; 29]);
30 30
31pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> { 31pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
32 if !p.at_ts(LITERAL_FIRST) { 32 if !p.at_ts(LITERAL_FIRST) {
@@ -39,7 +39,7 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
39 39
40// E.g. for after the break in `if break {}`, this should not match 40// E.g. for after the break in `if break {}`, this should not match
41pub(super) const ATOM_EXPR_FIRST: TokenSet = 41pub(super) const ATOM_EXPR_FIRST: TokenSet =
42 LITERAL_FIRST.union(paths::PATH_FIRST).union(token_set![ 42 LITERAL_FIRST.union(paths::PATH_FIRST).union(TokenSet::new(&[
43 T!['('], 43 T!['('],
44 T!['{'], 44 T!['{'],
45 T!['['], 45 T!['['],
@@ -59,9 +59,9 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet =
59 T![loop], 59 T![loop],
60 T![for], 60 T![for],
61 LIFETIME, 61 LIFETIME,
62 ]); 62 ]));
63 63
64const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW, R_DOLLAR]; 64const EXPR_RECOVERY_SET: TokenSet = TokenSet::new(&[LET_KW, R_DOLLAR]);
65 65
66pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 66pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
67 if let Some(m) = literal(p) { 67 if let Some(m) = literal(p) {
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs
index 8fd8f3b80..22810e6fb 100644
--- a/crates/parser/src/grammar/items.rs
+++ b/crates/parser/src/grammar/items.rs
@@ -26,7 +26,7 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
26 } 26 }
27} 27}
28 28
29pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ 29pub(super) const ITEM_RECOVERY_SET: TokenSet = TokenSet::new(&[
30 FN_KW, 30 FN_KW,
31 STRUCT_KW, 31 STRUCT_KW,
32 ENUM_KW, 32 ENUM_KW,
@@ -41,7 +41,7 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![
41 USE_KW, 41 USE_KW,
42 MACRO_KW, 42 MACRO_KW,
43 T![;], 43 T![;],
44]; 44]);
45 45
46pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { 46pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) {
47 let m = p.start(); 47 let m = p.start();
diff --git a/crates/parser/src/grammar/paths.rs b/crates/parser/src/grammar/paths.rs
index 52562afa4..5d297e2d6 100644
--- a/crates/parser/src/grammar/paths.rs
+++ b/crates/parser/src/grammar/paths.rs
@@ -3,7 +3,7 @@
3use super::*; 3use super::*;
4 4
5pub(super) const PATH_FIRST: TokenSet = 5pub(super) const PATH_FIRST: TokenSet =
6 token_set![IDENT, T![self], T![super], T![crate], T![:], T![<]]; 6 TokenSet::new(&[IDENT, T![self], T![super], T![crate], T![:], T![<]]);
7 7
8pub(super) fn is_path_start(p: &Parser) -> bool { 8pub(super) fn is_path_start(p: &Parser) -> bool {
9 is_use_path_start(p) || p.at(T![<]) 9 is_use_path_start(p) || p.at(T![<])
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 07b1d6dd5..796f206e1 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -2,9 +2,18 @@
2 2
3use super::*; 3use super::*;
4 4
5pub(super) const PATTERN_FIRST: TokenSet = expressions::LITERAL_FIRST 5pub(super) const PATTERN_FIRST: TokenSet =
6 .union(paths::PATH_FIRST) 6 expressions::LITERAL_FIRST.union(paths::PATH_FIRST).union(TokenSet::new(&[
7 .union(token_set![T![box], T![ref], T![mut], T!['('], T!['['], T![&], T![_], T![-], T![.]]); 7 T![box],
8 T![ref],
9 T![mut],
10 T!['('],
11 T!['['],
12 T![&],
13 T![_],
14 T![-],
15 T![.],
16 ]));
8 17
9pub(crate) fn pattern(p: &mut Parser) { 18pub(crate) fn pattern(p: &mut Parser) {
10 pattern_r(p, PAT_RECOVERY_SET); 19 pattern_r(p, PAT_RECOVERY_SET);
@@ -74,7 +83,7 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
74} 83}
75 84
76const PAT_RECOVERY_SET: TokenSet = 85const PAT_RECOVERY_SET: TokenSet =
77 token_set![LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA]; 86 TokenSet::new(&[LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA]);
78 87
79fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> { 88fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
80 let m = match p.nth(0) { 89 let m = match p.nth(0) {
diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs
index 9d00eb9b9..1ea130ac5 100644
--- a/crates/parser/src/grammar/types.rs
+++ b/crates/parser/src/grammar/types.rs
@@ -2,7 +2,7 @@
2 2
3use super::*; 3use super::*;
4 4
5pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(token_set![ 5pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(TokenSet::new(&[
6 T!['('], 6 T!['('],
7 T!['['], 7 T!['['],
8 T![<], 8 T![<],
@@ -16,16 +16,16 @@ pub(super) const TYPE_FIRST: TokenSet = paths::PATH_FIRST.union(token_set![
16 T![for], 16 T![for],
17 T![impl], 17 T![impl],
18 T![dyn], 18 T![dyn],
19]); 19]));
20 20
21const TYPE_RECOVERY_SET: TokenSet = token_set![ 21const TYPE_RECOVERY_SET: TokenSet = TokenSet::new(&[
22 T![')'], 22 T![')'],
23 T![,], 23 T![,],
24 L_DOLLAR, 24 L_DOLLAR,
25 // test_err struct_field_recover 25 // test_err struct_field_recover
26 // struct S { f pub g: () } 26 // struct S { f pub g: () }
27 T![pub], 27 T![pub],
28]; 28]);
29 29
30pub(crate) fn type_(p: &mut Parser) { 30pub(crate) fn type_(p: &mut Parser) {
31 type_with_bounds_cond(p, true); 31 type_with_bounds_cond(p, true);