Contents    Page-10    Prev    Next    Page+10    Index   

C for Lex Sample


%%       /* C functions */

install_id() {  printf("id  %10s   n = %4d\n",yytext,yyleng);  }

install_num() {  printf("num %10s   n = %4d\n",yytext,yyleng);  }

yywrap() {  return(1);  }   /* lex seems to need this. */

void main()          /* Call yylex repeatedly to test */
  { int res, done;
    done = 0;
    while (done == 0)
      { res = yylex();
        if (res != 0)
           {
            printf("yylex result = %4d\n", res);
           }
           else done = 1;
      }
    exit(0);
    }