From: <hib...@li...> - 2006-04-20 21:31:21
|
Author: ste...@jb... Date: 2006-04-20 17:31:04 -0400 (Thu, 20 Apr 2006) New Revision: 9774 Modified: branches/HQL_ANTLR_2/Hibernate3/grammar/hql-resolve.g Log: refactor to PersisterReference stuff Modified: branches/HQL_ANTLR_2/Hibernate3/grammar/hql-resolve.g =================================================================== --- branches/HQL_ANTLR_2/Hibernate3/grammar/hql-resolve.g 2006-04-20 21:26:31 UTC (rev 9773) +++ branches/HQL_ANTLR_2/Hibernate3/grammar/hql-resolve.g 2006-04-20 21:31:04 UTC (rev 9774) @@ -33,6 +33,8 @@ tokens { PROPERTY_REF; + ENTITY_PERSISTER_REF; + COLLECTION_PERSISTER_REF; BOGUS; } @@ -49,6 +51,25 @@ protected void defineRange(AST range,String path,AST alias, AST fetch) { } + protected AST buildEntityPersisterReference(String entityName, AST alias) { + return null; + } + + protected AST buildThetaJoinNode(AST persisterReference) { + return null; + } + + protected AST buildExplicitPropertyJoinNode(AST propertyReference, AST alias, AST joinType, AST fetch, AST propertyFetch, AST withClause) { + return null; + } + + protected AST buildAdHocJoinNode(AST persisterReference, AST joinType, AST onClause) { + return null; + } + + protected boolean isEntityName(String test) { + return false; + } } // The main statement rule. @@ -97,35 +118,55 @@ // -- Language sub-elements -- + fromClause - : #(f:FROM { pushContext(#fromClause,f); } ( range | join | filter ) * ) +// : #( f:FROM { pushContext(#fromClause, f); } entityPersisterReference ( thetaJoin | explicitJoin )* ) + : #( f:FROM { pushContext(#fromClause, f); } range ( thetaJoin | explicitJoin )* ) ; -// Antlr note: The '!' prevents the automatic creation of the output AST, so the semantic action can do it. -range - { - String p = ""; +range! + : #( RANGE e:entityPersisterReference) { + #range = #e; } - : #(RANGE p=pathAsString! (a:ALIAS!)? (f:FETCH!)? ) - { - defineRange(#range,p,a,f); // Set up the output tree. + ; + +entityPersisterReference! { + String p = ""; } + : p=pathAsString! (a:ALIAS!)? { + #entityPersisterReference = buildEntityPersisterReference( p, a ); + } ; -join - : #(JOIN (joinType )? (FETCH)? propertyRef [true] (ALIAS)? (FETCH)? (WITH)? ) +thetaJoin! +// : #( COMMA e:entityPersisterReference ) { +// #thetaJoin = buildThetaJoinNode( e ); +// } + : r:range { + #thetaJoin = buildThetaJoinNode( #r ); + } ; +explicitJoin! + : #(JOIN (jt:joinType)? joinRhs[jt] ) + ; + +joinRhs [AST joinType] + : { isEntityName( pathAsString( _t ) ) }? e:entityPersisterReference (on:ON)? { + buildAdHocJoinNode( #e, joinType, on ); + } + | (f:FETCH)? ref:propertyRef[true] (a:ALIAS)? (pf:FETCH)? (with:WITH)? { + buildExplicitPropertyJoinNode( #ref, a, joinType, f, pf, with ); + } + ; + +// TODO : need to add cross joins joinType : ( (LEFT | RIGHT) (OUTER)? ) | FULL | INNER ; -filter - : fe:FILTER_ENTITY a:ALIAS - ; - intoClause : #(i:INTO { pushContext(#intoClause,i); } (subtree)* ) ; |