aux-item-def.l 6.97 KB
Newer Older
1
2
%{
/*
3
 * $Id: aux-item-def.l,v 1.2 1998/06/14 14:50:35 byers Exp $
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
 * Copyright (C) 1994, 1995, 1996  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM 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 1, or (at your option) 
 * any later version.
 * 
 * LysKOM 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 LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */


#include <ctype.h>

#include "s-string.h"
#include "aux-item-def.tab.h"
#include "server/smalloc.h"

#define yylval aux_item_def_lval
#define yyerror aux_item_def_error


#if defined(HAVE_VFPRINTF) && defined(HAVE_STDARG_H)
void yyerror(const char * format, int lineno, ...)
#  if HAVE_ATTRIBUTE_FORMAT_PRINTF
    __attribute__ ((format (printf, 1, 3)))
#  endif
    ;
#else
void yyerror();
#endif
static String stringBuffer = EMPTY_STRING_i;
extern YYLTYPE yylloc;
extern int aux_item_def_error_line;
#define RETURN aux_item_def_error_line = yylineno; return
%}


%option yylineno
%option noyywrap
%option prefix="aux_item_def_"

%x string

%%

(true|on|yes)                       {
                                        yylval.num = 1;
                                        yylloc.first_line = yylineno;
                                        RETURN BOOLEAN;
                                    }
(false|off|no)                      {
                                        yylval.num = 0; 
                                        yylloc.first_line = yylineno;
                                        RETURN BOOLEAN;
                                    }
disabled                            {
                                        yylloc.first_line = yylineno;
                                        RETURN DISABLED;
                                    }
text                                {
                                        yylloc.first_line = yylineno;
                                        RETURN TEXT;
                                    }
conference                          {
                                        yylloc.first_line = yylineno; 
                                        RETURN CONFERENCE;
                                    }
letterbox                           {
                                        yylloc.first_line = yylineno;
                                        RETURN LETTERBOX;
                                    }
server                              {
                                        yylloc.first_line = yylineno;
90
91
92
93
94
95
96
97
98
99
                                        RETURN TOK_SERVER;
                                    }
create                              {
                                        yylloc.first_line = yylineno;
                                        RETURN CREATE;
                                    }

modify                              {
                                        yylloc.first_line = yylineno;
                                        RETURN MODIFY;
100
101
102
103
104
105
106
107
108
                                    }


#[^\n]*                             /* Eat comments */
[ \t\n]+                            /* Eat whitespace */

[[:alpha:]][\-[:alnum:]_]*          {
                                        char *s = yytext;
                                        do { *s=tolower(*s); } while(*(++s));
109
                                        yylval.str = EMPTY_STRING;
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
                                        s_crea_str(&yylval.str, yytext);
                                        yylloc.first_line = yylineno;
                                        RETURN ID;
                                    }

([0-9]+)                            {
                                        yylloc.first_line = yylineno;
                                        yylval.num = atoi(yytext);
                                        RETURN NUMBER;
                                    }

\"                                  {
                                        BEGIN(string); 
                                        stringBuffer = EMPTY_STRING;
                                        yylloc.first_line = yylineno;
                                    }
<string>
{
    "[ \t\n]*"                      /* Concatenate strings */
    \"                              {
                                        BEGIN(INITIAL);
                                        yylval.str = stringBuffer;
                                        stringBuffer = EMPTY_STRING;
                                        RETURN STRING;
                                    }
    \\[0-9]{1,3}                    {
                                        unsigned int tmp;
                                        sscanf(yytext+1, "%o", &tmp);
                                        if (tmp > 255)
                                            s_strcat(&stringBuffer, 
                                                     s_fcrea_str(yytext));
                                        else
                                        {
                                            sprintf(yytext, "%c",
                                                    (unsigned char)tmp);
                                            yytext[1] = '\0';
                                            s_strcat(&stringBuffer, 
                                                     s_fcrea_str(yytext));
                                        }
                                    }
    \\n                             s_strcat(&stringBuffer, s_fcrea_str("\n"));
    \\t                             s_strcat(&stringBuffer, s_fcrea_str("\t"));
    \\r                             s_strcat(&stringBuffer, s_fcrea_str("\r"));
    \\b                             s_strcat(&stringBuffer, s_fcrea_str("\b"));
    \\f                             s_strcat(&stringBuffer, s_fcrea_str("\f"));
    \\'                             s_strcat(&stringBuffer, s_fcrea_str("\'"));
    \\\"                            s_strcat(&stringBuffer, s_fcrea_str("\""));
    \\\n[ \t]+                      /* Eat escaped whitespace */
    \\.                             s_strcat(&stringBuffer, s_fcrea_str(yytext+1));
    [^\\\n\"]+                      s_strcat(&stringBuffer, s_fcrea_str(yytext));
    \n                              {
                                        yyerror("unterminated string",
                                                 yylloc.first_line);
                                        RETURN VOID;
                                    }
}

.                                   RETURN yytext[0];

%%