(no commit message)
[geda-pcb/pcjc2.git] / src / res_lex.l
blobdd4dadd56ce81d8e161972465bd389725675e21a
1 %{
3 #ifdef HAVE_CONFIG_H
4 #include "config.h"
5 #endif
7 #ifdef HAVE_STRING_H
8 #include <string.h>
9 #endif
11 #include "global.h"
12 #include "resource.h"
13 #include "res_parse.h"
15 #ifdef HAVE_LIBDMALLOC
16 #include <dmalloc.h>
17 #endif
19 #define YY_NO_INPUT
20 #define YY_INPUT(buf,result,max_size) { result = res_parse_getchars(buf, max_size); }
22 #ifdef FLEX_SCANNER
23 #define yyunput ATTRIBUTE_UNUSED yyunput
24 #endif
26 extern int res_lineno;
27 extern int res_parse_getchars(char *buf, int max_size);
31 %option prefix="res"
32 %option outfile="lex.yy.c"
33 %option yylineno
34 %option noyywrap
36 PARENSTR        ([^ (){}=\"\'\t\r\n]|\([^\)]*\))+
37 INCSTR          @[a-z0-9A-Z_]+
38 COMMENT         #[^\n]*
42 \"[^"]*\"       { reslval.sval = strdup(yytext+1);
43                   reslval.sval[strlen(reslval.sval) - 1] = 0;
44                   return STRING; }
46 \'[^']*\'       { reslval.sval = strdup(yytext+1);
47                   reslval.sval[strlen(reslval.sval) - 1] = 0;
48                   return STRING; }
50 {COMMENT}\n     { res_lineno++; }
51 [ \t\r\n]       { if (yytext[0] == '\n') res_lineno++; }
53 {INCSTR}        { reslval.sval = strdup(yytext);
54                           return INCLUDE; }
56 {PARENSTR}      { reslval.sval = strdup(yytext);
57                           return STRING; }
59 .               { return yytext[0]; }
63 /* ' */