                Listing Three


%{
/* lex program to recognize integers */

/*
 * This program classifies the digits and calculates their
 * numeric value.  The program stores the value in the global
 * variable "yylval" and returns the classification.
 */

#define YYSTYPE long
#include "dc1.h"
%}

%%

[0-9]+  {
    yylval = atoi(yytext);
    return INTEGER;
}

[-+/*\n()\.]    return *yytext;

[ \t]+      ;

[Qq]        return QUIT;

/* generate a syntax error for other characters */
.       return *yytext;
