queryparser/lemon.c File Reference

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>

Include dependency graph for lemon.c:

Go to the source code of this file.

Classes

struct  s_options
struct  symbol
struct  rule
struct  config
struct  action
struct  state
struct  plink
struct  lemon
struct  acttab
struct  pstate
struct  axset
struct  s_x1
struct  s_x1node
struct  s_x2
struct  s_x2node
struct  s_x3
struct  s_x3node
struct  s_x4
struct  s_x4node

Defines

#define PRIVATE
#define MAXRHS   1000
#define assert(X)   if(!(X))myassert(__FILE__,__LINE__)
#define SetFind(X, Y)   (X[Y])
#define NO_OFFSET   (-2147483647)
#define MemoryCheck(X)
#define acttab_size(X)   ((X)->nAction)
#define acttab_yyaction(X, N)   ((X)->aAction[N].action)
#define acttab_yylookahead(X, N)   ((X)->aAction[N].lookahead)
#define ERRMSGSIZE   10000
#define LINEWIDTH   79
#define PREFIXLIMIT   60
#define NEXT(A)   (*(char**)(((unsigned long)A)+offset))
#define LISTSIZE   30
#define ISOPT(X)   ((X)[0]=='-'||(X)[0]=='+'||strchr((X),'=')!=0)
#define LINESIZE   1000

Typedefs

typedef acttab acttab
typedef s_x1node x1node
typedef s_x2node x2node
typedef s_x3node x3node
typedef s_x4node x4node

Enumerations

enum  Boolean { B_FALSE = 0, B_TRUE }

Functions

char * msort ()
actionAction_new ()
actionAction_sort ()
void myassert ()
void FindRulePrecedences ()
void FindFirstSets ()
void FindStates ()
void FindLinks ()
void FindFollowSets ()
void FindActions ()
void Configlist_init ()
configConfiglist_add ()
configConfiglist_addbasis ()
void Configlist_closure ()
void Configlist_sort ()
void Configlist_sortbasis ()
configConfiglist_return ()
configConfiglist_basis ()
void Configlist_eat ()
void Configlist_reset ()
void ErrorMsg (const char *, int, const char *,...)
int OptInit ()
int OptNArgs ()
char * OptArg ()
void OptErr ()
void OptPrint ()
void Parse ()
plinkPlink_new ()
void Plink_add ()
void Plink_copy ()
void Plink_delete ()
void Reprint ()
void ReportOutput ()
void ReportTable ()
void ReportHeader ()
void CompressTables ()
void SetSize ()
char * SetNew ()
void SetFree ()
int SetAdd ()
int SetUnion ()
char * Strsafe ()
void Strsafe_init ()
int Strsafe_insert ()
char * Strsafe_find ()
symbolSymbol_new ()
int Symbolcmpp (const void *void_a, const void *void_b)
void Symbol_init ()
int Symbol_insert ()
symbolSymbol_find ()
symbolSymbol_Nth ()
int Symbol_count ()
symbol ** Symbol_arrayof ()
int Configcmp ()
stateState_new ()
void State_init ()
int State_insert ()
stateState_find ()
state ** State_arrayof ()
void Configtable_init ()
int Configtable_insert ()
configConfigtable_find ()
void Configtable_clear ()
static int actioncmp (struct action *ap1, struct action *ap2)
actionAction_sort (struct action *ap)
void Action_add (struct action **app, enum e_action type, struct symbol *sp, char *arg)
void acttab_free (acttab *p)
acttabacttab_alloc (void)
void acttab_action (acttab *p, int lookahead, int action)
int acttab_insert (acttab *p)
void myassert (char *file, int line)
void FindRulePrecedences (struct lemon *xp)
void FindFirstSets (struct lemon *lemp)
PRIVATE struct stategetstate ()
void FindStates (struct lemon *lemp)
PRIVATE void buildshifts ()
PRIVATE struct stategetstate (struct lemon *lemp)
PRIVATE void buildshifts (struct lemon *lemp, struct state *stp)
void FindLinks (struct lemon *lemp)
void FindFollowSets (struct lemon *lemp)
static int resolve_conflict ()
void FindActions (struct lemon *lemp)
static int resolve_conflict (struct action *apx, struct action *apy)
PRIVATE struct confignewconfig ()
PRIVATE void deleteconfig (struct config *old)
configConfiglist_add (struct rule *rp, int dot)
configConfiglist_addbasis (struct rule *rp, int dot)
void Configlist_closure (struct lemon *lemp)
void Configlist_eat (struct config *cfp)
static int findbreak (char *msg, int min, int max)
void memory_error ()
static void handle_D_option (char *z)
static void handle_o_option (char *z)
static void handle_h_option (char *z)
int main (int argc, char **argv)
static char * merge (char *a, char *b, int(*cmp)(), int offset)
char * msort (char *list, char **next, int(*cmp)())
static void errline (int n, int k, FILE *err)
static int argindex (int n)
static int handleflags (int i, FILE *err)
static int handleswitch (int i, FILE *err)
int OptInit (char **a, struct s_options *o, FILE *err)
char * OptArg (int n)
void OptErr (int n)
static void parseonetoken (struct pstate *psp)
static void preprocess_input (char *z)
void Parse (struct lemon *gp)
void Plink_add (struct plink **plpp, struct config *cfp)
void Plink_copy (struct plink **to, struct plink *from)
void Plink_delete (struct plink *plp)
PRIVATE char * file_makename (struct lemon *lemp, char *suffix)
PRIVATE FILE * file_open (struct lemon *lemp, char *suffix, char *mode)
void Reprint (struct lemon *lemp)
void ConfigPrint (FILE *fp, struct config *cfp)
int PrintAction (struct action *ap, FILE *fp, int indent)
void ReportOutput (struct lemon *lemp)
PRIVATE char * pathsearch (char *argv0, char *name, int modemask)
PRIVATE int compute_action (struct lemon *lemp, struct action *ap)
PRIVATE void tplt_xfer (char *name, FILE *in, FILE *out, int *lineno)
PRIVATE FILE * tplt_open (struct lemon *lemp)
PRIVATE void tplt_linedir (FILE *out, int lineno, char *filename)
PRIVATE void tplt_print (FILE *out, struct lemon *lemp, char *str, int strln, int *lineno)
void emit_destructor_code (FILE *out, struct symbol *sp, struct lemon *lemp, int *lineno)
int has_destructor (struct symbol *sp, struct lemon *lemp)
PRIVATE char * append_str (char *zText, int n, int p1, int p2)
PRIVATE void translate_code (struct lemon *lemp, struct rule *rp)
PRIVATE void emit_code (FILE *out, struct rule *rp, struct lemon *lemp, int *lineno)
void print_stack_union (FILE *out, struct lemon *lemp, int *plineno, int mhflag)
static const char * minimum_size_type (int lwr, int upr)
static int axset_compare (const void *a, const void *b)
void ReportTable (struct lemon *lemp, int mhflag)
void ReportHeader (struct lemon *lemp)
void CompressTables (struct lemon *lemp)
void SetSize (int n)
void SetFree (char *s)
int SetAdd (char *s, int e)
int SetUnion (char *s1, char *s2)
PRIVATE int strhash (char *x)
char * Strsafe (char *y)
int Strsafe_insert (char *data)
char * Strsafe_find (char *key)
symbolSymbol_new (char *x)
int Symbol_insert (struct symbol *data, char *key)
symbolSymbol_find (char *key)
symbolSymbol_Nth (int n)
int Configcmp (struct config *a, struct config *b)
PRIVATE int statecmp (struct config *a, struct config *b)
PRIVATE int statehash (struct config *a)
int State_insert (struct state *data, struct config *key)
stateState_find (struct config *key)
PRIVATE int confighash (struct config *a)
int Configtable_insert (struct config *data)
configConfigtable_find (struct config *key)
void Configtable_clear (int(*f)())

Variables

static struct configfreelist = 0
static struct configcurrent = 0
static struct config ** currentend = 0
static struct configbasis = 0
static struct config ** basisend = 0
static int nDefine = 0
static char ** azDefine = 0
static char * output_filename = 0
static char * output_header_filename = 0
static char ** argv
static struct s_optionsop
static FILE * errstream
static char emsg [] = "Command line syntax error: "
static struct plinkplink_freelist = 0
static int size = 0
static struct s_x1x1a
static struct s_x2x2a
static struct s_x3x3a
static struct s_x4x4a


Define Documentation

#define PRIVATE

Definition at line 29 of file lemon.c.

#define MAXRHS   1000

Definition at line 34 of file lemon.c.

Referenced by parseonetoken(), and translate_code().

#define assert (  )     if(!(X))myassert(__FILE__,__LINE__)

Definition at line 47 of file lemon.c.

Referenced by actioncmp(), acttab_insert(), append_str(), Configlist_add(), Configlist_addbasis(), Configlist_closure(), Configlist_eat(), emit_destructor_code(), Reprint(), and resolve_conflict().

#define SetFind ( X,
 )     (X[Y])

Definition at line 115 of file lemon.c.

Referenced by FindActions().

#define NO_OFFSET   (-2147483647)

Definition at line 224 of file lemon.c.

Referenced by ReportTable().

#define MemoryCheck (  ) 

Value:

if((X)==0){ \
  extern void memory_error(); \
  memory_error(); \
}

Definition at line 280 of file lemon.c.

Referenced by getstate(), State_new(), Strsafe(), and Symbol_new().

#define acttab_size (  )     ((X)->nAction)

Definition at line 427 of file lemon.c.

#define acttab_yyaction ( X,
 )     ((X)->aAction[N].action)

Definition at line 430 of file lemon.c.

#define acttab_yylookahead ( X,
 )     ((X)->aAction[N].lookahead)

Definition at line 433 of file lemon.c.

#define ERRMSGSIZE   10000

Definition at line 1271 of file lemon.c.

Referenced by ErrorMsg().

#define LINEWIDTH   79

Definition at line 1272 of file lemon.c.

Referenced by ErrorMsg().

#define PREFIXLIMIT   60

Definition at line 1273 of file lemon.c.

Referenced by ErrorMsg().

#define NEXT (  )     (*(char**)(((unsigned long)A)+offset))

Definition at line 1538 of file lemon.c.

Referenced by merge(), and msort().

#define LISTSIZE   30

Definition at line 1606 of file lemon.c.

Referenced by msort().

#define ISOPT (  )     ((X)[0]=='-'||(X)[0]=='+'||strchr((X),'=')!=0)

Definition at line 1637 of file lemon.c.

Referenced by argindex(), and OptNArgs().

#define LINESIZE   1000

Definition at line 2895 of file lemon.c.

Referenced by ReportHeader(), ReportTable(), and tplt_xfer().


Typedef Documentation

typedef struct acttab acttab

Definition at line 410 of file lemon.c.

typedef struct s_x1node x1node

typedef struct s_x2node x2node

typedef struct s_x3node x3node

typedef struct s_x4node x4node


Enumeration Type Documentation

enum Boolean

Enumerator:
B_FALSE 
B_TRUE 

Definition at line 122 of file lemon.c.


Function Documentation

char* msort (  ) 

Referenced by Action_sort(), Configlist_sort(), and Configlist_sortbasis().

struct action * Action_new (  )  [read]

Definition at line 338 of file lemon.c.

References freelist, config::next, and action::next.

Referenced by Action_add().

struct action* Action_sort (  )  [read]

void myassert (  ) 

void FindRulePrecedences (  ) 

Referenced by main().

void FindFirstSets (  ) 

Referenced by main().

void FindStates (  ) 

Referenced by main().

void FindLinks (  ) 

Referenced by main().

void FindFollowSets (  ) 

Referenced by main().

void FindActions (  ) 

Referenced by main().

void Configlist_init (  ) 

Definition at line 1074 of file lemon.c.

References basis, basisend, Configtable_init(), current, and currentend.

Referenced by FindStates().

struct config* Configlist_add (  )  [read]

Referenced by Configlist_closure().

struct config* Configlist_addbasis (  )  [read]

Referenced by buildshifts().

void Configlist_closure (  ) 

Referenced by getstate().

void Configlist_sort (  ) 

Definition at line 1191 of file lemon.c.

References Configcmp(), current, currentend, and msort().

Referenced by getstate().

void Configlist_sortbasis (  ) 

Definition at line 1199 of file lemon.c.

References basis, basisend, Configcmp(), current, and msort().

Referenced by getstate().

struct config * Configlist_return (  )  [read]

Definition at line 1208 of file lemon.c.

References current, and currentend.

Referenced by getstate().

struct config * Configlist_basis (  )  [read]

Definition at line 1218 of file lemon.c.

References basis, and basisend.

Referenced by getstate().

void Configlist_eat (  ) 

Referenced by getstate().

void Configlist_reset (  ) 

Definition at line 1084 of file lemon.c.

References basis, basisend, Configtable_clear(), current, and currentend.

Referenced by buildshifts().

void ErrorMsg ( const char *  ,
int  ,
const char *  ,
  ... 
)

Definition at line 1274 of file lemon.c.

References ERRMSGSIZE, findbreak(), LINEWIDTH, and PREFIXLIMIT.

Referenced by Configlist_closure(), FindStates(), Parse(), parseonetoken(), and ReportTable().

int OptInit (  ) 

Referenced by main().

int OptNArgs (  ) 

Definition at line 1841 of file lemon.c.

References ISOPT.

Referenced by main().

char* OptArg (  ) 

Referenced by main().

void OptErr (  ) 

void OptPrint (  ) 

Definition at line 1870 of file lemon.c.

References s_options::label, s_options::message, op, s_options::OPT_DBL, s_options::OPT_FDBL, s_options::OPT_FFLAG, s_options::OPT_FINT, s_options::OPT_FLAG, s_options::OPT_FSTR, s_options::OPT_INT, s_options::OPT_STR, and s_options::type.

Referenced by OptInit().

void Parse (  ) 

Referenced by main().

struct plink * Plink_new (  )  [read]

Definition at line 2554 of file lemon.c.

References plink::next, and plink_freelist.

Referenced by Plink_add().

void Plink_add (  ) 

Referenced by buildshifts().

void Plink_copy (  ) 

Referenced by getstate().

void Plink_delete (  ) 

Referenced by getstate().

void Reprint (  ) 

Referenced by main().

void ReportOutput (  ) 

Referenced by main().

void ReportTable (  ) 

Referenced by main().

void ReportHeader (  ) 

Referenced by main().

void CompressTables (  ) 

Referenced by main().

void SetSize (  ) 

Referenced by main().

char * SetNew (  ) 

Definition at line 3931 of file lemon.c.

References memory_error().

Referenced by Configlist_add(), Configlist_addbasis(), and FindFirstSets().

void SetFree (  ) 

Referenced by Configlist_eat().

int SetAdd (  ) 

Referenced by Configlist_closure().

int SetUnion (  ) 

Referenced by Configlist_closure().

char* Strsafe (  ) 

Referenced by parseonetoken(), and Symbol_new().

void Strsafe_init (  ) 

Definition at line 4042 of file lemon.c.

References s_x1::count, s_x1::ht, s_x1::size, s_x1::tbl, and x1a.

Referenced by main().

int Strsafe_insert (  ) 

Referenced by Strsafe().

char* Strsafe_find (  ) 

Referenced by Strsafe().

struct symbol* Symbol_new (  )  [read]

Referenced by main(), and parseonetoken().

int Symbolcmpp ( const void *  void_a,
const void *  void_b 
)

Definition at line 4172 of file lemon.c.

References symbol::index, and symbol::name.

Referenced by main().

void Symbol_init (  ) 

Definition at line 4206 of file lemon.c.

References s_x2::count, s_x2::ht, s_x2::size, s_x2::tbl, and x2a.

Referenced by main().

int Symbol_insert (  ) 

Referenced by Symbol_new().

struct symbol* Symbol_find (  )  [read]

Referenced by FindStates(), and Symbol_new().

struct symbol* Symbol_Nth (  )  [read]

int Symbol_count (  ) 

Definition at line 4316 of file lemon.c.

References s_x2::count, and x2a.

Referenced by main().

struct symbol ** Symbol_arrayof (  )  [read]

Definition at line 4324 of file lemon.c.

References s_x2::count, s_x2node::data, s_x2::tbl, and x2a.

Referenced by main().

int Configcmp (  ) 

Referenced by Configlist_sort(), Configlist_sortbasis(), Configtable_find(), and Configtable_insert().

struct state * State_new (  )  [read]

Definition at line 4378 of file lemon.c.

References MemoryCheck.

Referenced by getstate().

void State_init (  ) 

Definition at line 4412 of file lemon.c.

References s_x3::count, s_x3::ht, s_x3::size, s_x3::tbl, and x3a.

Referenced by main().

int State_insert (  ) 

Referenced by getstate().

struct state* State_find (  )  [read]

Referenced by getstate().

struct state ** State_arrayof (  )  [read]

Definition at line 4511 of file lemon.c.

References s_x3::count, s_x3node::data, s_x3::tbl, and x3a.

Referenced by main().

void Configtable_init (  ) 

Definition at line 4558 of file lemon.c.

References s_x4::count, s_x4::ht, s_x4::size, s_x4::tbl, and x4a.

Referenced by Configlist_init().

int Configtable_insert (  ) 

Referenced by Configlist_add(), and Configlist_addbasis().

struct config* Configtable_find (  )  [read]

Referenced by Configlist_add(), and Configlist_addbasis().

void Configtable_clear (  ) 

Referenced by Configlist_reset().

static int actioncmp ( struct action ap1,
struct action ap2 
) [static]

Definition at line 359 of file lemon.c.

References assert, action::CONFLICT, rule::index, symbol::index, action::RD_RESOLVED, action::REDUCE, action::rp, action::sp, action::type, and action::x.

Referenced by Action_sort().

struct action* Action_sort ( struct action ap  )  [read]

Definition at line 375 of file lemon.c.

References actioncmp(), and msort().

void Action_add ( struct action **  app,
enum e_action  type,
struct symbol sp,
char *  arg 
)

Definition at line 383 of file lemon.c.

References Action_new(), action::SHIFT, and action::sp.

Referenced by buildshifts(), and FindActions().

void acttab_free ( acttab p  ) 

Definition at line 436 of file lemon.c.

References acttab::aAction, and acttab::aLookahead.

acttab* acttab_alloc ( void   ) 

Definition at line 443 of file lemon.c.

void acttab_action ( acttab p,
int  lookahead,
int  action 
)

Definition at line 455 of file lemon.c.

References acttab::action, acttab::aLookahead, acttab::lookahead, acttab::mnAction, acttab::mnLookahead, acttab::mxLookahead, acttab::nLookahead, and acttab::nLookaheadAlloc.

int acttab_insert ( acttab p  ) 

Definition at line 488 of file lemon.c.

References acttab::aAction, acttab::action, acttab::aLookahead, assert, acttab::lookahead, acttab::mnLookahead, acttab::mxLookahead, acttab::nAction, acttab::nActionAlloc, and acttab::nLookahead.

void myassert ( char *  file,
int  line 
)

Definition at line 569 of file lemon.c.

void FindRulePrecedences ( struct lemon xp  ) 

Definition at line 591 of file lemon.c.

References rule::next, rule::nrhs, symbol::prec, rule::precsym, and rule::rhs.

void FindFirstSets ( struct lemon lemp  ) 

Definition at line 614 of file lemon.c.

References B_FALSE, and SetNew().

PRIVATE struct state* getstate (  )  [read]

Referenced by buildshifts().

void FindStates ( struct lemon lemp  ) 

Definition at line 671 of file lemon.c.

References Configlist_init(), ErrorMsg(), rule::lhs, symbol::name, rule::next, rule::nrhs, rule::rhs, symbol::rule, and Symbol_find().

PRIVATE void buildshifts (  ) 

Referenced by getstate().

PRIVATE struct state* getstate ( struct lemon lemp  )  [read]

Definition at line 730 of file lemon.c.

References state::ap, state::bp, config::bp, config::bplp, buildshifts(), state::cfp, Configlist_basis(), Configlist_closure(), Configlist_eat(), Configlist_return(), Configlist_sort(), Configlist_sortbasis(), config::fplp, state::index, MemoryCheck, Plink_copy(), Plink_delete(), State_find(), State_insert(), State_new(), and config::stp.

PRIVATE void buildshifts ( struct lemon lemp,
struct state stp 
)

Definition at line 775 of file lemon.c.

References Action_add(), state::ap, state::cfp, Configlist_addbasis(), Configlist_reset(), config::dot, getstate(), config::next, rule::nrhs, Plink_add(), rule::rhs, config::rp, and config::status.

void FindLinks ( struct lemon lemp  ) 

Definition at line 823 of file lemon.c.

References state::cfp, plink::cfp, config::next, and config::stp.

void FindFollowSets ( struct lemon lemp  ) 

Definition at line 859 of file lemon.c.

References plink::cfp, config::next, and config::status.

static int resolve_conflict (  )  [static]

void FindActions ( struct lemon lemp  ) 

Definition at line 896 of file lemon.c.

References Action_add(), state::ap, state::cfp, config::dot, config::fws, config::next, rule::nrhs, config::rp, and SetFind.

static int resolve_conflict ( struct action apx,
struct action apy 
) [static]

Definition at line 980 of file lemon.c.

References assert, symbol::assoc, symbol::LEFT, symbol::NONE, symbol::prec, rule::precsym, symbol::RIGHT, action::rp, action::sp, action::type, and action::x.

PRIVATE struct config* newconfig (  )  [read]

Definition at line 1047 of file lemon.c.

References freelist, and config::next.

Referenced by Configlist_add(), and Configlist_addbasis().

PRIVATE void deleteconfig ( struct config old  ) 

Definition at line 1066 of file lemon.c.

References freelist.

Referenced by Configlist_eat().

struct config* Configlist_add ( struct rule rp,
int  dot 
) [read]

Definition at line 1094 of file lemon.c.

References assert, config::bp, config::bplp, Configtable_find(), Configtable_insert(), currentend, config::dot, config::fplp, config::fws, newconfig(), config::next, config::rp, SetNew(), and config::stp.

struct config* Configlist_addbasis ( struct rule rp,
int  dot 
) [read]

Definition at line 1121 of file lemon.c.

References assert, basisend, config::bp, config::bplp, Configtable_find(), Configtable_insert(), currentend, config::dot, config::fplp, config::fws, newconfig(), config::next, config::rp, SetNew(), and config::stp.

void Configlist_closure ( struct lemon lemp  ) 

Definition at line 1151 of file lemon.c.

References assert, B_FALSE, Configlist_add(), current, currentend, config::dot, ErrorMsg(), symbol::firstset, config::fws, symbol::index, symbol::lambda, rule::line, symbol::name, config::next, rule::nextlhs, symbol::NONTERMINAL, rule::nrhs, rule::rhs, config::rp, symbol::rule, SetAdd(), SetUnion(), symbol::TERMINAL, and symbol::type.

void Configlist_eat ( struct config cfp  ) 

Definition at line 1227 of file lemon.c.

References assert, deleteconfig(), config::next, and SetFree().

static int findbreak ( char *  msg,
int  min,
int  max 
) [static]

Definition at line 1248 of file lemon.c.

Referenced by ErrorMsg().

void memory_error (  ) 

Definition at line 1320 of file lemon.c.

Referenced by SetNew().

static void handle_D_option ( char *  z  )  [static]

Definition at line 1331 of file lemon.c.

Referenced by main().

static void handle_o_option ( char *  z  )  [static]

Definition at line 1354 of file lemon.c.

Referenced by main().

static void handle_h_option ( char *  z  )  [static]

Definition at line 1367 of file lemon.c.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Definition at line 1378 of file lemon.c.

References lemon::accept, lemon::arg, lemon::argv0, lemon::basisflag, CompressTables(), lemon::error, lemon::errorcnt, lemon::errsym, lemon::extracode, lemon::failure, lemon::filename, FindActions(), FindFirstSets(), FindFollowSets(), FindLinks(), FindRulePrecedences(), FindStates(), handle_D_option(), handle_h_option(), handle_o_option(), lemon::has_fallback, lemon::include, symbol::index, symbol::name, lemon::name, lemon::nconflict, lemon::nsymbol, lemon::nterminal, s_options::OPT_FLAG, s_options::OPT_FSTR, OptArg(), OptInit(), OptNArgs(), lemon::outname, lemon::overflow, Parse(), ReportHeader(), ReportOutput(), ReportTable(), Reprint(), lemon::rule, SetSize(), lemon::stacksize, lemon::start, State_arrayof(), State_init(), Strsafe_init(), Symbol_arrayof(), Symbol_count(), Symbol_init(), Symbol_new(), Symbolcmpp(), lemon::symbols, lemon::tablesize, lemon::tokendest, lemon::tokenprefix, lemon::tokentype, lemon::vardest, and lemon::vartype.

static char* merge ( char *  a,
char *  b,
int (*)()  cmp,
int  offset 
) [static]

Definition at line 1555 of file lemon.c.

References NEXT.

Referenced by msort().

char* msort ( char *  list,
char **  next,
int (*)()  cmp 
)

Definition at line 1607 of file lemon.c.

References LISTSIZE, merge(), and NEXT.

static void errline ( int  n,
int  k,
FILE *  err 
) [static]

Definition at line 1643 of file lemon.c.

Referenced by handleflags(), handleswitch(), and OptErr().

static int argindex ( int  n  )  [static]

Definition at line 1669 of file lemon.c.

References ISOPT.

Referenced by OptArg(), and OptErr().

static int handleflags ( int  i,
FILE *  err 
) [static]

Definition at line 1691 of file lemon.c.

References s_options::arg, errline(), s_options::func, s_options::label, op, s_options::OPT_FFLAG, s_options::OPT_FLAG, s_options::OPT_FSTR, and s_options::type.

Referenced by OptInit().

static int handleswitch ( int  i,
FILE *  err 
) [static]

Definition at line 1727 of file lemon.c.

References s_options::arg, errline(), s_options::func, s_options::label, op, s_options::OPT_DBL, s_options::OPT_FDBL, s_options::OPT_FFLAG, s_options::OPT_FINT, s_options::OPT_FLAG, s_options::OPT_FSTR, s_options::OPT_INT, s_options::OPT_STR, and s_options::type.

Referenced by OptInit().

int OptInit ( char **  a,
struct s_options o,
FILE *  err 
)

Definition at line 1814 of file lemon.c.

References handleflags(), handleswitch(), op, and OptPrint().

char* OptArg ( int  n  ) 

Definition at line 1854 of file lemon.c.

References argindex().

void OptErr ( int  n  ) 

Definition at line 1862 of file lemon.c.

References argindex(), and errline().

static void parseonetoken ( struct pstate psp  )  [static]

Definition at line 1969 of file lemon.c.

References rule::code, ErrorMsg(), rule::index, rule::lhs, rule::lhsalias, MAXRHS, rule::next, rule::nextlhs, rule::nrhs, rule::precsym, rule::rhs, rule::rhsalias, symbol::rule, rule::ruleline, Strsafe(), and Symbol_new().

Referenced by Parse().

static void preprocess_input ( char *  z  )  [static]

Definition at line 2348 of file lemon.c.

Referenced by Parse().

void Parse ( struct lemon gp  ) 

Definition at line 2399 of file lemon.c.

References pstate::errorcnt, ErrorMsg(), pstate::filename, pstate::firstrule, pstate::gp, pstate::INITIALIZE, parseonetoken(), preprocess_input(), pstate::state, pstate::tokenlineno, and pstate::tokenstart.

void Plink_add ( struct plink **  plpp,
struct config cfp 
)

Definition at line 2575 of file lemon.c.

References plink::cfp, and Plink_new().

void Plink_copy ( struct plink **  to,
struct plink from 
)

Definition at line 2587 of file lemon.c.

References plink::next.

void Plink_delete ( struct plink plp  ) 

Definition at line 2601 of file lemon.c.

References plink::next, and plink_freelist.

PRIVATE char* file_makename ( struct lemon lemp,
char *  suffix 
)

Definition at line 2622 of file lemon.c.

Referenced by file_open(), and ReportTable().

PRIVATE FILE* file_open ( struct lemon lemp,
char *  suffix,
char *  mode 
)

Definition at line 2643 of file lemon.c.

References file_makename().

Referenced by ReportHeader(), ReportOutput(), and ReportTable().

void Reprint ( struct lemon lemp  ) 

Definition at line 2663 of file lemon.c.

References assert, symbol::index, rule::lhs, symbol::name, rule::next, rule::nrhs, rule::precsym, and rule::rhs.

void ConfigPrint ( FILE *  fp,
struct config cfp 
)

Definition at line 2703 of file lemon.c.

References config::dot, rule::lhs, symbol::name, rule::nrhs, rule::rhs, and config::rp.

Referenced by ReportOutput().

int PrintAction ( struct action ap,
FILE *  fp,
int  indent 
)

Definition at line 2757 of file lemon.c.

References ERROR, rule::index, state::index, symbol::name, action::rp, action::sp, action::stp, action::type, and action::x.

void ReportOutput ( struct lemon lemp  ) 

Definition at line 2786 of file lemon.c.

References config::bp, state::bp, config::bplp, state::cfp, ConfigPrint(), file_open(), config::fplp, config::fws, state::index, config::next, and action::stp.

PRIVATE char* pathsearch ( char *  argv0,
char *  name,
int  modemask 
)

Definition at line 2833 of file lemon.c.

Referenced by tplt_open().

PRIVATE int compute_action ( struct lemon lemp,
struct action ap 
)

Definition at line 2880 of file lemon.c.

References action::ACCEPT, ERROR, rule::index, state::index, action::REDUCE, action::rp, action::SHIFT, action::stp, action::type, and action::x.

Referenced by ReportTable().

PRIVATE void tplt_xfer ( char *  name,
FILE *  in,
FILE *  out,
int *  lineno 
)

Definition at line 2905 of file lemon.c.

References LINESIZE.

Referenced by ReportTable().

PRIVATE FILE* tplt_open ( struct lemon lemp  ) 

Definition at line 2934 of file lemon.c.

References pathsearch().

Referenced by ReportTable().

PRIVATE void tplt_linedir ( FILE *  out,
int  lineno,
char *  filename 
)

Definition at line 2972 of file lemon.c.

Referenced by emit_code(), emit_destructor_code(), and tplt_print().

PRIVATE void tplt_print ( FILE *  out,
struct lemon lemp,
char *  str,
int  strln,
int *  lineno 
)

Definition at line 2987 of file lemon.c.

References lemon::filename, lemon::outname, and tplt_linedir().

Referenced by ReportTable().

void emit_destructor_code ( FILE *  out,
struct symbol sp,
struct lemon lemp,
int *  lineno 
)

Definition at line 3015 of file lemon.c.

References assert, symbol::destructor, symbol::destructorln, symbol::dtnum, lemon::filename, lemon::outname, action::sp, lemon::tokendest, lemon::tokendestln, tplt_linedir(), symbol::type, lemon::vardest, and lemon::vardestln.

int has_destructor ( struct symbol sp,
struct lemon lemp 
)

Definition at line 3059 of file lemon.c.

References lemon::tokendest, and lemon::vardest.

PRIVATE char* append_str ( char *  zText,
int  n,
int  p1,
int  p2 
)

Definition at line 3084 of file lemon.c.

References assert.

Referenced by translate_code().

PRIVATE void translate_code ( struct lemon lemp,
struct rule rp 
)

Definition at line 3129 of file lemon.c.

References append_str(), rule::code, symbol::dtnum, rule::lhs, rule::lhsalias, MAXRHS, rule::nrhs, rule::rhs, rule::rhsalias, and action::rp.

PRIVATE void emit_code ( FILE *  out,
struct rule rp,
struct lemon lemp,
int *  lineno 
)

Definition at line 3204 of file lemon.c.

References rule::code, lemon::filename, rule::line, lemon::outname, action::rp, and tplt_linedir().

void print_stack_union ( FILE *  out,
struct lemon lemp,
int *  plineno,
int  mhflag 
)

Definition at line 3235 of file lemon.c.

References lemon::nsymbol, and lemon::vartype.

Referenced by ReportTable().

static const char* minimum_size_type ( int  lwr,
int  upr 
) [static]

Definition at line 3344 of file lemon.c.

Referenced by ReportTable().

static int axset_compare ( const void *  a,
const void *  b 
) [static]

Definition at line 3377 of file lemon.c.

References axset::nAction.

void ReportTable ( struct lemon lemp,
int  mhflag 
)

Definition at line 3384 of file lemon.c.

References state::ap, atoi(), compute_action(), ErrorMsg(), file_makename(), file_open(), state::iDflt, symbol::index, state::iNtOfst, state::iTknOfst, LINESIZE, minimum_size_type(), action::next, state::nNtAct, NO_OFFSET, state::nTknAct, print_stack_union(), action::sp, axset::stp, tplt_open(), tplt_print(), and tplt_xfer().

void ReportHeader ( struct lemon lemp  ) 

Definition at line 3810 of file lemon.c.

References file_open(), rule::line, and LINESIZE.

void CompressTables ( struct lemon lemp  ) 

Definition at line 3867 of file lemon.c.

References state::ap, action::next, action::rp, action::type, and action::x.

void SetSize ( int  n  ) 

Definition at line 3924 of file lemon.c.

void SetFree ( char *  s  ) 

Definition at line 3944 of file lemon.c.

int SetAdd ( char *  s,
int  e 
)

Definition at line 3952 of file lemon.c.

int SetUnion ( char *  s1,
char *  s2 
)

Definition at line 3963 of file lemon.c.

PRIVATE int strhash ( char *  x  ) 

Definition at line 3991 of file lemon.c.

Referenced by Strsafe_find(), Strsafe_insert(), Symbol_find(), and Symbol_insert().

char* Strsafe ( char *  y  ) 

Definition at line 4003 of file lemon.c.

References MemoryCheck, Strsafe_find(), and Strsafe_insert().

int Strsafe_insert ( char *  data  ) 

Definition at line 4062 of file lemon.c.

References s_x1::count, s_x1node::data, s_x1node::from, s_x1::ht, s_x1node::next, s_x1::size, strhash(), s_x1::tbl, and x1a.

char* Strsafe_find ( char *  key  ) 

Definition at line 4119 of file lemon.c.

References s_x1node::data, s_x1::ht, s_x1node::next, s_x1::size, strhash(), and x1a.

struct symbol* Symbol_new ( char *  x  )  [read]

Definition at line 4138 of file lemon.c.

References symbol::assoc, B_FALSE, symbol::datatype, symbol::destructor, symbol::fallback, symbol::firstset, symbol::lambda, MemoryCheck, symbol::name, symbol::NONTERMINAL, symbol::prec, symbol::rule, Strsafe(), Symbol_find(), Symbol_insert(), symbol::TERMINAL, symbol::type, and symbol::UNK.

int Symbol_insert ( struct symbol data,
char *  key 
)

Definition at line 4226 of file lemon.c.

References s_x2::count, s_x2node::data, s_x2node::from, s_x2::ht, s_x2node::key, s_x2node::next, s_x2::size, strhash(), s_x2::tbl, and x2a.

struct symbol* Symbol_find ( char *  key  )  [read]

Definition at line 4286 of file lemon.c.

References s_x2node::data, s_x2::ht, s_x2node::key, s_x2node::next, s_x2::size, strhash(), and x2a.

struct symbol* Symbol_Nth ( int  n  )  [read]

Definition at line 4303 of file lemon.c.

References s_x2node::data, s_x2::tbl, and x2a.

int Configcmp ( struct config a,
struct config b 
)

Definition at line 4338 of file lemon.c.

References config::dot, rule::index, and config::rp.

PRIVATE int statecmp ( struct config a,
struct config b 
)

Definition at line 4349 of file lemon.c.

References config::bp.

Referenced by State_find(), and State_insert().

PRIVATE int statehash ( struct config a  ) 

Definition at line 4366 of file lemon.c.

Referenced by State_find(), and State_insert().

int State_insert ( struct state data,
struct config key 
)

Definition at line 4432 of file lemon.c.

References s_x3::count, s_x3node::data, s_x3node::from, s_x3::ht, s_x3node::key, s_x3node::next, s_x3::size, statecmp(), statehash(), s_x3::tbl, and x3a.

struct state* State_find ( struct config key  )  [read]

Definition at line 4492 of file lemon.c.

References s_x3node::data, s_x3::ht, s_x3node::key, s_x3node::next, s_x3::size, statecmp(), statehash(), and x3a.

PRIVATE int confighash ( struct config a  ) 

Definition at line 4525 of file lemon.c.

Referenced by Configtable_find(), and Configtable_insert().

int Configtable_insert ( struct config data  ) 

Definition at line 4578 of file lemon.c.

References Configcmp(), confighash(), s_x4::count, s_x4node::data, s_x4node::from, s_x4::ht, s_x4node::next, s_x4::size, s_x4::tbl, and x4a.

struct config* Configtable_find ( struct config key  )  [read]

Definition at line 4635 of file lemon.c.

References Configcmp(), confighash(), s_x4node::data, s_x4::ht, s_x4node::next, s_x4::size, and x4a.

void Configtable_clear ( int(*)()  f  ) 

Definition at line 4653 of file lemon.c.

References s_x4::count, s_x4node::data, s_x4::ht, s_x4::tbl, and x4a.


Variable Documentation

struct config* freelist = 0 [static]

Definition at line 1040 of file lemon.c.

Referenced by Action_new(), deleteconfig(), and newconfig().

struct config* current = 0 [static]

Definition at line 1041 of file lemon.c.

Referenced by Configlist_closure(), Configlist_init(), Configlist_reset(), Configlist_return(), Configlist_sort(), Configlist_sortbasis(), and FlintSpellingTable::merge_changes().

struct config** currentend = 0 [static]

Definition at line 1042 of file lemon.c.

Referenced by Configlist_add(), Configlist_addbasis(), Configlist_closure(), Configlist_init(), Configlist_reset(), Configlist_return(), and Configlist_sort().

struct config* basis = 0 [static]

Definition at line 1043 of file lemon.c.

Referenced by Configlist_basis(), Configlist_init(), Configlist_reset(), and Configlist_sortbasis().

struct config** basisend = 0 [static]

Definition at line 1044 of file lemon.c.

Referenced by Configlist_addbasis(), Configlist_basis(), Configlist_init(), Configlist_reset(), and Configlist_sortbasis().

int nDefine = 0 [static]

Definition at line 1325 of file lemon.c.

char** azDefine = 0 [static]

Definition at line 1326 of file lemon.c.

char* output_filename = 0 [static]

Definition at line 1350 of file lemon.c.

char* output_header_filename = 0 [static]

Definition at line 1363 of file lemon.c.

char** argv [static]

Definition at line 1633 of file lemon.c.

struct s_options* op [static]

Definition at line 1634 of file lemon.c.

Referenced by handleflags(), handleswitch(), OptInit(), and OptPrint().

FILE* errstream [static]

Definition at line 1635 of file lemon.c.

char emsg[] = "Command line syntax error: " [static]

Definition at line 1686 of file lemon.c.

struct plink* plink_freelist = 0 [static]

Definition at line 2551 of file lemon.c.

Referenced by Plink_delete(), and Plink_new().

int size = 0 [static]

Definition at line 3921 of file lemon.c.

Referenced by Xapian::WritableDatabase::add_document(), Xapian::WritableDatabase::add_spelling(), Xapian::WritableDatabase::add_synonym(), Xapian::Database::allterms_begin(), Xapian::WritableDatabase::begin_transaction(), Xapian::WritableDatabase::cancel_transaction(), Xapian::WritableDatabase::clear_synonyms(), Xapian::WritableDatabase::commit_transaction(), DEFINE_TESTCASE(), Xapian::WritableDatabase::delete_document(), Xapian::WritableDatabase::flush(), generate_grouping_table(), generate_substring(), Xapian::Database::get_avlength(), get_input(), make_among(), Xapian::ESet::max_size(), Xapian::MSet::max_size(), Btree::mid_point(), FlintTable::mid_point(), FlintVersion::read_and_check(), Xapian::WritableDatabase::remove_spelling(), Xapian::WritableDatabase::remove_synonym(), Xapian::WritableDatabase::replace_document(), QuartzTermListTable::set_entries(), and QuartzPositionListTable::set_positionlist().

struct s_x1* x1a [static]

Definition at line 4039 of file lemon.c.

Referenced by Strsafe_find(), Strsafe_init(), and Strsafe_insert().

struct s_x2* x2a [static]

Definition at line 4203 of file lemon.c.

Referenced by Symbol_arrayof(), Symbol_count(), Symbol_find(), Symbol_init(), Symbol_insert(), and Symbol_Nth().

struct s_x3* x3a [static]

Definition at line 4409 of file lemon.c.

Referenced by State_arrayof(), State_find(), State_init(), and State_insert().

struct s_x4* x4a [static]

Definition at line 4555 of file lemon.c.

Referenced by Configtable_clear(), Configtable_find(), Configtable_init(), and Configtable_insert().


Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.