1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::ast::{self, kw};
use crate::parser::{Parse, Parser, Result};
#[derive(Debug)]
pub struct Event<'a> {
pub span: ast::Span,
pub id: Option<ast::Id<'a>>,
pub exports: ast::InlineExport<'a>,
pub ty: EventType<'a>,
}
#[derive(Clone, Debug)]
pub enum EventType<'a> {
Exception(ast::TypeUse<'a, ast::FunctionType<'a>>),
}
impl<'a> Parse<'a> for Event<'a> {
fn parse(parser: Parser<'a>) -> Result<Self> {
let span = parser.parse::<kw::event>()?.0;
let id = parser.parse()?;
let exports = parser.parse()?;
let ty = parser.parse()?;
Ok(Event {
span,
id,
exports,
ty,
})
}
}
impl<'a> Parse<'a> for EventType<'a> {
fn parse(parser: Parser<'a>) -> Result<Self> {
Ok(EventType::Exception(parser.parse()?))
}
}