1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* SI 413 Fall 2013
 * Lab 6
 * Scanner specification for the pat language (part 1)
 * YOUR NAME HERE
 * PARTNER NAME HERE
 */
%{
#include <iostream>
using namespace std;
#include "pat1.tab.hpp"
%}
 
%option noyywrap
 
%%
[a-z][a-zA-Z0-9]* { yylval = new ParseTree(yytext); return SYM; }
"*"               { yylval = new ParseTree(yytext); return FOLD; }
";"               { yylval = new ParseTree(yytext); return STOP; }
":"               { yylval = new ParseTree(yytext); return COLON; }
[A-Z][a-zA-Z0-9]* { yylval = new ParseTree(yytext); return NAME; }
"_r"              { yylval = new ParseTree(yytext); return REV; }
"["               { yylval = new ParseTree(yytext); return LB; }
"]"               { yylval = new ParseTree(yytext); return RB; }
<<EOF>>           { return 0; }
[ \t\n]+          { }
.                 { errout << "Unrecognized token starting with"
                           << yytext << endl; 
                    exit(1); 
                  }
%%