aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-02-04 10:39:24 +0000
committerAleksey Kladov <[email protected]>2018-02-04 10:53:05 +0000
commita40b715ce1cae4db1b4c3b4c383ee7517d4202c4 (patch)
tree6d18d8c47065ea28bb4414a52855ad1c2407c81b /src/parser
parent5e5313a7c71d8aa873b418575f56d23b2eac6e7f (diff)
G: unsafe impl & trait
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event_parser/grammar/items/mod.rs18
-rw-r--r--src/parser/event_parser/grammar/items/traits.rs17
2 files changed, 35 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/items/mod.rs b/src/parser/event_parser/grammar/items/mod.rs
index 6d6fabbd7..3612802e1 100644
--- a/src/parser/event_parser/grammar/items/mod.rs
+++ b/src/parser/event_parser/grammar/items/mod.rs
@@ -3,6 +3,7 @@ use super::*;
3mod structs; 3mod structs;
4mod use_item; 4mod use_item;
5mod consts; 5mod consts;
6mod traits;
6 7
7pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { 8pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
8 attributes::inner_attributes(p); 9 attributes::inner_attributes(p);
@@ -80,6 +81,22 @@ fn item(p: &mut Parser) {
80 CONST_ITEM 81 CONST_ITEM
81 } 82 }
82 }, 83 },
84 // TODO: auto trait
85 // test unsafe_trait
86 // unsafe trait T {}
87 UNSAFE_KW if la == TRAIT_KW => {
88 p.bump();
89 traits::trait_item(p);
90 TRAIT_ITEM
91 }
92 // TODO: default impl
93 // test unsafe_impl
94 // unsafe impl Foo {}
95 UNSAFE_KW if la == IMPL_KW => {
96 p.bump();
97 traits::impl_item(p);
98 IMPL_ITEM
99 }
83 MOD_KW => { 100 MOD_KW => {
84 mod_item(p); 101 mod_item(p);
85 MOD_ITEM 102 MOD_ITEM
@@ -131,6 +148,7 @@ fn extern_block(p: &mut Parser) {
131 p.bump(); 148 p.bump();
132 p.expect(R_CURLY); 149 p.expect(R_CURLY);
133} 150}
151
134fn mod_item(p: &mut Parser) { 152fn mod_item(p: &mut Parser) {
135 assert!(p.at(MOD_KW)); 153 assert!(p.at(MOD_KW));
136 p.bump(); 154 p.bump();
diff --git a/src/parser/event_parser/grammar/items/traits.rs b/src/parser/event_parser/grammar/items/traits.rs
new file mode 100644
index 000000000..3bef9639f
--- /dev/null
+++ b/src/parser/event_parser/grammar/items/traits.rs
@@ -0,0 +1,17 @@
1use super::*;
2
3pub(super) fn trait_item(p: &mut Parser) {
4 assert!(p.at(TRAIT_KW));
5 p.bump();
6 p.expect(IDENT);
7 p.expect(L_CURLY);
8 p.expect(R_CURLY);
9}
10
11pub(super) fn impl_item(p: &mut Parser) {
12 assert!(p.at(IMPL_KW));
13 p.bump();
14 p.expect(IDENT);
15 p.expect(L_CURLY);
16 p.expect(R_CURLY);
17}