lol_html/parser/state_machine/syntax_dsl/
action_list.rs

1macro_rules! action_list {
2    ( | $self:tt, $ctx:tt, $input:ident |>
3        if $cond:ident
4            ( $($if_actions:tt)* )
5        else
6            ( $($else_actions:tt)* )
7    ) => {
8        if $self.$cond() {
9            action_list!(| $self, $ctx, $input |> $($if_actions)*);
10        } else {
11            action_list!(| $self, $ctx, $input |> $($else_actions)*);
12        }
13    };
14
15    ( | $self:tt, $ctx:tt, $input:ident |> { $($code_block:tt)* } ) => ( $($code_block)* );
16
17    ( | $self:tt, $ctx:tt, $input:ident |> $action:ident $($args:expr),*; $($rest:tt)* ) => {
18        trace!(@actions $action $($args:expr)*);
19        action!(| $self, $ctx, $input |> $action $($args),*);
20        action_list!(| $self, $ctx, $input |> $($rest)*);
21    };
22
23     ( | $self:tt, $ctx:tt, $input:ident |> $action:ident ? $($args:expr),*; $($rest:tt)* ) => {
24        trace!(@actions $action $($args:expr)*);
25        action!(| $self, $ctx, $input |> $action ? $($args),*);
26        action_list!(| $self, $ctx, $input |> $($rest)*);
27    };
28
29    // NOTE: state transition should always be in the end of the action list
30    ( | $self:tt, $ctx:tt, $input:ident|> $($transition:tt)+ ) => {
31        trace!(@actions $($transition)+);
32        action!(@state_transition | $self, $ctx, $input |> $($transition)+);
33    };
34
35    // NOTE: end of the action list
36    ( | $self:tt, $ctx:tt, $input:ident |> ) => ();
37}