- use librtti
- Fix issue to xce_get() api cause client side crash - add parse resreq section - add rusage parser - parse resreq with basic support alternative & compound, still miss select
This commit is contained in:
parent
e7dc09c604
commit
cd4f3953b2
20 changed files with 1422 additions and 15 deletions
85
src/lib/section.peg
Normal file
85
src/lib/section.peg
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
%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[" / "]") .)* {$$ = strdup($0); }
|
||||
/ (!("span[" "]" / "]") .)* {$$ = strdup($0); }
|
||||
/ (!("same[" !"]" / "]") .)* {$$ = strdup($0);}
|
||||
/ (!("affinity[" / "]") !"]" .)* {$$ = strdup($0);}
|
||||
|
||||
|
||||
usage_clause <- "rusage[" _ usage:usage_statement _ "]" { $$ = usage; }
|
||||
|
||||
|
||||
usage_statement <- (!("span[" / "]") .)* { $$ = strdup($0); }
|
||||
/ (!("same[" / "]") .)* { $$ = strdup($0); }
|
||||
/ (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
||||
|
||||
|
||||
span_clause <- "span[" _ span:span_statement _ "]" { $$ = span; }
|
||||
|
||||
|
||||
span_statement <- (!("same[" / "]") .)* { $$ = strdup($0); }
|
||||
/ (!("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 <- !.
|
||||
Loading…
Add table
Add a link
Reference in a new issue