diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/parser/event_parser/grammar.rs | 17 | ||||
-rw-r--r-- | src/syntax_kinds.rs | 4 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/parser/event_parser/grammar.rs b/src/parser/event_parser/grammar.rs index f26cbc4f6..09b2f02b2 100644 --- a/src/parser/event_parser/grammar.rs +++ b/src/parser/event_parser/grammar.rs | |||
@@ -22,8 +22,12 @@ fn inner_attributes(_: &mut Parser) { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | fn item_first(p: &Parser) -> bool { | 24 | fn item_first(p: &Parser) -> bool { |
25 | match p.current() { | 25 | let current = match p.current() { |
26 | Some(STRUCT_KW) => true, | 26 | Some(c) => c, |
27 | None => return false, | ||
28 | }; | ||
29 | match current { | ||
30 | STRUCT_KW | FN_KW => true, | ||
27 | _ => false, | 31 | _ => false, |
28 | } | 32 | } |
29 | } | 33 | } |
@@ -31,7 +35,8 @@ fn item_first(p: &Parser) -> bool { | |||
31 | fn item(p: &mut Parser) { | 35 | fn item(p: &mut Parser) { |
32 | outer_attributes(p); | 36 | outer_attributes(p); |
33 | visibility(p); | 37 | visibility(p); |
34 | node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item); | 38 | node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) |
39 | || node_if(p, FN_KW, FN_ITEM, fn_item); | ||
35 | } | 40 | } |
36 | 41 | ||
37 | fn struct_item(p: &mut Parser) { | 42 | fn struct_item(p: &mut Parser) { |
@@ -45,6 +50,12 @@ fn struct_field(p: &mut Parser) -> bool { | |||
45 | }) | 50 | }) |
46 | } | 51 | } |
47 | 52 | ||
53 | fn fn_item(p: &mut Parser) { | ||
54 | p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) | ||
55 | && p.curly_block(|p| ()); | ||
56 | } | ||
57 | |||
58 | |||
48 | // Paths, types, attributes, and stuff // | 59 | // Paths, types, attributes, and stuff // |
49 | 60 | ||
50 | fn outer_attributes(_: &mut Parser) { | 61 | fn outer_attributes(_: &mut Parser) { |
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 4a27b0eae..6099cd6e0 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -61,8 +61,9 @@ pub const SHEBANG: SyntaxKind = SyntaxKind(56); | |||
61 | pub const FILE: SyntaxKind = SyntaxKind(57); | 61 | pub const FILE: SyntaxKind = SyntaxKind(57); |
62 | pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(58); | 62 | pub const STRUCT_ITEM: SyntaxKind = SyntaxKind(58); |
63 | pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(59); | 63 | pub const STRUCT_FIELD: SyntaxKind = SyntaxKind(59); |
64 | pub const FN_ITEM: SyntaxKind = SyntaxKind(60); | ||
64 | 65 | ||
65 | static INFOS: [SyntaxInfo; 60] = [ | 66 | static INFOS: [SyntaxInfo; 61] = [ |
66 | SyntaxInfo { name: "USE_KW" }, | 67 | SyntaxInfo { name: "USE_KW" }, |
67 | SyntaxInfo { name: "FN_KW" }, | 68 | SyntaxInfo { name: "FN_KW" }, |
68 | SyntaxInfo { name: "STRUCT_KW" }, | 69 | SyntaxInfo { name: "STRUCT_KW" }, |
@@ -123,6 +124,7 @@ static INFOS: [SyntaxInfo; 60] = [ | |||
123 | SyntaxInfo { name: "FILE" }, | 124 | SyntaxInfo { name: "FILE" }, |
124 | SyntaxInfo { name: "STRUCT_ITEM" }, | 125 | SyntaxInfo { name: "STRUCT_ITEM" }, |
125 | SyntaxInfo { name: "STRUCT_FIELD" }, | 126 | SyntaxInfo { name: "STRUCT_FIELD" }, |
127 | SyntaxInfo { name: "FN_ITEM" }, | ||
126 | ]; | 128 | ]; |
127 | 129 | ||
128 | pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { | 130 | pub(crate) fn syntax_info(kind: SyntaxKind) -> &'static SyntaxInfo { |