File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,6 +97,12 @@ pub enum Expression<'a> {
9797 Or ( Vec < Expression < ' a > > ) ,
9898 Equals ( Box < Expression < ' a > > , Box < Expression < ' a > > ) ,
9999 Dot ( Box < Expression < ' a > > , & ' a str , Vec < Expression < ' a > > ) ,
100+ Aggregate (
101+ & ' a str ,
102+ Vec < FormalParameter < ' a > > ,
103+ Box < Expression < ' a > > ,
104+ Box < Expression < ' a > > ,
105+ ) ,
100106}
101107
102108impl < ' a > fmt:: Display for Expression < ' a > {
@@ -138,6 +144,16 @@ impl<'a> fmt::Display for Expression<'a> {
138144 }
139145 write ! ( f, ")" )
140146 }
147+ Expression :: Aggregate ( n, vars, range, term) => {
148+ write ! ( f, "{}(" , n) ?;
149+ for ( index, var) in vars. iter ( ) . enumerate ( ) {
150+ if index > 0 {
151+ write ! ( f, ", " ) ?;
152+ }
153+ write ! ( f, "{}" , var) ?;
154+ }
155+ write ! ( f, " | {} | {})" , range, term)
156+ }
141157 }
142158 }
143159}
Original file line number Diff line number Diff line change @@ -52,11 +52,22 @@ fn create_ast_node_class<'a>() -> ql::Class<'a> {
5252 return_type : Some ( ql:: Type :: Normal ( "AstNode" ) ) ,
5353 formal_parameters : vec ! [ ] ,
5454 body : ql:: Expression :: Equals (
55- Box :: new ( ql:: Expression :: Var ( "this" ) ) ,
56- Box :: new ( ql:: Expression :: Dot (
57- Box :: new ( ql:: Expression :: Var ( "result" ) ) ,
58- "getAFieldOrChild" ,
59- vec ! [ ] ,
55+ Box :: new ( ql:: Expression :: Var ( "result" ) ) ,
56+ Box :: new ( ql:: Expression :: Aggregate (
57+ "unique" ,
58+ vec ! [ ql:: FormalParameter {
59+ name: "parent" ,
60+ param_type: ql:: Type :: Normal ( "AstNode" ) ,
61+ } ] ,
62+ Box :: new ( ql:: Expression :: Equals (
63+ Box :: new ( ql:: Expression :: Var ( "this" ) ) ,
64+ Box :: new ( ql:: Expression :: Dot (
65+ Box :: new ( ql:: Expression :: Var ( "parent" ) ) ,
66+ "getAFieldOrChild" ,
67+ vec ! [ ] ,
68+ ) ) ,
69+ ) ) ,
70+ Box :: new ( ql:: Expression :: Var ( "parent" ) ) ,
6071 ) ) ,
6172 ) ,
6273 } ;
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ class AstNode extends @ast_node {
1111
1212 Location getLocation ( ) { none ( ) }
1313
14- AstNode getParent ( ) { this = result .getAFieldOrChild ( ) }
14+ AstNode getParent ( ) {
15+ result = unique( AstNode parent | this = parent .getAFieldOrChild ( ) | parent )
16+ }
1517
1618 AstNode getAFieldOrChild ( ) { none ( ) }
1719
You can’t perform that action at this time.
0 commit comments