71 lines
2.1 KiB
Text
71 lines
2.1 KiB
Text
%prefix "xce_section"
|
|
%value "char *"
|
|
%auxil "section_context_t *"
|
|
%source {
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#if 0
|
|
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
|
#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \
|
|
fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer)
|
|
#endif
|
|
#define PCC_ERROR(auxil) my_report_error(auxil)
|
|
|
|
void my_report_error(section_context_t *auxil) {
|
|
/* Calculate line/column from max_err */
|
|
auxil->has_error = 1;
|
|
}
|
|
}
|
|
|
|
%common {
|
|
#include "resreq.h"
|
|
|
|
#define PCC_GETCHAR(auxil) \
|
|
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
|
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
|
c; \
|
|
})
|
|
|
|
}
|
|
|
|
|
|
statement <- _ resource_statement _ EOF
|
|
|
|
resource_statement <- select:select_clause? _ usage:usage_clause? _ span:span_clause? _ same:same_clause? _ affinity:affinity_clause? {
|
|
auxil->data.selectString = select;
|
|
auxil->data.rusageString = usage;
|
|
auxil->data.spanString = span;
|
|
auxil->data.sameString = same;
|
|
auxil->data.affinityString = affinity;
|
|
$$ = NULL;
|
|
}
|
|
|
|
select_clause <- "select[" _ s:select_statement _ "]" { $$ = s; }
|
|
/ s:select_statement {$$ = s; }
|
|
|
|
|
|
select_statement <- (!("rusage[" / "span[" / "same[" / "affinity[" / "]") .)* { $$=strdup($0); }
|
|
|
|
usage_clause <- "rusage[" _ usage:usage_statement _ "]" { $$ = usage; }
|
|
|
|
usage_statement <- (!("span[" / "same[" / "affinity[" / "]") .)* { $$=strdup($0); }
|
|
|
|
span_clause <- "span[" _ span:span_statement _ "]" { $$ = span; }
|
|
|
|
span_statement <- (!("same[" / "affinity[" / "]") .)* { $$=strdup($0); }
|
|
|
|
same_clause <- "same[" _ same:same_statement _ "]" { $$ = same; }
|
|
|
|
same_statement <- (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
|
|
|
affinity_clause <- "affinity[" _ affinity:affinity_statement _ "]" { $$ = affinity; }
|
|
|
|
affinity_statement <- (!"]" .)* { $$ = strdup($0); }
|
|
|
|
EOL <- "\n" / "\r\n" / "\r" / "\0"
|
|
|
|
_ <- [ \t]*
|
|
|
|
EOF <- !.
|