/* File........ parser1.lex 
 * Contents.... Exemple of small parser usin LEX 
 *
 * compilation: 
 *    flex parser1.lex 
 *    gcc -o parser1.exe lexyy.c
 */


/* ---------------- Definitions space ----------------- */
%option noyywrap
%{
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

  int num_matches = 0;
%}


/* ------------------- Rules space -------------------- */
%%

^[ab]*aaa[ab]*$             {++num_matches; printf("\nThe match was : %s", yytext);}
.            {}

%%

/* ----------------- User code space ------------------ */
main()
{
  printf("Listing matches for 'All words containing three consecutive a.'\n");
  yylex();
  printf("--- Number of matches found: %d\n", num_matches);
}
