File: cue.L

package info (click to toggle)
libcdio 2.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,140 kB
  • sloc: ansic: 39,407; cpp: 2,556; sh: 1,263; makefile: 826; yacc: 324; ruby: 116; perl: 34
file content (239 lines) | stat: -rw-r--r-- 4,336 bytes parent folder | download
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*  $Id: cue.L,v 1.2 2008/03/23 17:21:34 karl Exp $ -*- C -*- */
/*  CUE-sheet 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 "cue.tab.h"

  static int debug_lex=0;
%}
%x filename

TrackDef         "TRACK"
Audio            "AUDIO"
Mode1_2048       "MODE1/2048"
Mode1_2352       "MODE1/2352"
Mode2_2336       "MODE2/2336"
Mode2_2352       "MODE2/2352"
Index            "INDEX"
File             "FILE"
Pregap           "PREGAP"
Postgap          "POSTGAP"
Binary           "BINARY"
Motorola         "MOTOROLA"
Flags            "FLAGS"
Catalog          "CATALOG"
Isrc             "ISRC"
Four_Channel     "4CH"
Dont_Copy        "DCP"
Pre_Emphasis     "PRE"
Colon            ":"
Integer          [[:digit:]]+
Spaces           [[:blank:]\n\r]+ 
String           \".+\" 
Filename         [^[:blank:]\n\r]+
%%
{TrackDef} {
  /*"*/
  return TRACK_TOKEN;
}
{Audio}  {
  return AUDIO_TOKEN;
}

{Mode1_2048} {
  return MODE1_2048_TOKEN;
}

{Mode1_2352} {
  return MODE1_2352_TOKEN;
}

{Mode2_2336} {
  return MODE2_2336_TOKEN;
}

{Mode2_2352} {
  return MODE2_2352_TOKEN;
}

{Index} {
  return INDEX_TOKEN;
}

{File} {
  BEGIN(filename);
  return FILE_TOKEN;
}

{Pregap} {
  return PREGAP_TOKEN;
}

{Postgap} {
  return POSTGAP_TOKEN;
}

{Binary} {
  return BINARY_TOKEN;
}

{Motorola} {
  return MOTOROLA_TOKEN;
}

{Flags} {
  return FLAGS_TOKEN;
}

{Catalog} {
  return CATALOG_TOKEN;
}

{Isrc} {
  if (debug_lex) printf("Isrc token\n");
}

{Four_Channel} {
  return FOURCH_TOKEN;
}

{Dont_Copy} {
  return DCP_TOKEN;
}

{Pre_Emphasis} {
  if (debug_lex) printf("Pre_Emphasis token\n");
}

{Colon} {
  return COLON_TOKEN;
}

{Integer} {
  return INTEGER_TOKEN;
}

<filename>{Filename} {
  BEGIN(INITIAL);
  return FILENAME_TOKEN;
}

<INITIAL,filename>{String} {
  return STRING_TOKEN;
}

<INITIAL,filename>{Spaces} {
  return SPACES_TOKEN;
}

<INITIAL,filename><<EOF>> {
  return EOF;
}

  
%%

#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 TRACK_TOKEN:
      printf("TRACK\n");
      break;
    case AUDIO_TOKEN:
      printf("AUDIO token\n");
      break;
    case MODE1_2048_TOKEN: 
      printf("MODE1/2048\n");
      break;
    case MODE1_2352_TOKEN:
      printf("MODE1/2352\n");
      break;
    case MODE2_2336_TOKEN:
      printf("MODE1/2336\n");
      break;
    case MODE2_2352_TOKEN:
      printf("MODE2/2352\n");
      break;
    case INDEX_TOKEN:
      printf("INDEX\n");
      break;
    case FILE_TOKEN:
      printf("FILE\n");
      break;
    case PREGAP_TOKEN:
      printf("PREGAP\n");
      break;
    case POSTGAP_TOKEN:
      printf("POSTGAP\n");
      break;
    case BINARY_TOKEN:
      printf("BINARY\n");
      break;
    case SPACES_TOKEN:
      printf("spaces\n");
      break;
    case STRING_TOKEN:
      printf("string: %s\n", yytext);
      break;
    case INTEGER_TOKEN:
      printf("integer: %d (%s)\n", atoi(yytext), yytext);
      break;
    case COLON_TOKEN:
      printf(":\n");
      break;
    case FLAGS_TOKEN:
      printf("FLAGS\n");
      break;
    case CATALOG_TOKEN:
      printf("CATALOG\n");
      break;
    case DCP_TOKEN:
      printf("DCP\n");
      break;
    case MOTOROLA_TOKEN:
      printf("MOTOROLA\n");
      break;
    case FOURCH_TOKEN:
      printf("4CH\n");
      break;
    case FILENAME_TOKEN:
      printf("filename %s\n", yytext);
      break;
    default: ;
    }
  }
  return 0;
}
#endif