diff options
author | Aleksey Kladov <[email protected]> | 2018-01-01 20:22:01 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-01 20:22:01 +0000 |
commit | 55602727c8adfa12c026a8c7881a8bc57fba9db8 (patch) | |
tree | afebee4b834ba25b870b194e09a9d069cb922a38 /src | |
parent | 46422f722bdcadbf4462dd5a9c65756434b2d97a (diff) |
Parser: first struct :-)
Diffstat (limited to 'src')
-rw-r--r-- | src/parser/event_parser/grammar.rs | 7 | ||||
-rw-r--r-- | src/parser/event_parser/parser.rs | 9 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/parser/event_parser/grammar.rs b/src/parser/event_parser/grammar.rs index 0896506fb..be61483ec 100644 --- a/src/parser/event_parser/grammar.rs +++ b/src/parser/event_parser/grammar.rs | |||
@@ -43,13 +43,18 @@ fn item(p: &mut Parser) -> Result { | |||
43 | if p.current_is(STRUCT_KW) { | 43 | if p.current_is(STRUCT_KW) { |
44 | p.start(STRUCT_ITEM); | 44 | p.start(STRUCT_ITEM); |
45 | p.bump(); | 45 | p.bump(); |
46 | let _ = struct_item(p); | ||
46 | p.finish(); | 47 | p.finish(); |
47 | return OK; | 48 | return OK; |
48 | } | 49 | } |
49 | ERR | 50 | ERR |
50 | } | 51 | } |
51 | 52 | ||
52 | 53 | fn struct_item(p: &mut Parser) -> Result{ | |
54 | p.expect(IDENT)?; | ||
55 | p.expect(L_CURLY)?; | ||
56 | p.expect(R_CURLY) | ||
57 | } | ||
53 | 58 | ||
54 | // Paths, types, attributes, and stuff // | 59 | // Paths, types, attributes, and stuff // |
55 | 60 | ||
diff --git a/src/parser/event_parser/parser.rs b/src/parser/event_parser/parser.rs index 2d5418a29..36452ef67 100644 --- a/src/parser/event_parser/parser.rs +++ b/src/parser/event_parser/parser.rs | |||
@@ -69,6 +69,15 @@ impl<'t> Parser<'t> { | |||
69 | Some(kind) | 69 | Some(kind) |
70 | } | 70 | } |
71 | 71 | ||
72 | pub(crate) fn expect(&mut self, kind: SyntaxKind) -> Result<(), ()> { | ||
73 | if kind == self.current().ok_or(())? { | ||
74 | self.bump(); | ||
75 | Ok(()) | ||
76 | } else { | ||
77 | Err(()) | ||
78 | } | ||
79 | } | ||
80 | |||
72 | fn event(&mut self, event: Event) { | 81 | fn event(&mut self, event: Event) { |
73 | self.events.push(event) | 82 | self.events.push(event) |
74 | } | 83 | } |