blob: 945d6b272f7b3673db9454721dc20e879af2b78e (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
/* $Id: toc.L,v 1.2 2008/03/23 17:21:34 karl Exp $ -*- C -*- */
/* cdrdao TOC scanner
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
%{
#undef yywrap
#ifdef STANDALONE
#include <stdio.h>
#endif
#include "toc.tab.h"
static int debug_lex=0;
%}
%union {
unsigned long int val; /* For returning numbers. */
char const * str; /* For returning stringss. */
}
integer [[:digit:]]+
/* The below isn't octal. I'm just going by the name and pattern
in the cdrdao pacct grammar. */
stringoctal [[:digit:]]{3}
spaces [[:blank:]\n\r]+
# Need to expand this to include "octal" \000 and embedded quotes.
string \".+\"
%%
{integer} {
/*"*/
return Integer;
}
{stringoctal} {
/*"*/
return StringOctal;
}
{spaces} {
return Spaces;
}
%%
#if STANDALONE
int
main( int argc, const char **argv )
{
int token;
++argv, --argc; /* skip over program name */
debug_lex = 1;
if ( argc > 0 )
yyin = fopen( argv[0], "r" );
else
yyin = stdin;
while ((token=yylex()) != EOF) {
switch (token) {
case StringOctal:
printf("StringOctal\n");
break;
case Spaces:
printf("Spaces\n");
break;
case Integer:
printf("Integer\n");
break;
default: ;
}
}
return 0;
}
#endif
|