diff options
author | Anders Broman <anders.broman@ericsson.com> | 2013-03-01 23:54:06 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2013-03-01 23:54:06 +0000 |
commit | a5c53e847e9ccc1e3736cb0087c0e07bbabb15ac (patch) | |
tree | 44e1db27f76ce4b79c7143d7491d22dac6158975 /tools/lemon | |
parent | 1ebdb2e521ca0cbd7aeebd1c89b8a5cf6a4cc322 (diff) |
Backports from sqlite lemon.
svn path=/trunk/; revision=47993
Diffstat (limited to 'tools/lemon')
-rw-r--r-- | tools/lemon/lemon.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index ae1731e928..a93a93b766 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -288,9 +288,10 @@ void ErrorMsg( const char *, int, const char *, ... ); #endif /****** From the file "option.h" ******************************************/ +enum option_type { OPT_FLAG=1, OPT_INT, OPT_DBL, OPT_STR, + OPT_FFLAG, OPT_FINT, OPT_FDBL, OPT_FSTR}; struct s_options { - enum { OPT_FLAG=1, OPT_INT, OPT_DBL, OPT_STR, - OPT_FFLAG, OPT_FINT, OPT_FDBL, OPT_FSTR} type; + enum option_type type; const char *label; char *arg; const char *message; @@ -450,14 +451,16 @@ static void Action_add(struct action **app, enum e_action type, struct symbol *s ** The state of the yy_action table under construction is an instance of ** the following structure */ +struct lookahead_action { + int lookahead; /* Value of the lookahead token */ + int action; /* Action to take on the given lookahead */ +}; typedef struct acttab acttab; struct acttab { int nAction; /* Number of used slots in aAction[] */ int nActionAlloc; /* Slots allocated for aAction[] */ - struct { - int lookahead; /* Value of the lookahead token */ - int action; /* Action to take on the given lookahead */ - } *aAction, /* The yy_action[] table under construction */ + struct lookahead_action + *aAction, /* The yy_action[] table under construction */ *aLookahead; /* A single new transaction set */ int mnLookahead; /* Minimum aLookahead[].lookahead */ int mnAction; /* Action associated with mnLookahead */ @@ -491,7 +494,7 @@ static acttab *acttab_alloc(void){ static void acttab_action(acttab *p, int lookahead, int action){ if( p->nLookahead>=p->nLookaheadAlloc ){ p->nLookaheadAlloc += 25; - p->aLookahead = realloc( p->aLookahead, + p->aLookahead = (struct lookahead_action *) realloc( p->aLookahead, sizeof(p->aLookahead[0])*p->nLookaheadAlloc ); if( p->aLookahead==0 ){ fprintf(stderr,"malloc failed\n"); @@ -533,7 +536,7 @@ static int acttab_insert(acttab *p){ if( p->nAction + n >= p->nActionAlloc ){ int oldAlloc = p->nActionAlloc; p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20; - p->aAction = realloc( p->aAction, + p->aAction = (struct lookahead_action *) realloc( p->aAction, sizeof(p->aAction[0])*p->nActionAlloc); if( p->aAction==0 ){ fprintf(stderr,"malloc failed\n"); |