@@ -6,6 +6,7 @@ pub enum TopLevel<'a> {
66 Class ( Class < ' a > ) ,
77 Import ( Import < ' a > ) ,
88 Module ( Module < ' a > ) ,
9+ Predicate ( Predicate < ' a > ) ,
910}
1011
1112impl fmt:: Display for TopLevel < ' _ > {
@@ -14,6 +15,7 @@ impl fmt::Display for TopLevel<'_> {
1415 TopLevel :: Import ( imp) => write ! ( f, "{}" , imp) ,
1516 TopLevel :: Class ( cls) => write ! ( f, "{}" , cls) ,
1617 TopLevel :: Module ( m) => write ! ( f, "{}" , m) ,
18+ TopLevel :: Predicate ( pred) => write ! ( f, "{}" , pred) ,
1719 }
1820 }
1921}
@@ -72,6 +74,8 @@ impl fmt::Display for Class<'_> {
7274 return_type: None ,
7375 formal_parameters: vec![ ] ,
7476 body: charpred. clone( ) ,
77+ pragma: None ,
78+ overlay: None ,
7579 }
7680 ) ?;
7781 }
@@ -150,6 +154,7 @@ pub enum Expression<'a> {
150154 expr : Box < Expression < ' a > > ,
151155 second_expr : Option < Box < Expression < ' a > > > ,
152156 } ,
157+ Negation ( Box < Expression < ' a > > ) ,
153158}
154159
155160impl fmt:: Display for Expression < ' _ > {
@@ -231,10 +236,22 @@ impl fmt::Display for Expression<'_> {
231236 }
232237 write ! ( f, ")" )
233238 }
239+ Expression :: Negation ( e) => write ! ( f, "not ({})" , e) ,
234240 }
235241 }
236242}
237243
244+ #[ derive( Clone , Eq , PartialEq , Hash ) ]
245+ pub enum PragmaAnnotation {
246+ Nomagic ,
247+ }
248+
249+ #[ derive( Clone , Eq , PartialEq , Hash ) ]
250+ pub enum OverlayAnnotation {
251+ Local ,
252+ DiscardEntity ,
253+ }
254+
238255#[ derive( Clone , Eq , PartialEq , Hash ) ]
239256pub struct Predicate < ' a > {
240257 pub qldoc : Option < String > ,
@@ -244,13 +261,30 @@ pub struct Predicate<'a> {
244261 pub return_type : Option < Type < ' a > > ,
245262 pub formal_parameters : Vec < FormalParameter < ' a > > ,
246263 pub body : Expression < ' a > ,
264+ pub pragma : Option < PragmaAnnotation > ,
265+ pub overlay : Option < OverlayAnnotation > ,
247266}
248267
249268impl fmt:: Display for Predicate < ' _ > {
250269 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
251270 if let Some ( qldoc) = & self . qldoc {
252271 write ! ( f, "/** {} */" , qldoc) ?;
253272 }
273+ if let Some ( overlay_annotation) = & self . overlay {
274+ write ! ( f, "overlay[" ) ?;
275+ match overlay_annotation {
276+ OverlayAnnotation :: Local => write ! ( f, "local" ) ?,
277+ OverlayAnnotation :: DiscardEntity => write ! ( f, "discard_entity" ) ?,
278+ }
279+ write ! ( f, "] " ) ?;
280+ }
281+ if let Some ( pragma) = & self . pragma {
282+ write ! ( f, "pragma[" ) ?;
283+ match pragma {
284+ PragmaAnnotation :: Nomagic => write ! ( f, "nomagic" ) ?,
285+ }
286+ write ! ( f, "] " ) ?;
287+ }
254288 if self . is_final {
255289 write ! ( f, "final " ) ?;
256290 }
0 commit comments