The DejaVU Framework -- hush 3.0
[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?

scanner: ooly.l hush-3.1/grammar/filters


[.] - [up] [top] - index README text make grammar configure slides talks
  
  

ooly


  static int _pr[3] = { 0, 0, 0 };
  static int max=7;
  static int gg=0;
  static int _op = 0;
  static int _prec = 0;
  static int _expr = 0;
  static int _defaults = 0;
  
  

slide: ooly


predefined tokens


  
  static char* op[] = {
          "OP","LOP","ROP","PRE","POS",
          "SPEC","DECL","QUAL",
          "MODE","META",
          "STOP","COMM","ATOM","TYPE",
          "END",
          NULL };
  
  static void printop();
  static void printprec();
  static void printexpr();
  
  name [A-Za-z][A-Z_a-z0-9]*
  

slide: predefined tokens


rules


  ^\%"class "{name} {
          printf("\n\n\n%%{\n#define CLASS %s\n%%}\n",yytext+7);
          printf("\n\n\n%%{\n#define NAME %s\n%%}\n",yytext+7);
          //printf("\n\n\n%%{\n#define lex_scanner %s_scanner\n%%}\n",yytext+7);
          }
  ^"%lex "{name} {
          printf("\n\n\n%%{\n#define CLASS %s\n%%}\n",yytext+7);
          printf("\n\n\n%%{\n#define NAME %s\n%%}\n",yytext+5);
          //printf("\n\n\n%%{\n#define lex_scanner %s_lex__scanner\n%%}\n",yytext+5);
          }
  ^"%yacc "{name} {
          printf("\n\n\n%%{\n#define NAME %s\n%%}\n",yytext+6);
          }
  ^"%nodef".* { _op = 1; _prec = 1; _expr = 1; }
  ^"%defau".* { _defaults; _op = 1; printop(); }
  ^"%op".* { _op = 1; printop(); }
  ^"%noop".* { _op = 1; }
  ^"%prec".* { _prec = 1; printprec(); }
  ^"%noprec".* { _prec = 1; }
  ^"%expr".* { _expr = 1; printexpr(); }
  ^"%noexpr".* { _expr = 1; }
  ^\%\%.*   {
            if (!gg) {
                  if (_op && !_prec) printprec();
                   printf("\n  
%");

if (_op && !_expr) printexpr(); gg++; } else if (gg==1) { if (yyleng==2) // || (yyleng > 2 && yytext[3]=='<')) printf("\n
%");

} }

slide: rules


printop()


  
  static void printop() {
          int i = 0; int j;
          _pr[0] = 1;
          for (i = 0; op[i] ; i++) {
           printf("\n%%token ");
           for (j=0;j<=max;j++) { 
                  printf("%s%d ",op[i],j); 
                  }
           }
  }
  
  

slide: printop()


printprec()


  
  static void printprec() {
   _pr[1] = 1;
   printf("\n%%right ROP7 POS7 TYPE7 ");
   printf("\n%%left  OP7  LOP7 PRE7 ");
   printf("\n%%right ROP6 POS6 TYPE6 ");
   printf("\n%%left  OP6  LOP6 PRE6 ");
   printf("\n%%right ROP5 POS5 TYPE5 ");
   printf("\n%%left  OP5  LOP5 PRE5 ");
   printf("\n%%right ROP4 POS4 TYPE4 ");
   printf("\n%%left  OP4  LOP4 PRE4 ");
   printf("\n%%right ROP3 POS3 TYPE3 ");
   printf("\n%%left  OP3  LOP3 PRE3 '~' '>' '<' '=' ");
   printf("\n%%right ROP2 POS2 TYPE2 ");
   printf("\n%%left  OP2 LEFT2 PRE2  '*'  '/' ");
   printf("\n%%right ROP1 POS1 TYPE1 ");
   printf("\n%%left  OP1 LOP1 PRE1 '-' '?' '+' '!' ");
   printf("\n%%right ROP0 POS0 TYPE0 ");
   printf("\n%%left  OP0 LOP0 PRE0  ");
  }
  
  

slide: printprec()


printexpr()


  
  static void printexpr() {
  _pr[2] = 1;
  printf("\nEXPR : OPEX ; ");
  printf("\n ");
  printf("\nAOP : '+' | '-' | '*' | '/' ; ");
  printf("\nCOP : '=' | '<' | '>' | '~' ; ");
  printf("\nSOP : '?' | '!' | ':' | '@' | '^' ; ");
  printf("\n ");
  printf("\nOP : AOP | COP | SOP | GOP | LOP | ROP ; ");
  printf("\nGOP: OP0|OP1|OP2|OP3|OP4|OP5|OP6|OP7; ");
  printf("\nLOP: LOP0|LOP1|LOP2|LOP3|LOP4|LOP5|LOP6|LOP7; ");
  printf("\nROP: ROP0|ROP1|ROP2|ROP3|ROP4|ROP5|ROP6|ROP7; ");
  printf("\nPRE: PRE0|PRE1|PRE2|PRE3|PRE4|PRE5|PRE6|PRE7; ");
  printf("\nPOS: POS0|POS1|POS2|POS3|POS4|POS5|POS6|POS7; ");
  printf("\n ");
  printf("\nDECL: DECL0|DECL1|DECL2|DECL3|DECL4|DECL5|DECL6|DECL7; ");
  printf("\nSPEC: SPEC0|SPEC1|SPEC2|SPEC3|SPEC4|SPEC5|SPEC6|SPEC7; ");
  printf("\nQUAL: QUAL0|QUAL1|QUAL2|QUAL3|QUAL4|QUAL5|QUAL6|QUAL7; ");
  printf("\n ");
  printf("\nMODE: MODE0|MODE1|MODE2|MODE3|MODE4|MODE5|MODE6|MODE7; ");
  printf("\nMETA: META0|META1|META2|META3|META4|META5|META6|META7; ");
  printf("\n ");
  printf("\nSTOP: STOP0|STOP1|STOP2|STOP3|STOP4|STOP5|STOP6|STOP7; ");
  printf("\nCOMM: COMM0|COMM1|COMM2|COMM3|COMM4|COMM5|COMM6|COMM7; ");
  printf("\nATOM: ATOM0|ATOM1|ATOM2|ATOM3|ATOM4|ATOM5|ATOM6|ATOM7; ");
  printf("\nTYPE: TYPE0|TYPE1|TYPE2|TYPE3|TYPE4|TYPE5|TYPE6|TYPE7; ");
  printf("\n ");
  printf("\nEND: END0|END1|END2|END3|END4|END5|END6|END7; ");
  printf("\n ");
  printf("\nOPEX: term OP term { $$ = mkterm(strof($2),$1,$3); } ");
  printf("\n    | OP  term     { $$ = mkterm(strof($1),$2); } ");
  printf("\n    | term OP      { $$ = mkterm(strof($2),$1); } ");
  printf("\n    | PRE term     { $$ = mkterm(strof($1),$2); } ");
  printf("\n    | term POS    { $$ = mkterm(strof($2),$1); } ");
  printf("\n    | TYPE term     { $$ = mkterm(strof($1),$2); } ");
  printf("\n    | term ':' TYPE    { $$ = mkterm(strof($3),$1); } ");
  printf("\n    ; ");
  printf("\n ");
  }
  
  

slide: printexpr()

  

[.] Papers Tutorials Examples Manuals Interfaces Sources Packages Resources ?
Hush Online Technology
hush@cs.vu.nl
11/03/98