1999-03-18 16:08:57 +01:00
|
|
|
|
%{
|
|
|
|
|
/*
|
1999-03-30 11:42:51 +02:00
|
|
|
|
* File: lexer.l
|
|
|
|
|
* Date created: March 15, 1999 (Monday, 17:16h)
|
2006-07-07 09:24:17 +02:00
|
|
|
|
* Author: Copyright (C) 1999 Thomas Jensen <boxes@thomasjensen.com>
|
1999-03-30 11:42:51 +02:00
|
|
|
|
* Language: lex (ANSI C)
|
2015-01-11 23:15:48 +01:00
|
|
|
|
* Web Site: http://boxes.thomasjensen.com/
|
1999-03-30 11:42:51 +02:00
|
|
|
|
* Purpose: flex lexical analyzer for boxes configuration files
|
1999-07-22 14:21:14 +02:00
|
|
|
|
*
|
2015-01-11 23:15:48 +01:00
|
|
|
|
* License: o This program is free software; you can redistribute it and/or
|
1999-07-22 14:21:14 +02:00
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
|
* o 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.
|
|
|
|
|
* o You should have received a copy of the GNU General Public
|
|
|
|
|
* License along with this program; if not, write to the Free
|
|
|
|
|
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
|
*
|
2015-01-11 23:15:48 +01:00
|
|
|
|
* Remarks: - We don't use the yylineno %option. It is not only inefficient,
|
|
|
|
|
* but also doesn't work. :-| *doh*
|
1999-03-30 11:42:51 +02:00
|
|
|
|
*
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
1999-03-18 16:08:57 +01:00
|
|
|
|
*/
|
|
|
|
|
|
1999-07-22 14:21:14 +02:00
|
|
|
|
#include "config.h"
|
1999-03-18 16:08:57 +01:00
|
|
|
|
#include <string.h>
|
1999-08-18 20:23:41 +02:00
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <unistd.h>
|
1999-06-28 14:17:46 +02:00
|
|
|
|
#include "shape.h"
|
|
|
|
|
#define FILE_LEXER_L
|
1999-03-18 16:08:57 +01:00
|
|
|
|
#include "boxes.h"
|
1999-06-28 14:17:46 +02:00
|
|
|
|
#undef FILE_LEXER_L
|
1999-06-22 14:00:05 +02:00
|
|
|
|
#include "tools.h"
|
1999-07-02 13:58:15 +02:00
|
|
|
|
#include "parser.h"
|
1999-07-22 14:21:14 +02:00
|
|
|
|
#include "lexer.h"
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
1999-06-28 20:37:38 +02:00
|
|
|
|
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
#define LEX_MAX_WARN 3 /* number of lex errors per design */
|
1999-06-22 14:00:05 +02:00
|
|
|
|
|
1999-06-28 14:17:46 +02:00
|
|
|
|
|
|
|
|
|
static const char rcsid_lexer_l[] =
|
2014-08-27 22:41:48 +02:00
|
|
|
|
"$Id: lexer.l,v 1.19 2006/07/22 19:31:25 tsjensen Exp $";
|
2006-07-22 21:30:55 +02:00
|
|
|
|
int tjlineno = 1;
|
2006-07-07 09:24:17 +02:00
|
|
|
|
|
1999-08-18 20:23:41 +02:00
|
|
|
|
static int yyerrcnt = 0;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
static char sdel = '\"';
|
|
|
|
|
static char sesc = '\\';
|
|
|
|
|
|
1999-08-18 20:23:41 +02:00
|
|
|
|
|
|
|
|
|
/*
|
1999-08-20 21:51:12 +02:00
|
|
|
|
* User-defined initializations for the lexer
|
1999-08-18 20:23:41 +02:00
|
|
|
|
*/
|
1999-08-20 21:51:12 +02:00
|
|
|
|
static void inflate_inbuf();
|
|
|
|
|
#define YY_USER_INIT inflate_inbuf()
|
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
%}
|
|
|
|
|
|
1999-08-20 21:51:12 +02:00
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
%option nounput
|
|
|
|
|
%option noyywrap
|
1999-08-18 17:40:10 +02:00
|
|
|
|
%option never-interactive
|
|
|
|
|
%option caseless
|
2006-07-07 09:24:17 +02:00
|
|
|
|
%option noyylineno
|
1999-07-02 13:58:15 +02:00
|
|
|
|
|
1999-08-20 21:51:12 +02:00
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
%x SAMPLE
|
1999-07-02 13:58:15 +02:00
|
|
|
|
%x SPEEDMODE
|
1999-08-18 17:40:10 +02:00
|
|
|
|
%x DELWORD
|
1999-03-18 16:08:57 +01:00
|
|
|
|
%s SHAPES
|
|
|
|
|
%s ELASTIC
|
|
|
|
|
|
1999-08-20 21:51:12 +02:00
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
PWORD [a-zA-Z<><5A><EFBFBD><EFBFBD><EFBFBD><EFBFBD>][a-zA-Z0-9\-_<><5F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]*
|
|
|
|
|
PWHITE [\n \r\t]
|
|
|
|
|
PBOX Box
|
1999-08-18 17:40:10 +02:00
|
|
|
|
SDELIM [\"~\'`!@\%\&\*=:;<>\?/|\.\\]
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
1999-08-20 21:51:12 +02:00
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
<DELWORD,SHAPES,ELASTIC,INITIAL>[ \r\t] /* ignore whitespace */
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
2006-07-22 21:30:55 +02:00
|
|
|
|
<DELWORD,SHAPES,ELASTIC,INITIAL>\n ++tjlineno;
|
1999-08-18 17:40:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<DELWORD>[^ \t\r\n]+ {
|
|
|
|
|
/*
|
|
|
|
|
* String delimiter spec - like WORD, but allow any character
|
|
|
|
|
*/
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\nYDELWOR: %s -- STATE INITIAL", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
yylval.s = (char *) strdup (yytext);
|
|
|
|
|
if (yylval.s == NULL) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
BEGIN INITIAL;
|
|
|
|
|
return YDELWORD;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
{SDELIM}.*$ {
|
|
|
|
|
/*
|
|
|
|
|
* Strings -- first match everything starting from a potential
|
|
|
|
|
* string delimiter until the end of the line. We will give back what
|
|
|
|
|
* we don't need and also detect unterminated strings.
|
|
|
|
|
*/
|
|
|
|
|
char *p;
|
|
|
|
|
int rest_len = yyleng - 1; /* length of string pointed to by p */
|
|
|
|
|
int qcnt = 0; /* esc char count in current string */
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
if (yytext[0] != sdel) {
|
|
|
|
|
REJECT; /* that was not our delimiter */
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
yylval.s = (char *) strdup (yytext + 1);
|
|
|
|
|
if (yylval.s == NULL) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
p = yylval.s;
|
|
|
|
|
|
|
|
|
|
while (*p) {
|
|
|
|
|
if (*p == sesc) {
|
|
|
|
|
memmove (p, p+1, rest_len); /* incl. '\0' */
|
|
|
|
|
++qcnt;
|
|
|
|
|
--rest_len;
|
|
|
|
|
if (*p == '\0')
|
|
|
|
|
break;
|
1999-06-28 20:37:38 +02:00
|
|
|
|
}
|
1999-08-18 17:40:10 +02:00
|
|
|
|
else if (*p == sdel) {
|
|
|
|
|
*p = '\0';
|
|
|
|
|
yyless ((p-yylval.s)+2+qcnt); /* string plus quotes */
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\n STRING: \"%s\"", yylval.s);
|
|
|
|
|
#endif
|
|
|
|
|
return STRING;
|
|
|
|
|
}
|
|
|
|
|
--rest_len;
|
|
|
|
|
++p;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
1999-08-18 17:40:10 +02:00
|
|
|
|
if (yyerrcnt++ < 5)
|
|
|
|
|
yyerror ("Unterminated String -- %s", yytext);
|
|
|
|
|
return YUNREC;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
|
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
Sample {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-08-16 18:28:03 +02:00
|
|
|
|
fprintf (stderr, "\nYSAMPLE: %s -- STATE SAMPLE", yytext);
|
1999-03-18 16:08:57 +01:00
|
|
|
|
#endif
|
1999-08-16 18:28:03 +02:00
|
|
|
|
BEGIN SAMPLE;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
return YSAMPLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
<SAMPLE>\n {
|
2006-07-22 21:30:55 +02:00
|
|
|
|
++tjlineno;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
if (yyleng > 1)
|
|
|
|
|
yymore();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
<SAMPLE>^[ \t]*ends[ \t\r]*$ {
|
|
|
|
|
char *p = yytext + yyleng -1;
|
|
|
|
|
size_t len; /* length of sample */
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
while (*p == ' ' || *p == '\t' || *p == '\r')
|
|
|
|
|
--p; /* skip trailing whitespace */
|
|
|
|
|
p -= 2; /* almost skip "ends" statement */
|
|
|
|
|
*p = '\0'; /* p now points to 'n' */
|
|
|
|
|
yylval.s = (char *) strdup (yytext);
|
|
|
|
|
if (yylval.s == NULL) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
*p-- = 'n';
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
len = p - yytext; /* yyless(n): push back all but the first n */
|
|
|
|
|
yyless (len); /* allow him to return YENDSAMPLE */
|
|
|
|
|
|
|
|
|
|
yylval.s[len] = '\n'; /* replace 'e' with newline */
|
|
|
|
|
btrim (yylval.s, &len);
|
|
|
|
|
if (len > 0) {
|
|
|
|
|
strcat (yylval.s, "\n"); /* memory was allocated with strdup */
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\n STRING: \"%s\" -- STATE INITIAL", yylval.s);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN INITIAL;
|
|
|
|
|
return STRING;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
if (yyerrcnt++ < 5)
|
1999-08-16 18:28:03 +02:00
|
|
|
|
yyerror ("SAMPLE block must not be empty");
|
|
|
|
|
BFREE (yylval.s);
|
1999-06-28 20:37:38 +02:00
|
|
|
|
return YUNREC;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
|
|
|
|
|
<SAMPLE>. yymore();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ends[ \t\r]*$ {
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\nYENDSAM: %s", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
return YENDSAMPLE;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-08-16 18:28:03 +02:00
|
|
|
|
|
|
|
|
|
|
1999-06-28 20:37:38 +02:00
|
|
|
|
Elastic {
|
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\nYELASTC: %s -- STATE ELASTIC", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN ELASTIC;
|
|
|
|
|
return YELASTIC;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Shapes {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\nYSHAPES: %s -- STATE SHAPES", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN SHAPES;
|
|
|
|
|
return YSHAPES;
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
{PBOX} {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-07-02 13:58:15 +02:00
|
|
|
|
fprintf (stderr, "\n YBOX: %s", yytext);
|
1999-06-28 14:17:46 +02:00
|
|
|
|
#endif
|
1999-06-28 20:37:38 +02:00
|
|
|
|
yyerrcnt = 0;
|
1999-06-28 14:17:46 +02:00
|
|
|
|
return YBOX;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-28 20:37:38 +02:00
|
|
|
|
Replace { return YREPLACE; }
|
|
|
|
|
Reverse { return YREVERSE; }
|
|
|
|
|
Padding { return YPADDING; }
|
|
|
|
|
End { return YEND; }
|
|
|
|
|
To { return YTO; }
|
|
|
|
|
With { return YWITH; }
|
|
|
|
|
Global { yylval.c = 'g'; return YRXPFLAG; }
|
|
|
|
|
Once { yylval.c = 'o'; return YRXPFLAG; }
|
1999-06-28 14:17:46 +02:00
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
|
|
|
|
|
<SHAPES,ELASTIC>nw { yylval.shape = NW; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>nnw { yylval.shape = NNW; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>n { yylval.shape = N; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>nne { yylval.shape = NNE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>ne { yylval.shape = NE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>ene { yylval.shape = ENE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>e { yylval.shape = E; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>ese { yylval.shape = ESE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>se { yylval.shape = SE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>sse { yylval.shape = SSE; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>s { yylval.shape = S; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>ssw { yylval.shape = SSW; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>sw { yylval.shape = SW; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>wsw { yylval.shape = WSW; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>w { yylval.shape = W; return SHAPE; }
|
|
|
|
|
<SHAPES,ELASTIC>wnw { yylval.shape = WNW; return SHAPE; }
|
|
|
|
|
|
|
|
|
|
<ELASTIC>\) {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\n SYMBOL: \'%c\' -- STATE INITIAL", yytext[0]);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN INITIAL;
|
|
|
|
|
return yytext[0];
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 15:31:13 +02:00
|
|
|
|
<SHAPES>\} {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\n SYMBOL: \'%c\' -- STATE INITIAL", yytext[0]);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN INITIAL;
|
|
|
|
|
return yytext[0];
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 15:31:13 +02:00
|
|
|
|
|
1999-06-28 14:17:46 +02:00
|
|
|
|
author|created|revision|revdate|indent {
|
1999-03-18 16:08:57 +01:00
|
|
|
|
/*
|
1999-04-04 18:11:39 +02:00
|
|
|
|
* general key words
|
1999-03-18 16:08:57 +01:00
|
|
|
|
*/
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\nKEYWORD: %s", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
yylval.s = (char *) strdup (yytext);
|
1999-06-28 20:37:38 +02:00
|
|
|
|
if (yylval.s == NULL) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
1999-03-18 16:08:57 +01:00
|
|
|
|
return KEYWORD;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 15:31:13 +02:00
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
Delimiter|Delim {
|
|
|
|
|
/*
|
|
|
|
|
* Change string delimiting characters
|
|
|
|
|
*/
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\nYCHGDEL: %s -- STATE DELWORD", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN DELWORD;
|
|
|
|
|
return YCHGDEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
{PWORD} {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\n WORD: %s", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
yylval.s = (char *) strdup (yytext);
|
1999-06-28 20:37:38 +02:00
|
|
|
|
if (yylval.s == NULL) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
1999-03-18 16:08:57 +01:00
|
|
|
|
return WORD;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 15:31:13 +02:00
|
|
|
|
|
1999-06-20 16:17:58 +02:00
|
|
|
|
[\+-]?[0-9]+ {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-06-20 16:17:58 +02:00
|
|
|
|
fprintf (stderr, "\nYNUMBER: %s", yytext);
|
|
|
|
|
#endif
|
|
|
|
|
yylval.num = atoi (yytext);
|
|
|
|
|
return YNUMBER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
[,(){}] {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-03-18 16:08:57 +01:00
|
|
|
|
fprintf (stderr, "\n SYMBOL: \'%c\'", yytext[0]);
|
|
|
|
|
#endif
|
|
|
|
|
return yytext[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-04 18:11:39 +02:00
|
|
|
|
#.*$ {
|
|
|
|
|
/* ignore comments */
|
1999-06-28 20:37:38 +02:00
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-04-04 18:11:39 +02:00
|
|
|
|
fprintf (stderr, "\nCOMMENT: %s", yytext+1);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-09 15:31:13 +02:00
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
. {
|
1999-06-28 20:37:38 +02:00
|
|
|
|
if (yyerrcnt++ < LEX_MAX_WARN)
|
1999-07-02 13:58:15 +02:00
|
|
|
|
yyerror ("Unrecognized input char \'%s\'", yytext);
|
1999-06-28 20:37:38 +02:00
|
|
|
|
return YUNREC;
|
1999-03-18 16:08:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
<SPEEDMODE>{PBOX}{PWHITE}+{PWORD} {
|
|
|
|
|
#ifdef LEXER_DEBUG
|
1999-08-18 17:40:10 +02:00
|
|
|
|
fprintf (stderr, "\n STATUS: %s -- STATE INITIAL", yytext);
|
1999-07-02 13:58:15 +02:00
|
|
|
|
#endif
|
|
|
|
|
yyless (0);
|
|
|
|
|
speeding = 0;
|
|
|
|
|
BEGIN INITIAL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-07-22 21:30:55 +02:00
|
|
|
|
<SPEEDMODE>\n ++tjlineno;
|
1999-07-02 13:58:15 +02:00
|
|
|
|
|
|
|
|
|
<SPEEDMODE>. /* ignore anything else */
|
|
|
|
|
|
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
1999-08-20 21:51:12 +02:00
|
|
|
|
static void inflate_inbuf()
|
|
|
|
|
/*
|
|
|
|
|
* User-defined initializations for the lexer.
|
|
|
|
|
*
|
|
|
|
|
* Since this scanner must use REJECT in order to be able to process the
|
|
|
|
|
* string delimiter commands, it cannot dynamically enlarge its input
|
|
|
|
|
* buffer to accomodate larger tokens. Thus, we simply set the buffer size
|
|
|
|
|
* to the input file size plus 10 bytes margin-of-error.
|
|
|
|
|
*
|
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
|
*/
|
|
|
|
|
{
|
|
|
|
|
struct stat sinf;
|
|
|
|
|
|
|
|
|
|
if (stat(yyfilename, &sinf)) {
|
|
|
|
|
perror (PROJECT);
|
|
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
yy_delete_buffer (YY_CURRENT_BUFFER);
|
2006-07-07 09:24:17 +02:00
|
|
|
|
yy_switch_to_buffer (yy_create_buffer (yyin, sinf.st_size+10));
|
1999-08-20 21:51:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-07-02 13:58:15 +02:00
|
|
|
|
void begin_speedmode()
|
|
|
|
|
{
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\n STATUS: begin_speedmode() -- STATE SPEEDMODE");
|
|
|
|
|
#endif
|
|
|
|
|
BEGIN SPEEDMODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-08-18 17:40:10 +02:00
|
|
|
|
|
|
|
|
|
void chg_strdelims (const char asesc, const char asdel)
|
|
|
|
|
{
|
|
|
|
|
#ifdef LEXER_DEBUG
|
|
|
|
|
fprintf (stderr, "\n STATUS: chg_strdelims ('%c', '%c')", asesc, asdel);
|
|
|
|
|
#endif
|
|
|
|
|
sesc = asesc;
|
|
|
|
|
sdel = asdel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-03-18 16:08:57 +01:00
|
|
|
|
/*EOF*/ /* vim: set cindent sw=4: */
|