forked from lei.chen/myxce
fix typo of perflag && reformat .peg
This commit is contained in:
parent
12dcc2a60d
commit
ff6d4eeccd
4 changed files with 165 additions and 165 deletions
|
|
@ -487,7 +487,7 @@ int calc_wanted_global_resvals(xvec_idval_t* resvals, resmgr_t* resmgr,
|
||||||
}
|
}
|
||||||
|
|
||||||
int calc_wanted_host_resvals(xvec_idval_t* resvals, resmgr_t* resmgr,
|
int calc_wanted_host_resvals(xvec_idval_t* resvals, resmgr_t* resmgr,
|
||||||
xlist_t* rusages, rusage_per_type_t perfflag,
|
xlist_t* rusages, rusage_per_type_t perflag,
|
||||||
int nhosts, int nslots)
|
int nhosts, int nslots)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
||||||
|
|
@ -2,87 +2,87 @@
|
||||||
%value "char *"
|
%value "char *"
|
||||||
%auxil "rusage_context_t *"
|
%auxil "rusage_context_t *"
|
||||||
%source {
|
%source {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
||||||
#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \
|
#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)
|
fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer)
|
||||||
#endif
|
#endif
|
||||||
#define PCC_ERROR(auxil) my_rusage_error(auxil)
|
#define PCC_ERROR(auxil) my_rusage_error(auxil)
|
||||||
|
|
||||||
static void my_rusage_error(rusage_context_t *auxil) {
|
static void my_rusage_error(rusage_context_t *auxil) {
|
||||||
/* Calculate line/column from max_err */
|
/* Calculate line/column from max_err */
|
||||||
auxil->has_error = 1;
|
auxil->has_error = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
%common {
|
%common {
|
||||||
#include "resreq.h"
|
#include "resreq.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
|
||||||
#define PCC_GETCHAR(auxil) \
|
#define PCC_GETCHAR(auxil) \
|
||||||
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
||||||
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
||||||
c; \
|
c; \
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rusage_spec <- _ rusage_params _ EOF
|
rusage_spec <- _ rusage_params _ EOF
|
||||||
|
|
||||||
rusage_params <- first:rusage_param _ ',' _ rest:rusage_params
|
rusage_params <- first:rusage_param _ ',' _ rest:rusage_params
|
||||||
/ rusage_param
|
/ rusage_param
|
||||||
|
|
||||||
rusage_param <- key:identifier _ '=' v:resvalue _ duration _ decay {
|
rusage_param <- key:identifier _ '=' v:resvalue _ duration _ decay {
|
||||||
rusage_value_t *rusage = (rusage_value_t *)calloc(1, sizeof(*rusage));
|
rusage_value_t *rusage = (rusage_value_t *)calloc(1, sizeof(*rusage));
|
||||||
if (rusage != NULL) {
|
if (rusage != NULL) {
|
||||||
rusage->res = auxil->resname;
|
rusage->res = auxil->resname;
|
||||||
rusage->per_flag = auxil->per_flag;
|
rusage->per_flag = auxil->per_flag;
|
||||||
rusage->value = auxil->resvalue;
|
rusage->value = auxil->resvalue;
|
||||||
rusage->duration = auxil->duration_value;
|
rusage->duration = auxil->duration_value;
|
||||||
rusage->decay_flag = auxil->decay_flag;
|
rusage->decay_flag = auxil->decay_flag;
|
||||||
auxil->resname = NULL;
|
auxil->resname = NULL;
|
||||||
|
|
||||||
xlist_store(auxil->rusages, rusage);
|
xlist_store(auxil->rusages, rusage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auxil->resname != NULL) {
|
if (auxil->resname != NULL) {
|
||||||
free(auxil->resname);
|
free(auxil->resname);
|
||||||
auxil->resname = NULL;
|
auxil->resname = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
duration <- ':duration=' _ duration_value _
|
duration <- ':duration=' _ duration_value _
|
||||||
/ empty_duration
|
/ empty_duration
|
||||||
|
|
||||||
empty_duration <- { } { auxil->duration_value = -1.0; }
|
empty_duration <- { } { auxil->duration_value = -1.0; }
|
||||||
|
|
||||||
decay <- ':decay=' _ decay_value _
|
decay <- ':decay=' _ decay_value _
|
||||||
/ empty_decay
|
/ empty_decay
|
||||||
|
|
||||||
empty_decay <- { } { auxil->decay_flag = 0; }
|
empty_decay <- { } { auxil->decay_flag = 0; }
|
||||||
|
|
||||||
identifier <- [a-zA-Z_][a-zA-Z_0-9]* { auxil->resname = strdup($0); }
|
identifier <- [a-zA-Z_][a-zA-Z_0-9]* { auxil->resname = strdup($0); }
|
||||||
|
|
||||||
resvalue <- number '/' per_type { auxil->resvalue = auxil->tmp_value; }
|
resvalue <- number '/' per_type { auxil->resvalue = auxil->tmp_value; }
|
||||||
/ number { auxil->resvalue = auxil->tmp_value; auxil->per_flag = PER_DEFAULT; }
|
/ number { auxil->resvalue = auxil->tmp_value; auxil->per_flag = PER_DEFAULT; }
|
||||||
|
|
||||||
per_type <- 'task' { auxil->per_flag = PER_TASK; }
|
per_type <- 'task' { auxil->per_flag = PER_TASK; }
|
||||||
/ 'job' { auxil->per_flag = PER_JOB; }
|
/ 'job' { auxil->per_flag = PER_JOB; }
|
||||||
/ 'host' { auxil->per_flag = PER_HOST; }
|
/ 'host' { auxil->per_flag = PER_HOST; }
|
||||||
|
|
||||||
duration_value <- v:number duration_unit { auxil->duration_value = auxil->tmp_value * auxil->duration_multiply; }
|
duration_value <- v:number duration_unit { auxil->duration_value = auxil->tmp_value * auxil->duration_multiply; }
|
||||||
/ v:number { auxil->duration_value = auxil->tmp_value * 60.0; }
|
/ v:number { auxil->duration_value = auxil->tmp_value * 60.0; }
|
||||||
|
|
||||||
duration_unit <- 'h' { auxil->duration_multiply = 3600.0; }
|
duration_unit <- 'h' { auxil->duration_multiply = 3600.0; }
|
||||||
/ 'm' { auxil->duration_multiply = 60.0; }
|
/ 'm' { auxil->duration_multiply = 60.0; }
|
||||||
/ 's' { auxil->duration_multiply = 1.0; }
|
/ 's' { auxil->duration_multiply = 1.0; }
|
||||||
|
|
||||||
decay_value <- '0' { auxil->decay_flag = 0; }
|
decay_value <- '0' { auxil->decay_flag = 0; }
|
||||||
/ '1' { auxil->decay_flag = 1; }
|
/ '1' { auxil->decay_flag = 1; }
|
||||||
|
|
||||||
number <- < [0-9]+('.'[0-9]*)? > { auxil->tmp_value = atof($0); }
|
number <- < [0-9]+('.'[0-9]*)? > { auxil->tmp_value = atof($0); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,45 +2,45 @@
|
||||||
%value "char *"
|
%value "char *"
|
||||||
%auxil "section_context_t *"
|
%auxil "section_context_t *"
|
||||||
%source {
|
%source {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
||||||
#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \
|
#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)
|
fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer)
|
||||||
#endif
|
#endif
|
||||||
#define PCC_ERROR(auxil) my_report_error(auxil)
|
#define PCC_ERROR(auxil) my_report_error(auxil)
|
||||||
|
|
||||||
void my_report_error(section_context_t *auxil) {
|
void my_report_error(section_context_t *auxil) {
|
||||||
/* Calculate line/column from max_err */
|
/* Calculate line/column from max_err */
|
||||||
auxil->has_error = 1;
|
auxil->has_error = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
%common {
|
%common {
|
||||||
#include "resreq.h"
|
#include "resreq.h"
|
||||||
|
|
||||||
#define PCC_GETCHAR(auxil) \
|
#define PCC_GETCHAR(auxil) \
|
||||||
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
||||||
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
||||||
c; \
|
c; \
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
statement <- _ resource_statement _ EOF
|
statement <- _ resource_statement _ EOF
|
||||||
|
|
||||||
resource_statement <- select:select_clause? _ usage:usage_clause? _ span:span_clause? _ same:same_clause? _ affinity:affinity_clause? {
|
resource_statement <- select:select_clause? _ usage:usage_clause? _ span:span_clause? _ same:same_clause? _ affinity:affinity_clause? {
|
||||||
auxil->data.selectString = select;
|
auxil->data.selectString = select;
|
||||||
auxil->data.rusageString = usage;
|
auxil->data.rusageString = usage;
|
||||||
auxil->data.spanString = span;
|
auxil->data.spanString = span;
|
||||||
auxil->data.sameString = same;
|
auxil->data.sameString = same;
|
||||||
auxil->data.affinityString = affinity;
|
auxil->data.affinityString = affinity;
|
||||||
$$ = NULL;
|
$$ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
select_clause <- "select[" _ s:select_statement _ "]" { $$ = s; }
|
select_clause <- "select[" _ s:select_statement _ "]" { $$ = s; }
|
||||||
/ s:select_statement {$$ = s; }
|
/ s:select_statement {$$ = s; }
|
||||||
|
|
@ -56,15 +56,15 @@ usage_clause <- "rusage[" _ usage:usage_statement _ "]" { $$ = usage; }
|
||||||
|
|
||||||
|
|
||||||
usage_statement <- (!("span[" / "]") .)* { $$ = strdup($0); }
|
usage_statement <- (!("span[" / "]") .)* { $$ = strdup($0); }
|
||||||
/ (!("same[" / "]") .)* { $$ = strdup($0); }
|
/ (!("same[" / "]") .)* { $$ = strdup($0); }
|
||||||
/ (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
/ (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
||||||
|
|
||||||
|
|
||||||
span_clause <- "span[" _ span:span_statement _ "]" { $$ = span; }
|
span_clause <- "span[" _ span:span_statement _ "]" { $$ = span; }
|
||||||
|
|
||||||
|
|
||||||
span_statement <- (!("same[" / "]") .)* { $$ = strdup($0); }
|
span_statement <- (!("same[" / "]") .)* { $$ = strdup($0); }
|
||||||
/ (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
/ (!("affinity[" / "]") .)* { $$ = strdup($0); }
|
||||||
|
|
||||||
|
|
||||||
same_clause <- "same[" _ same:same_statement _ "]" { $$ = same; }
|
same_clause <- "same[" _ same:same_statement _ "]" { $$ = same; }
|
||||||
|
|
|
||||||
|
|
@ -2,113 +2,113 @@
|
||||||
%value "char *"
|
%value "char *"
|
||||||
%auxil "resreq_context_t *"
|
%auxil "resreq_context_t *"
|
||||||
%source {
|
%source {
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" };
|
||||||
#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \
|
#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)
|
fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer)
|
||||||
#endif
|
#endif
|
||||||
#define PCC_ERROR(auxil) my_resreq_error(auxil)
|
#define PCC_ERROR(auxil) my_resreq_error(auxil)
|
||||||
|
|
||||||
static void my_resreq_error(resreq_context_t *auxil) {
|
static void my_resreq_error(resreq_context_t *auxil) {
|
||||||
/* Calculate line/column from max_err */
|
/* Calculate line/column from max_err */
|
||||||
auxil->has_error = 1;
|
auxil->has_error = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
%common {
|
%common {
|
||||||
#include "resreq.h"
|
#include "resreq.h"
|
||||||
#include "xlist.h"
|
#include "xlist.h"
|
||||||
|
|
||||||
#define PCC_GETCHAR(auxil) \
|
#define PCC_GETCHAR(auxil) \
|
||||||
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
({ int c = (auxil->input[auxil->pos] != '\0') ? (int)auxil->input[auxil->pos ++]: -1; \
|
||||||
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
if (auxil->pos > auxil->err_pos) auxil->err_pos = auxil->pos; \
|
||||||
c; \
|
c; \
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
statement <- _ resreq _ EOF
|
statement <- _ resreq _ EOF
|
||||||
|
|
||||||
resreq <- alter_resreq {
|
resreq <- alter_resreq {
|
||||||
xce_resreq_t *resreq = auxil->resreq;
|
xce_resreq_t *resreq = auxil->resreq;
|
||||||
resreq->tag = XCE_RESREQ_ALTER;
|
resreq->tag = XCE_RESREQ_ALTER;
|
||||||
resreq->u.alter = auxil->alter;
|
resreq->u.alter = auxil->alter;
|
||||||
auxil->alter = NULL;
|
auxil->alter = NULL;
|
||||||
}
|
}
|
||||||
/ compound_resreq {
|
/ compound_resreq {
|
||||||
xce_resreq_t *resreq = auxil->resreq;
|
xce_resreq_t *resreq = auxil->resreq;
|
||||||
if (resreq != NULL) {
|
if (resreq != NULL) {
|
||||||
resreq->tag = XCE_RESREQ_COMPOUND;
|
resreq->tag = XCE_RESREQ_COMPOUND;
|
||||||
resreq->u.compound = auxil->compound;
|
resreq->u.compound = auxil->compound;
|
||||||
auxil->compound = NULL;
|
auxil->compound = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/ primary_resreq {
|
/ primary_resreq {
|
||||||
xce_resreq_t *resreq = auxil->resreq;
|
xce_resreq_t *resreq = auxil->resreq;
|
||||||
if (resreq != NULL) {
|
if (resreq != NULL) {
|
||||||
resreq->tag = XCE_RESREQ_PRIMARY;
|
resreq->tag = XCE_RESREQ_PRIMARY;
|
||||||
resreq->u.primary = auxil->primary;
|
resreq->u.primary = auxil->primary;
|
||||||
auxil->primary = NULL;
|
auxil->primary = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alter_resreq <- alter_resreq_term _ ('||' _ alter_resreq_term _)*
|
alter_resreq <- alter_resreq_term _ ('||' _ alter_resreq_term _)*
|
||||||
|
|
||||||
alter_resreq_term <- '{' _ compound_resreq _ '}' _ {
|
alter_resreq_term <- '{' _ compound_resreq _ '}' _ {
|
||||||
xce_alter_resreq_t *alter = auxil->alter;
|
xce_alter_resreq_t *alter = auxil->alter;
|
||||||
if (alter == NULL) {
|
if (alter == NULL) {
|
||||||
alter = (xce_alter_resreq_t *)calloc(1, sizeof(*alter));
|
alter = (xce_alter_resreq_t *)calloc(1, sizeof(*alter));
|
||||||
if (alter != NULL) {
|
if (alter != NULL) {
|
||||||
xlist_init(&(alter->compounds), 8);
|
xlist_init(&(alter->compounds), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
auxil->alter = alter;
|
auxil->alter = alter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alter != NULL) {
|
if (alter != NULL) {
|
||||||
if (auxil->compound != NULL) {
|
if (auxil->compound != NULL) {
|
||||||
xlist_store(&(alter->compounds), auxil->compound);
|
xlist_store(&(alter->compounds), auxil->compound);
|
||||||
auxil->compound = NULL;
|
auxil->compound = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compound_resreq <- compound_resreq_term _ ('+' _ compound_resreq_term _)*
|
compound_resreq <- compound_resreq_term _ ('+' _ compound_resreq_term _)*
|
||||||
|
|
||||||
compound_resreq_term <- < int_num _ '*' _ '{' _ primary_resreq _ '}' _
|
compound_resreq_term <- < int_num _ '*' _ '{' _ primary_resreq _ '}' _
|
||||||
/ '{' _ primary_resreq _ '}' _ > {
|
/ '{' _ primary_resreq _ '}' _ > {
|
||||||
xce_compound_resreq_t *compound = auxil->compound;
|
xce_compound_resreq_t *compound = auxil->compound;
|
||||||
if (compound == NULL) {
|
if (compound == NULL) {
|
||||||
compound = (xce_compound_resreq_t *)calloc(1, sizeof(*compound));
|
compound = (xce_compound_resreq_t *)calloc(1, sizeof(*compound));
|
||||||
if (compound != NULL) {
|
if (compound != NULL) {
|
||||||
xlist_init(&(compound->primaries), 8);
|
xlist_init(&(compound->primaries), 8);
|
||||||
}
|
}
|
||||||
auxil->compound = compound;
|
auxil->compound = compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compound != NULL) {
|
if (compound != NULL) {
|
||||||
xce_primary_resreq_t *primary = auxil->primary;
|
xce_primary_resreq_t *primary = auxil->primary;
|
||||||
|
|
||||||
if (primary != NULL) {
|
if (primary != NULL) {
|
||||||
primary->minTasks = auxil->resreq_fact_count;
|
primary->minTasks = auxil->resreq_fact_count;
|
||||||
primary->maxTasks = auxil->resreq_fact_count;
|
primary->maxTasks = auxil->resreq_fact_count;
|
||||||
xlist_store(&(compound->primaries), primary);
|
xlist_store(&(compound->primaries), primary);
|
||||||
auxil->primary = NULL;
|
auxil->primary = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
primary_resreq <- < (! ('{' / '}' ) .)* > {
|
primary_resreq <- < (! ('{' / '}' ) .)* > {
|
||||||
xce_primary_resreq_t *primary = (xce_primary_resreq_t *)calloc(1, sizeof(*primary));
|
xce_primary_resreq_t *primary = (xce_primary_resreq_t *)calloc(1, sizeof(*primary));
|
||||||
if (primary != NULL) {
|
if (primary != NULL) {
|
||||||
auxil->primary = primary;
|
auxil->primary = primary;
|
||||||
parse_resreq_primary(primary, (char *)$0, &(auxil->errmsg));
|
parse_resreq_primary(primary, (char *)$0, &(auxil->errmsg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int_num <- < [0-9]+ > { auxil->resreq_fact_count = atoi($0); }
|
int_num <- < [0-9]+ > { auxil->resreq_fact_count = atoi($0); }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue