-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.c
65 lines (45 loc) · 1.03 KB
/
parse.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* File: parse.c
* Author: Edward Hills
* Date: 23/03/2012
* Description: This program will parse the xml collection given to it
* using the scanner created by flex below, and then pass
* the terms onto the indexer.
*/
%option noyywrap
%option nounput
%option noinput
%{
#include <stdio.h>
#include "mylib.h"
#include "index.h"
%}
%%
[a-zA-Z]+ {
toLower(yytext);
word(yytext);
} /* eg fred */
[a-zA-Z]+[\'][a-zA-Z]{2,} {
toLower(yytext);
word(yytext);
}
[\'][a-z] { /* eat it up */ }
"<"[a-zA-Z]+">" { start_tag(yytext); }
"</"[a-zA-Z]+">" { end_tag(yytext); }
[a-zA-Z]*[\$]?[\.]?[-\+]?[0-9]+([/]?[\.,-][0-9]+)*[\%]? {
toLower(yytext);
word(yytext);
} /* eg. $24.08 */
([a-zA-Z][\.])+ {
toLower(yytext);
word(yytext);
}
[\&][a-z\;]+ /* eat it up */
["\n"] /* eat it up */
. /* eat it up */
%%
#include "parse.h"
void parse(FILE *stream) {
yyin = stream;
yylex();
}