Index: libabac/rt2.y
===================================================================
--- libabac/rt2.y	(revision 7211a95f1601147c8c72a41f8043ef08062de055)
+++ libabac/rt2.y	(revision 2e9455f11fea0205b8b4b1306b5d0804cda72e10)
@@ -11,5 +11,6 @@
 
 #include "abac_pl_yy.h"
-#include "abac_list.h"
+#include "abac_verifier.h"
+#include "rt2.h"
 
 /* lex tie-ins flag */
@@ -19,7 +20,8 @@
 FILE *abac_yyout = NULL;
 char *abac_yyfptr = NULL;
-char *abac_yyfptr_encoded = NULL;
+void *abac_yyctxt=NULL;
 
 #define USE(evalue) ((getenv(evalue)!=NULL)?1:0)
+#define OUT(msg) { if(debug) fprintf(abac_yyout,"\n===%s\n",msg); }
 
 void panic(char *msg);
@@ -41,5 +43,5 @@
 %start input
 
-%type <lstruct> stmt
+%type <intval> stmt
 %type <rostruct> rolepart 
 %type <estruct> roleleft 
@@ -64,4 +66,5 @@
 %token <string> OSET                /* the word, oset */
 %token <string> PRINCIPAL           /* the word, principal */
+%token <string> THIS                /* the word, this */
 %token <string> OTYPE               /* integer,boolean,urn,time,string,float */
 %token <string> OTYPE_CONSTANT      
@@ -92,5 +95,5 @@
      | stmt 
              {  
-               abac_yy_set_rule_clauses($1);
+               /* SUCCESS */
              }
      ;
@@ -101,10 +104,10 @@
                abac_yy_expression_t *headexpr=$1;
                abac_yy_expression_t *tailexpr=$3;
-               abac_list_t *ret=make_role_statement(headexpr, tailexpr);
-               if(ret == NULL) {
+               int rc=make_role_statement(headexpr, tailexpr);
+               if(rc) {
                    panic("unable to parse the role rule statment");
                    YYERROR;
                    } else {
-                       $$=ret;
+                       $$=rc;
                }
              }
@@ -113,10 +116,10 @@
                abac_yy_expression_t *headexpr=$1;
                abac_yy_expression_t *tailexpr=$3;
-               abac_list_t *ret=make_oset_statement(headexpr, tailexpr);
-               if(ret == NULL) {
+               int rc=make_oset_statement(headexpr, tailexpr);
+               if(rc) {
                    panic("unable to parse the oset rule statment");
                    YYERROR;
                    } else {
-                       $$=ret;
+                       $$=rc;
                }
              }
@@ -138,7 +141,7 @@
 /* [keyid:mike] */
 keypart : LSQUARE KEYTYPE COLON
-             { abac_push_keyid_yystate(); }
+             { abac_ll_push_keyid_yystate(); }
           KEYID_CONSTANT
-             { abac_pop_yystate(); }
+             { abac_ll_pop_yystate(); }
           RSQUARE 
              { 
@@ -146,9 +149,10 @@
                char *tmp=NULL;
                asprintf(&tmp,"%s",$5);
+               $$=make_yy_principal(tmp, tmp, idtype);
                char *cn=abac_cn_with_sha(tmp);
                if(cn && idtype)  {
                  $$=make_yy_principal(tmp, cn, idtype);
                  } else {
-                     if((USE("ABAC_CN")) && cn==NULL) {
+                     if((USE("ABAC_CN")) && (cn==NULL)) {
                          if(debug)
                              asprintf(&tmp,"encountered an invalid SHA id(%s)",$5);
@@ -181,7 +185,7 @@
    [keyid:mike]
    [principal:?Z]
-   [principal:?this]
    [int:99]
    [int:?Z]
+   [?this], this could be any of type...
    [?]
 */
@@ -198,5 +202,7 @@
      ;
 
-term : LSQUARE QMARK RSQUARE 
+term : LSQUARE QMARK THIS RSQUARE 
+             { $$= make_yy_term_dterm_this(); }
+     | LSQUARE QMARK RSQUARE 
              { $$= make_yy_term_dterm_anonymous(); }
      | keypart 
@@ -231,12 +237,16 @@
 /* urn same as string */
 /* time like int but with quoted string values */
+/* XXX would have to extend this if want the linked oset in the
+   constraints..
+   [otype:?Z{linked oset-constraint}]
+*/
 otypetail :  VARIABLE_CONSTANT COLON 
              { 
-               abac_pop_yystate();
-               abac_push_range_yystate();
+               abac_ll_pop_yystate();
+               abac_ll_push_range_yystate();
              }
             rangetype 
             {
-              abac_pop_yystate();
+              abac_ll_pop_yystate();
               abac_yy_term_data_t *ptr=make_yy_term_data();
               set_yy_term_data_name(ptr,$1);
@@ -244,8 +254,9 @@
               set_yy_term_data_cond_range(ptr,$4);
               $$=ptr;
+              OUT("otypetail_1");
             }
      | VARIABLE_CONSTANT 
-            { abac_pop_yystate(); }
-            osetleft 
+            { abac_ll_pop_yystate(); }
+            osetterm 
             {
               abac_yy_term_data_t *ptr=make_yy_term_data();
@@ -254,23 +265,26 @@
               set_yy_term_data_cond_head_expr(ptr,$3);
               $$=ptr;
+              OUT("otypetail_2");
             }
      | VARIABLE_CONSTANT
             {
-              abac_pop_yystate();
+              abac_ll_pop_yystate();
               abac_yy_term_data_t *ptr=make_yy_term_data();
               set_yy_term_data_name(ptr,$1);
               set_yy_term_data_is_variable(ptr);
               $$=ptr;
+              OUT("otypetail_3");
             }
      | OTYPE_CONSTANT
             {
-              abac_pop_yystate();
+              abac_ll_pop_yystate();
               abac_yy_term_data_t *ptr=make_yy_term_data();
               set_yy_term_data_name(ptr,$1);
               $$=ptr;
+              OUT("otypetail_4");
             }
      | QMARK
             {
-              abac_pop_yystate();
+              abac_ll_pop_yystate();
               abac_yy_term_data_t *ptr=make_yy_term_data();
               set_yy_term_data_is_anonymous(ptr);
@@ -280,5 +294,5 @@
 
 typedpart  : LSQUARE OTYPE COLON 
-             { abac_push_yystate($2); }
+             { abac_ll_push_yystate($2); }
              otypetail RSQUARE
              { 
@@ -295,9 +309,14 @@
 
 
+
 /* [principal:?] */
 /* [principal:?Z] */
 /* [principal:?This] */
-/* [principal:?Z:{role-constraint}] */
-principalpart : LSQUARE PRINCIPAL COLON QMARK IDEN roleleft RSQUARE 
+/* [principal:?Z{role-constraint}] */
+/* XXX if want to allow linked role constraint need to swap roleleft
+       into roleterm.. but make sure the tree is right
+3/21/13, [principal:?Z[keyid:A].role:roleA.role:roleB([string:?P])] 
+*/
+principalpart : LSQUARE PRINCIPAL COLON QMARK IDEN roleterm RSQUARE 
                 { 
                   abac_yy_expression_t *expr=$6;
@@ -308,4 +327,5 @@
                   make_yy_role_constraint(ptr,tail_string);
                   $$=ptr;
+                  OUT("principalpart_1");
                 }
               | LSQUARE PRINCIPAL COLON QMARK IDEN RSQUARE 
@@ -314,4 +334,5 @@
                   set_yy_term_principal_name(ptr,$5);
                   $$ = ptr;
+                  OUT("principalpart_2");
                 }
               | LSQUARE PRINCIPAL COLON QMARK RSQUARE 
@@ -320,4 +341,5 @@
                   set_yy_term_principal_is_anonymous(ptr);
                   $$ = ptr;
+                  OUT("principalpart_3");
                 }
      ;
@@ -346,4 +368,5 @@
                   make_yy_expression(e_yy_EXPR_LINKED,keypart,rolepart,linked_rolepart);
                $$=expr;
+               OUT("roleterm_1");
              }
      | keypart DOT rolepart
@@ -354,4 +377,5 @@
                    make_yy_expression(e_yy_EXPR_ROLE,keypart,rolepart,NULL);
                $$=expr;
+               OUT("roleterm_2");
              }
      | keypart
@@ -361,4 +385,5 @@
                    make_yy_expression(e_yy_EXPR_NAMED,keypart,NULL,NULL);
                $$=expr;
+               OUT("roleterm_3");
              }
      ;
@@ -372,4 +397,5 @@
                   make_yy_expression(e_yy_EXPR_LINKED,keypart,osetpart,linked_rolepart);
                $$=expr;
+               OUT("osetterm_1");
              }
      | keypart DOT osetpart
@@ -380,4 +406,5 @@
                    make_yy_expression(e_yy_EXPR_OSET,keypart,osetpart,NULL);
                $$=expr;
+               OUT("osetterm_2");
              }
      | keypart
@@ -387,4 +414,5 @@
                    make_yy_expression(e_yy_EXPR_NAMED,keypart,NULL,NULL);
                $$=expr;
+               OUT("osetterm_3");
              }
      | typedpart 
@@ -394,4 +422,5 @@
                    make_yy_expression(e_yy_EXPR_OBJECT,objpart,NULL,NULL);
                $$=expr;
+               OUT("osetterm_4");
              }
      ;
@@ -418,4 +447,5 @@
                     make_yy_expression(e_yy_EXPR_OSET,keypart,osetpart,NULL);
                $$=expr;
+               OUT("osetleft");
              }
      ;
@@ -426,7 +456,11 @@
                abac_yy_expression_t *exprs=$3;
                $$=add_yy_expression(nexpr,exprs);
+               OUT("osetright_1");
              }
      | osetterm
-             { $$=$1; }
+             { 
+               $$=$1; 
+               OUT("osetright_2");
+             }
      ;
 %%
@@ -448,13 +482,12 @@
 void abac_yyinit()
 {
-    abac_yyout=abac_get_yyout();
-    abac_yyfptr = abac_get_yyfptr();
-    abac_yyfptr_encoded = abac_get_yyfptr_encoded();
-    if(debug)
-        fprintf (abac_yyout,"\n=======================================\n");
+    abac_yyout=abac_ll_get_yyout();
+    abac_yyfptr = abac_ll_get_yyfptr();
+    OUT("======================================");
 }
 
 void panic(char *msg) 
 {
+     OUT("panic, EEEEKKKKKK...");
      yyerror(msg);
 }
