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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! The parent-list shapes `role_table!` rejects (#1794), each a
//! `compile_fail` doctest that differs from the control below in one
//! respect only. Kept off the macro's own doc so they do not count
//! against `roles/mod.rs`: this module exists only under `cfg(doctest)`,
//! where rustdoc collects a private module's doc comments too.
//!
//! The control: every attribute the rejections combine, one per owner.
//!
//! ```
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::{Ancestors, Java, Node};
//! fn always(_: &Node<'_>, _: Ancestors<'_, '_>) -> bool { true }
//! fn always_text(_: &Node<'_>, _: &[u8], _: Ancestors<'_, '_>) -> bool { true }
//! role_table! {
//! lang: Java;
//! Exit {
//! owns [ReturnStatement(gated_by always), ThrowStatement(under [Block]),
//! YieldStatement(not_under [ClassBody])]
//! }
//! Comparison {
//! owns [BinaryExpression(holds_payer), InstanceofExpression(text_gated_by always_text)]
//! pays [EQEQ under [BinaryExpression]]
//! }
//! }
//! # fn main() {}
//! ```
//!
//! A parent list is the owner's gate, so it sits beside no other gate
//! and no `holds_payer`, in either order:
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::{Ancestors, Java, Node};
//! fn always(_: &Node<'_>, _: Ancestors<'_, '_>) -> bool { true }
//! role_table! {
//! lang: Java;
//! Exit { owns [ReturnStatement(under [Block] gated_by always)] }
//! }
//! # fn main() {}
//! ```
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::{Ancestors, Java, Node};
//! fn always(_: &Node<'_>, _: Ancestors<'_, '_>) -> bool { true }
//! role_table! {
//! lang: Java;
//! Exit { owns [ReturnStatement(gated_by always under [Block])] }
//! }
//! # fn main() {}
//! ```
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::{Ancestors, Java, Node};
//! fn always_text(_: &Node<'_>, _: &[u8], _: Ancestors<'_, '_>) -> bool { true }
//! role_table! {
//! lang: Java;
//! Comparison { owns [InstanceofExpression(under [Block] text_gated_by always_text)] pays [EQEQ] }
//! }
//! # fn main() {}
//! ```
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::Java;
//! role_table! {
//! lang: Java;
//! Comparison { owns [BinaryExpression(holds_payer under [Block])] pays [EQEQ] }
//! }
//! # fn main() {}
//! ```
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::Java;
//! role_table! {
//! lang: Java;
//! Comparison { owns [BinaryExpression(under [Block] holds_payer)] pays [EQEQ] }
//! }
//! # fn main() {}
//! ```
//!
//! An owner takes one list, so not one of each direction:
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::Java;
//! role_table! {
//! lang: Java;
//! Exit { owns [ThrowStatement(under [Block] not_under [ClassBody])] }
//! }
//! # fn main() {}
//! ```
//!
//! And a list names at least one kind, an owner's or a payer's — an
//! empty one would claim the kind and never admit it. The row body
//! requires it as well as the entry scan, so a `..fragment!()` whose
//! splice spells `K under []` is refused where a row's own `pays` is:
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::Java;
//! role_table! {
//! lang: Java;
//! Exit { owns [YieldStatement(not_under [])] }
//! }
//! # fn main() {}
//! ```
//!
//! ```compile_fail
//! # #[macro_use] extern crate big_code_analysis_ast;
//! # use big_code_analysis_ast::Java;
//! role_table! {
//! lang: Java;
//! Comparison { owns [BinaryExpression] pays [EQEQ under []] }
//! }
//! # fn main() {}
//! ```