1 |
%{ |
%{ |
2 |
|
/* Eliot */ |
3 |
|
/* Copyright (C) 2005 Antoine Fraboulet */ |
4 |
|
/* */ |
5 |
|
/* This file is part of Eliot. */ |
6 |
|
/* */ |
7 |
|
/* Eliot is free software; you can redistribute it and/or modify */ |
8 |
|
/* it under the terms of the GNU General Public License as published by */ |
9 |
|
/* the Free Software Foundation; either version 2 of the License, or */ |
10 |
|
/* (at your option) any later version. */ |
11 |
|
/* */ |
12 |
|
/* Elit is distributed in the hope that it will be useful, */ |
13 |
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
14 |
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
15 |
|
/* GNU General Public License for more details. */ |
16 |
|
/* */ |
17 |
|
/* You should have received a copy of the GNU General Public License */ |
18 |
|
/* along with this program; if not, write to the Free Software */ |
19 |
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ |
20 |
|
|
21 |
#include <stdio.h> |
#include <stdio.h> |
22 |
#include <malloc.h> |
#include <malloc.h> |
23 |
#include <stdlib.h> |
#include <stdlib.h> |
91 |
|
|
92 |
start: LEX_L_BRACKET expr LEX_R_BRACKET LEX_SHARP |
start: LEX_L_BRACKET expr LEX_R_BRACKET LEX_SHARP |
93 |
{ |
{ |
94 |
NODE *sharp; |
NODE* sharp = regexp_createNODE(NODE_VAR,RE_FINAL_TOK,NULL,NULL); |
95 |
NODE *er; |
*root = regexp_createNODE(NODE_AND,'\0',$2,sharp); |
|
sharp = regexp_createNODE(NODE_VAR,RE_FINAL_TOK,NULL,NULL); |
|
|
er = $2; |
|
|
*root = regexp_createNODE(NODE_AND,'\0',er,sharp); |
|
96 |
YYACCEPT; |
YYACCEPT; |
97 |
} |
} |
98 |
; |
; |
108 |
} |
} |
109 |
| var LEX_QMARK |
| var LEX_QMARK |
110 |
{ |
{ |
111 |
$$=regexp_createNODE(NODE_QMARK,'\0',$1,NULL); |
NODE* epsilon=regexp_createNODE(NODE_VAR,RE_EPSILON,NULL,NULL); |
112 |
|
$$=regexp_createNODE(NODE_OR,'\0',$1,epsilon); |
113 |
} |
} |
114 |
| var LEX_PLUS |
| var LEX_PLUS |
115 |
{ |
{ |
126 |
} |
} |
127 |
| LEX_L_BRACKET expr LEX_R_BRACKET LEX_QMARK |
| LEX_L_BRACKET expr LEX_R_BRACKET LEX_QMARK |
128 |
{ |
{ |
129 |
$$=regexp_createNODE(NODE_QMARK,'\0',$2,NULL); |
NODE* epsilon=regexp_createNODE(NODE_VAR,RE_EPSILON,NULL,NULL); |
130 |
|
$$=regexp_createNODE(NODE_OR,'\0',$2,epsilon); |
131 |
} |
} |
132 |
| LEX_L_BRACKET expr LEX_R_BRACKET LEX_PLUS |
| LEX_L_BRACKET expr LEX_R_BRACKET LEX_PLUS |
133 |
{ |
{ |
144 |
} |
} |
145 |
| LEX_L_SQBRACKET exprdisnode LEX_R_SQBRACKET LEX_QMARK |
| LEX_L_SQBRACKET exprdisnode LEX_R_SQBRACKET LEX_QMARK |
146 |
{ |
{ |
147 |
$$=regexp_createNODE(NODE_QMARK,'\0',$2,NULL); |
NODE* epsilon=regexp_createNODE(NODE_VAR,RE_EPSILON,NULL,NULL); |
148 |
|
$$=regexp_createNODE(NODE_OR,'\0',$2,epsilon); |
149 |
} |
} |
150 |
| LEX_L_SQBRACKET exprdisnode LEX_R_SQBRACKET LEX_PLUS |
| LEX_L_SQBRACKET exprdisnode LEX_R_SQBRACKET LEX_PLUS |
151 |
{ |
{ |
161 |
|
|
162 |
var : LEX_CHAR |
var : LEX_CHAR |
163 |
{ |
{ |
164 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
165 |
printf("var : lecture %c\n",$1 + 'a' -1); |
printf("var : lecture %c\n",$1 + 'a' -1); |
166 |
#endif |
#endif |
167 |
$$=regexp_createNODE(NODE_VAR,$1,NULL,NULL); |
$$=regexp_createNODE(NODE_VAR,$1,NULL,NULL); |
192 |
exprdisnode : exprdis |
exprdisnode : exprdis |
193 |
{ |
{ |
194 |
int i,j; |
int i,j; |
195 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
196 |
printf("exprdisnode : exprdis : "); |
printf("exprdisnode : exprdis : "); |
197 |
#endif |
#endif |
198 |
for(i=RE_LIST_USER_END + 1; i < DIC_SEARCH_REGE_LIST; i++) |
for(i=RE_LIST_USER_END + 1; i < DIC_SEARCH_REGE_LIST; i++) |
204 |
list->letters[i][0] = 0; |
list->letters[i][0] = 0; |
205 |
for(j=1; j < DIC_LETTERS; j++) |
for(j=1; j < DIC_LETTERS; j++) |
206 |
list->letters[i][j] = $1[j] ? 1 : 0; |
list->letters[i][j] = $1[j] ? 1 : 0; |
207 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
208 |
printf("list %d symbl x%02x : ",i,list->symbl[i]); |
printf("list %d symbl x%02x : ",i,list->symbl[i]); |
209 |
for(j=0; j < DIC_LETTERS; j++) |
for(j=0; j < DIC_LETTERS; j++) |
210 |
if (list->letters[i][j]) |
if (list->letters[i][j]) |
219 |
| LEX_HAT exprdis |
| LEX_HAT exprdis |
220 |
{ |
{ |
221 |
int i,j; |
int i,j; |
222 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
223 |
printf("exprdisnode : HAT exprdis : "); |
printf("exprdisnode : HAT exprdis : "); |
224 |
#endif |
#endif |
225 |
for(i=RE_LIST_USER_END + 1; i < DIC_SEARCH_REGE_LIST; i++) |
for(i=RE_LIST_USER_END + 1; i < DIC_SEARCH_REGE_LIST; i++) |
231 |
list->letters[i][0] = 0; |
list->letters[i][0] = 0; |
232 |
for(j=1; j < DIC_LETTERS; j++) |
for(j=1; j < DIC_LETTERS; j++) |
233 |
list->letters[i][j] = $2[j] ? 0 : 1; |
list->letters[i][j] = $2[j] ? 0 : 1; |
234 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
235 |
printf("list %d symbl x%02x : ",i,list->symbl[i]); |
printf("list %d symbl x%02x : ",i,list->symbl[i]); |
236 |
for(j=0; j < DIC_LETTERS; j++) |
for(j=0; j < DIC_LETTERS; j++) |
237 |
if (list->letters[i][j]) |
if (list->letters[i][j]) |
264 |
{ |
{ |
265 |
int c = $1; |
int c = $1; |
266 |
memset($$,0,sizeof(char)*DIC_LETTERS); |
memset($$,0,sizeof(char)*DIC_LETTERS); |
267 |
#ifdef DEBUG_RE |
#ifdef DEBUG_RE_PARSE |
268 |
printf("vardis : lecture %c\n",c + 'a' -1); |
printf("vardis : lecture %c\n",c + 'a' -1); |
269 |
#endif |
#endif |
270 |
$$[c] = 1; |
$$[c] = 1; |
282 |
err->pos2 = llocp->last_column; |
err->pos2 = llocp->last_column; |
283 |
strncpy(err->msg,msg,sizeof(err->msg)); |
strncpy(err->msg,msg,sizeof(err->msg)); |
284 |
} |
} |
285 |
|
|
286 |
|
/* |
287 |
|
* shut down the compiler |
288 |
|
*/ |
289 |
|
static int yy_init_globals (yyscan_t yyscanner ) |
290 |
|
{ |
291 |
|
yy_init_globals(yyscanner); |
292 |
|
return 0; |
293 |
|
} |