fix typo of perflag && reformat .peg
This commit is contained in:
parent
12dcc2a60d
commit
ff6d4eeccd
4 changed files with 165 additions and 165 deletions
|
|
@ -2,88 +2,88 @@
|
|||
%value "char *"
|
||||
%auxil "rusage_context_t *"
|
||||
%source {
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#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) \
|
||||
#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_rusage_error(auxil)
|
||||
#endif
|
||||
#define PCC_ERROR(auxil) my_rusage_error(auxil)
|
||||
|
||||
static void my_rusage_error(rusage_context_t *auxil) {
|
||||
/* Calculate line/column from max_err */
|
||||
auxil->has_error = 1;
|
||||
static void my_rusage_error(rusage_context_t *auxil) {
|
||||
/* Calculate line/column from max_err */
|
||||
auxil->has_error = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%common {
|
||||
#include "resreq.h"
|
||||
#include "xlist.h"
|
||||
#include "resreq.h"
|
||||
#include "xlist.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; \
|
||||
})
|
||||
#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; \
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
rusage_spec <- _ rusage_params _ EOF
|
||||
|
||||
rusage_params <- first:rusage_param _ ',' _ rest:rusage_params
|
||||
/ rusage_param
|
||||
|
||||
/ rusage_param
|
||||
|
||||
rusage_param <- key:identifier _ '=' v:resvalue _ duration _ decay {
|
||||
rusage_value_t *rusage = (rusage_value_t *)calloc(1, sizeof(*rusage));
|
||||
if (rusage != NULL) {
|
||||
rusage->res = auxil->resname;
|
||||
rusage->per_flag = auxil->per_flag;
|
||||
rusage->value = auxil->resvalue;
|
||||
rusage->duration = auxil->duration_value;
|
||||
rusage->decay_flag = auxil->decay_flag;
|
||||
auxil->resname = NULL;
|
||||
rusage_value_t *rusage = (rusage_value_t *)calloc(1, sizeof(*rusage));
|
||||
if (rusage != NULL) {
|
||||
rusage->res = auxil->resname;
|
||||
rusage->per_flag = auxil->per_flag;
|
||||
rusage->value = auxil->resvalue;
|
||||
rusage->duration = auxil->duration_value;
|
||||
rusage->decay_flag = auxil->decay_flag;
|
||||
auxil->resname = NULL;
|
||||
|
||||
xlist_store(auxil->rusages, rusage);
|
||||
}
|
||||
xlist_store(auxil->rusages, rusage);
|
||||
}
|
||||
|
||||
if (auxil->resname != NULL) {
|
||||
free(auxil->resname);
|
||||
auxil->resname = NULL;
|
||||
}
|
||||
if (auxil->resname != NULL) {
|
||||
free(auxil->resname);
|
||||
auxil->resname = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
duration <- ':duration=' _ duration_value _
|
||||
/ empty_duration
|
||||
/ empty_duration
|
||||
|
||||
empty_duration <- { } { auxil->duration_value = -1.0; }
|
||||
|
||||
decay <- ':decay=' _ decay_value _
|
||||
/ empty_decay
|
||||
/ empty_decay
|
||||
|
||||
empty_decay <- { } { auxil->decay_flag = 0; }
|
||||
|
||||
|
||||
identifier <- [a-zA-Z_][a-zA-Z_0-9]* { auxil->resname = strdup($0); }
|
||||
|
||||
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; }
|
||||
/ 'job' { auxil->per_flag = PER_JOB; }
|
||||
/ 'host' { auxil->per_flag = PER_HOST; }
|
||||
/ 'job' { auxil->per_flag = PER_JOB; }
|
||||
/ 'host' { auxil->per_flag = PER_HOST; }
|
||||
|
||||
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; }
|
||||
/ 'm' { auxil->duration_multiply = 60.0; }
|
||||
/ 's' { auxil->duration_multiply = 1.0; }
|
||||
|
||||
/ 'm' { auxil->duration_multiply = 60.0; }
|
||||
/ 's' { auxil->duration_multiply = 1.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); }
|
||||
|
||||
EOL <- "\n" / "\r\n" / "\r" / "\0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue