Debian Codegraph @

xo/res_l.l

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 %{
2 /* res_l.l
3 $Id: res_l.l,v 1.8 1997/10/18 04:57:41 elf Exp $
4
5 This file is part of the project XO. See the file README for
6 more information.
7
8 Copyright (C) 1997 Marc Singer
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 in a file called COPYING along with this program; if not, write to
22 the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
23 02139, USA.
24
25 -----------
26 DESCRIPTION
27 -----------
28
29 Lexical anaylzer for dialog language parser.
30
31 */
32
33 #include "standard.h"
34 #define IS_PARSER
35 #include "lres.h"
36 #include "res_y.h"
37 #include <limits.h>
38
39 #if defined (__cplusplus)
40 extern "C" int yylex (void);
41 #else
42 int yylex (void);
43 #endif
44
45 int g_iLineParse = 1;
46
47 /* We need to read from the buffered input stream because we do some
48 magic with the first line that requires an ungetc() call. */
49 #define YY_INPUT(pv,result,cbMax) \
50 if ((result = fread ((char*) pv, 1, cbMax, yyin)) < 0 ) \
51 YY_FATAL_ERROR ("input in flex scanner failed");
52
53 #define DPRINTF(a)
54
55 #define YY_NO_UNPUT
56
57 %}
58
59 %s COMMENT
60
61 %%
62
63 /* comments are ignored */
64 "/*" { BEGIN COMMENT; }
65 "*/" { BEGIN 0; }
66 <COMMENT>.* ;
67 <COMMENT>\n { ++g_iLineParse; }
68
69 /* real number */
70 ([+-]?[0-9]+\.[0-9]*) {
71 float r;
72 if (safe_atof (yytext, &r)) {
73 /* yylval.er = erInteger; */
74 return ERROR;
75 }
76 yylval.r = r;
77 return REAL;
78 }
79
80 /* integer */
81 ([+-]?[0-9]+) {
82 long l;
83 if (safe_atol (yytext, &l)) {
84 /* yylval.er = erInteger; */
85 return ERROR;
86 }
87 yylval.l = l;
88 return INTEGER;
89 }
90
91 /* hex integer */
92 (0[xX][0-9a-fA-F]+) {
93 long l;
94 if (safe_atol (yytext, &l)) {
95 /* yylval.er = erInteger; */
96 return ERROR;
97 }
98 yylval.l = l;
99 return INTEGER;
100 }
101
102 /* white space is ignored */
103 \n { ++g_iLineParse; }
104 [ \t\r\032] ;
105
106
107 /* string surrounded by double quotes, \" to escape a " character */
108 \"([^\"\n]|(\\\"))*\" {
109 yytext[yyleng - 1] = 0;
110 yylval.sz = (char*) LResNode::alloc (yyleng - 1, yytext + 1);
111 return STRING;
112 }
113
114 [a-zA-Z_]+ {
115 yylval.sz = (char*) LResNode::alloc (yyleng + 1, yytext);
116 return KEYWORD;
117 }
118
119 "\"" { return QUOTE; }
120 "{" { return BO; }
121 "}" { return BC; }
122 "(" { return PO; }
123 ")" { return PC; }
124
125 . { return yytext[0]; }
126
127 %%