summaryrefslogtreecommitdiffstats
path: root/src/config-bison.y
diff options
context:
space:
mode:
authorJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-10-18 10:00:38 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2012-01-11 19:55:00 +0100
commit97f80d2e5d6f984a71c870748bc9c51f40dd0839 (patch)
treed1d0d9632ca0fa8aa291b577ae950cee47cdd51d /src/config-bison.y
parentc8d8f6fb17a206f282df3ad77aca8c740cb24fbc (diff)
downloadlatrace-97f80d2e5d6f984a71c870748bc9c51f40dd0839.tar.gz
latrace-97f80d2e5d6f984a71c870748bc9c51f40dd0839.tar.xz
latrace-97f80d2e5d6f984a71c870748bc9c51f40dd0839.zip
error simulation: application part
Diffstat (limited to 'src/config-bison.y')
-rw-r--r--src/config-bison.y170
1 files changed, 142 insertions, 28 deletions
diff --git a/src/config-bison.y b/src/config-bison.y
index 944f59b..14ee5a3 100644
--- a/src/config-bison.y
+++ b/src/config-bison.y
@@ -21,8 +21,9 @@
%name-prefix "lt_config_"
%{
-#include <stdlib.h>
+#include <strings.h>
#include <string.h>
+#include <stdlib.h>
#include "config.h"
#include "lib-include.h"
@@ -33,7 +34,7 @@ static struct lt_config_app *scfg;
int lt_config_lex(void);
void lt_config_error(const char *m);
-#define ERROR(fmt, args...) \
+#define ABORT(fmt, args...) \
do { \
char ebuf[1024]; \
sprintf(ebuf, fmt, ## args); \
@@ -42,13 +43,17 @@ do { \
} while(0)
static LT_LIST_HEAD(opt_list);
+static struct lt_error_app error_app;
+static struct lt_error_app_run *error_app_run;
+static struct lt_error_app_go *error_app_go;
+static struct lt_error_app_return *error_app_return;
#define OPTION_ADD(idx, sval, nval) \
do { \
struct lt_config_opt *opt; \
opt = lt_config_opt_new(scfg, idx, sval, nval); \
if (!opt) \
- ERROR("failed to process option\n"); \
+ ABORT("failed to process option\n"); \
lt_list_add_tail(&opt->list, &opt_list); \
} while(0)
@@ -66,6 +71,9 @@ static struct lt_list_head ln_names;
%token OPT_LIBS OPT_LIBS_TO OPT_LIBS_FROM
%token OPT_SYM OPT_SYM_OMIT OPT_SYM_BELOW OPT_SYM_NOEXIT
%token OPT_ARGS_STRING_POINTER_LENGTH
+%token ERROR
+%token ERR_DO ERR_DIR ERR_RUN ERR_GO ERR_RETURN ERR_N
+%token ERR_PROG ERR_ARGS ERR_FILTER ERR_SEQ
%union
{
@@ -79,9 +87,11 @@ static struct lt_list_head ln_names;
%%
entry:
-entry include_def
+entry include
|
-entry options_def
+entry options
+|
+entry errors
|
entry END
{
@@ -91,18 +101,18 @@ entry END
|
/* left blank intentionally */
-include_def: INCLUDE '"' NAME '"'
+include: INCLUDE '"' NAME '"'
{
if (lt_inc_open(scfg->sh, lt_config_sinc, $3))
- ERROR("failed to process include");
+ ABORT("failed to process include");
}
-options_def: OPTIONS '{' OPTIONS_DEF '}'
+options: OPTIONS '{' OPTIONS_DEF '}'
{
struct lt_config_opt *opt, *opth;
if (lt_config_opt_process(scfg, &opt_list))
- ERROR("failed to process options");
+ ABORT("failed to process options");
lt_list_for_each_entry_safe(opt, opth, &opt_list, list) {
lt_list_del(&opt->list);
@@ -185,8 +195,8 @@ OPTIONS_DEF OPT_LIBS '=' list_names_comma
{
char libs[LT_LIBS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, libs, LT_LIBS_MAXSIZE))
- ERROR("failed to process libs option");
+ if (lt_config_ln_fill_buf(&ln_names, libs, LT_LIBS_MAXSIZE))
+ ABORT("failed to process libs option");
OPTION_ADD(LT_OPT_LIBS, libs, -1);
}
@@ -195,8 +205,8 @@ OPTIONS_DEF OPT_LIBS_TO '=' list_names_comma
{
char libs_to[LT_LIBS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, libs_to, LT_LIBS_MAXSIZE))
- ERROR("failed to process libs_to option");
+ if (lt_config_ln_fill_buf(&ln_names, libs_to, LT_LIBS_MAXSIZE))
+ ABORT("failed to process libs_to option");
OPTION_ADD(LT_OPT_LIBS_TO, libs_to, -1);
}
@@ -205,8 +215,8 @@ OPTIONS_DEF OPT_LIBS_FROM '=' list_names_comma
{
char libs_from[LT_LIBS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, libs_from, LT_LIBS_MAXSIZE))
- ERROR("failed to process libs_from option");
+ if (lt_config_ln_fill_buf(&ln_names, libs_from, LT_LIBS_MAXSIZE))
+ ABORT("failed to process libs_from option");
OPTION_ADD(LT_OPT_LIBS_FROM, libs_from, -1);
}
@@ -215,8 +225,8 @@ OPTIONS_DEF OPT_SYM '=' list_names_comma
{
char sym[LT_LIBS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, sym, LT_LIBS_MAXSIZE))
- ERROR("failed to process sym option");
+ if (lt_config_ln_fill_buf(&ln_names, sym, LT_LIBS_MAXSIZE))
+ ABORT("failed to process sym option");
OPTION_ADD(LT_OPT_SYM, sym, -1);
}
@@ -225,8 +235,8 @@ OPTIONS_DEF OPT_SYM_OMIT '=' list_names_comma
{
char sym_omit[LT_SYMBOLS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, sym_omit, LT_SYMBOLS_MAXSIZE))
- ERROR("failed to process sym_omit option");
+ if (lt_config_ln_fill_buf(&ln_names, sym_omit, LT_SYMBOLS_MAXSIZE))
+ ABORT("failed to process sym_omit option");
OPTION_ADD(LT_OPT_SYM_OMIT, sym_omit, -1);
}
@@ -235,8 +245,8 @@ OPTIONS_DEF OPT_SYM_BELOW '=' list_names_comma
{
char sym_below[LT_SYMBOLS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, sym_below, LT_SYMBOLS_MAXSIZE))
- ERROR("failed to process sym_below option");
+ if (lt_config_ln_fill_buf(&ln_names, sym_below, LT_SYMBOLS_MAXSIZE))
+ ABORT("failed to process sym_below option");
OPTION_ADD(LT_OPT_SYM_BELOW, sym_below, -1);
}
@@ -245,8 +255,8 @@ OPTIONS_DEF OPT_SYM_NOEXIT '=' list_names_comma
{
char sym_noexit[LT_SYMBOLS_MAXSIZE];
- if (lt_config_ln_fill(&ln_names, sym_noexit, LT_SYMBOLS_MAXSIZE))
- ERROR("failed to process sym_below option");
+ if (lt_config_ln_fill_buf(&ln_names, sym_noexit, LT_SYMBOLS_MAXSIZE))
+ ABORT("failed to process sym_below option");
OPTION_ADD(LT_OPT_SYM_NOEXIT, sym_noexit, -1);
}
@@ -262,21 +272,125 @@ list_names_comma:
list_names_comma ',' NAME
{
if (lt_config_ln_add(&ln_names, $3))
- ERROR("failed to add list name");
+ ABORT("failed to add list name");
}
|
NAME
{
if (lt_config_ln_add(&ln_names, $1))
- ERROR("failed to add list name");
+ ABORT("failed to add list name");
+}
+
+errors: ERROR NAME '{' error_def '}'
+{
+ error_app.name = strdup($2);
+
+ if (lt_error_app(scfg, &error_app))
+ ABORT("failed to add error");
+
+ lt_error_app_init(&error_app);
+}
+
+error_def:
+error_def error_run
+{
+ lt_list_add_tail(&error_app_run->list_app, &error_app.head_run);
+ error_app_run = NULL;
+}
+|
+error_def error_go
+{
+ lt_list_add_tail(&error_app_go->list, &error_app.head_go);
+ error_app_go = NULL;
+}
+|
+error_def error_return
+{
+ lt_list_add_tail(&error_app_return->list_app, &error_app.head_return);
+ error_app_return = NULL;
+}
+|
+error_def ERR_DIR NAME
+{
+ error_app.dir = strdup($3);
+}
+|
+error_def ERR_PROG NAME
+{
+ if (error_app.prog)
+ ABORT("only one PROG clause allowed");
+
+ error_app.prog = strdup($3);
+}
+|
+/* left blank intentionally */
+
+
+error_return: ERR_RETURN NAME '{' error_return_def '}'
+{
+ error_app_return->name = strdup($2);
+}
+
+error_return_def:
+error_return_def NAME '=' VALUE
+{
+ if (lt_error_return_ass(scfg, &error_app_return, $2, $4))
+ ABORT("failed to add symbol to return definition");
+}
+|
+error_return_def ERR_FILTER ERR_SEQ
+{
+ if (lt_error_return_filter(scfg, &error_app_return,
+ LT_ERROR_FILTER_TYPE_SEQ, NULL))
+ ABORT("failed to add filter to return definition");
+}
+|
+/* left blank intentionally */
+
+
+error_run: ERR_RUN NAME '{' error_run_def '}'
+{
+ error_app_run->name = strdup($2);
+}
+
+error_run_def:
+error_run_def ERR_ARGS list_names_comma
+{
+ if (lt_error_run_args(scfg, &error_app_run, &ln_names))
+ ABORT("failed to add run");
+}
+|
+error_run_def ERR_RETURN list_names_comma
+{
+ if (lt_error_run_return(scfg, &error_app_run, &error_app, &ln_names))
+ ABORT("failed to add run");
+}
+|
+
+error_go:
+ERR_GO NAME list_names_comma
+{
+ if (lt_error_go(scfg, &error_app_go, &error_app,
+ strdup($2), 1, &ln_names))
+ ABORT("failed to add go");
+}
+|
+ERR_GO NAME ERR_N '=' VALUE list_names_comma
+{
+ if (lt_error_go(scfg, &error_app_go, &error_app,
+ strdup($2), $5, &ln_names))
+ ABORT("failed to add go");
}
%%
int lt_config_parse_init(struct lt_config_app *cfg, struct lt_include *inc)
{
- scfg = cfg;
- lt_config_sinc = inc;
+ scfg = cfg;
+ lt_config_sinc = inc;
lt_init_list_head(&ln_names);
- return 0;
+ lt_error_app_init(&error_app);
+ error_app_run = NULL;
+ error_app_go = NULL;
+ return 0;
}