%{ #include %} %start program %token START END /* each of the tokens mentioned in the Lex file need to be listed here */ %token DIGITS LETTERS %% /* beginning of rules section */ program : START statements END | { yyerror("didn't find a program"); } ; statements : statement | statement SEMI statements ; /* there may be a couple of dozen more productions to be placed here */ /* no need to worry about $$, $1, and so forth. not needed to validate a Gimli program */ /* the expression grammar from the text can be used ALMOST verbatim here */ %% main() { fprintf(stderr, "Starting parse\n"); yyparse(); fprintf(stderr, "Looks good\n"); } yyerror(s) char *s; { fprintf(stderr, "%s\n", s); } yywrap() { return(1); }