/[pdpsoft]/trunk/grid-mw-security/ees/src/eval_man/pdl_lex.l
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/eval_man/pdl_lex.l

Parent Directory Parent Directory | Revision Log Revision Log


Revision 881 - (show annotations) (download)
Wed Oct 7 11:46:12 2009 UTC (12 years, 3 months ago) by aramv
File size: 4781 byte(s)
Rearranged some declarations to satisfy lex/yacc warnings
1
2 %{
3 #include "pdl.h"
4 #include "pdl_yacc.h"
5 #include "eef_log.h"
6 #include <string.h>
7 unsigned int lineno = 1;
8
9 /*static int no_valid_rule=0;*/
10 %}
11
12 ws [\t ]+
13 nl \n
14 term [a-zA-Z_.0-9]+
15 label {term}:
16 trans "->"
17 comment #.*\n
18 tokens [\~=\|]
19 pvar "path"
20 path \.*\/[^\/ \t\n]*
21 pdlstr \"[^\"\n]*[\"\n]
22
23
24 %x linecom path pathcom mq
25 %%
26
27 {ws} ;
28 {pvar} { return PVAR; }
29 {term} { if ((yylval.record = (record_t*)malloc(sizeof(record_t))))
30 if (((yylval.record)->string = (char*) strdup(yytext))) {
31 (yylval.record)->lineno = lineno;
32 return TERM;
33 }
34 eef_log(LOG_ERR, "out of memory.");
35 return 0;
36 }
37 {label} { yytext[yyleng-1] = '\0'; /* remove trailing ':' */
38
39 /* Check if this policy rule is allowed or not. */
40 if (allowed_policy_rule(yytext)) {
41 allow_rules(TRUE);
42 } else {
43 /* This label should not be added, however normal parsing
44 * must continue. */
45 allow_rules(FALSE);
46 }
47 if ((yylval.record = (record_t*)malloc(sizeof(record_t))))
48 if (((yylval.record)->string = (char *) strdup(yytext))) {
49 (yylval.record)->lineno = lineno;
50 return LABEL;
51 }
52 eef_log(LOG_ERR, "out of memory.");
53 return 0;
54 }
55 {path} { if ((yylval.record = (record_t *)malloc(sizeof(record_t))))
56 if (((yylval.record)->string = strdup(yytext))) {
57 (yylval.record)->lineno = lineno;
58 BEGIN path;
59 return PATH;
60 }
61 eef_log(LOG_ERR, "out of memory.");
62 return 0;
63 }
64 <path>{path} { if ((yylval.record = (record_t *)malloc(sizeof(record_t))))
65 if (((yylval.record)->string = strdup(yytext))) {
66 (yylval.record)->lineno = lineno;
67 return PATH;
68 }
69 eef_log(LOG_ERR, "out of memory.");
70 return 0;
71 }
72 <path># { BEGIN pathcom; }
73 <path>[ \t]* ;
74 <path>\n { BEGIN INITIAL; yyless(0); return '\n'; }
75 <path>. { eef_log(LOG_ERR, "unrecognized tokens in path name."); }
76 <pathcom>. ;
77 <pathcom>\n { BEGIN INITIAL; yyless(0); return '\n'; }
78 {nl} { ++lineno; }
79 {tokens} { return yytext[0]; }
80 {trans} { return TRANS; }
81 {comment} { ++lineno; BEGIN INITIAL ; }
82 {pdlstr} { if ((yylval.record = (record_t*)malloc(sizeof(record_t)))) {
83 if (yytext[yyleng-2] == '\\') {
84 if (((yylval.record)->string = strdup(yytext+1))) {
85 (yylval.record)->string[yyleng-2] = '\0';
86 (yylval.record)->string[yyleng-3] = '\"';
87 (yylval.record)->lineno = lineno;
88 yyless(yyleng-1); /* make the next string start with " */
89 BEGIN mq;
90 return STRING;
91 }
92 } else {
93 if (yytext[yyleng-1] == '\"') {
94 if (((yylval.record)->string = strdup(yytext+1))) {
95 (yylval.record)->string[yyleng-2] = '\0';
96 (yylval.record)->lineno = lineno;
97 return STRING;
98 }
99 }
100 }
101 eef_log(LOG_ERR, "out of memory.");
102 return 0;
103 } else
104 eef_log(LOG_ERR, "string contains a newline.");
105 }
106 <mq>{pdlstr} { if ((yylval.record = (record_t*)malloc(sizeof(record_t)))) {
107 if (yytext[yyleng-2] == '\\') {
108 if (((yylval.record)->string = strdup(yytext+1))) {
109 (yylval.record)->string[yyleng-2] = '\0';
110 (yylval.record)->string[yyleng-3] = '\"';
111 (yylval.record)->lineno = lineno;
112 yyless(yyleng-1); /* make the next string start with " */
113 BEGIN INITIAL;
114 return STRING;
115 }
116 } else {
117 eef_log(LOG_ERR, "Unballanced quotes.");
118 return 0;
119 }
120 }
121 eef_log(LOG_ERR, "out of memory.");
122 return 0;
123 }
124 . { eef_log(LOG_WARNING, "unrecoginzed token '%c'.", yytext[0]);
125 return yytext[0];
126 }
127 %%
128
129 #ifdef HAVE_FLEX
130
131 void delete_lex_buffer(void)
132 {
133 yy_delete_buffer(YY_CURRENT_BUFFER);
134 }
135
136 #endif

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28