#include <stdio.h>#include <stdarg.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#include <assert.h>#include <unistd.h>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 | lemonStrlen(X) ((int)strlen(X)) |
| #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 30 |
| #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 struct acttab | acttab |
| typedef struct s_x1node | x1node |
| typedef struct s_x2node | x2node |
| typedef struct s_x3node | x3node |
| typedef struct s_x4node | x4node |
Enumerations | |
| enum | Boolean { LEMON_FALSE = 0, LEMON_TRUE } |
Functions | |
| static char * | msort (char *, char **, int(*)(const char *, const char *)) |
| static struct action * | Action_new (void) |
| static struct action * | Action_sort (struct action *) |
| void | FindRulePrecedences () |
| void | FindFirstSets () |
| void | FindStates () |
| void | FindLinks () |
| void | FindFollowSets () |
| void | FindActions () |
| void | Configlist_init () |
| struct config * | Configlist_add () |
| struct config * | Configlist_addbasis () |
| void | Configlist_closure () |
| void | Configlist_sort () |
| void | Configlist_sortbasis () |
| struct config * | Configlist_return () |
| struct config * | Configlist_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 () |
| struct plink * | Plink_new () |
| void | Plink_add () |
| void | Plink_copy () |
| void | Plink_delete () |
| void | Reprint () |
| void | ReportOutput () |
| void | ReportTable () |
| void | ReportHeader () |
| void | CompressTables () |
| void | ResortStates () |
| void | SetSize () |
| char * | SetNew () |
| void | SetFree () |
| int | SetAdd () |
| int | SetUnion () |
| char * | Strsafe () |
| void | Strsafe_init () |
| int | Strsafe_insert () |
| char * | Strsafe_find () |
| struct symbol * | Symbol_new () |
| int | Symbolcmpp () |
| void | Symbol_init () |
| int | Symbol_insert () |
| struct symbol * | Symbol_find () |
| struct symbol * | Symbol_Nth () |
| int | Symbol_count () |
| struct symbol ** | Symbol_arrayof () |
| int | Configcmp () |
| struct state * | State_new () |
| void | State_init () |
| int | State_insert () |
| struct state * | State_find () |
| struct state ** | State_arrayof () |
| void | Configtable_init () |
| int | Configtable_insert () |
| struct config * | Configtable_find () |
| void | Configtable_clear () |
| static int | actioncmp (struct action *ap1, struct action *ap2) |
| void | Action_add (struct action **app, enum e_action type, struct symbol *sp, char *arg) |
| void | acttab_free (acttab *p) |
| acttab * | acttab_alloc (void) |
| void | acttab_action (acttab *p, int lookahead, int action) |
| int | acttab_insert (acttab *p) |
| void | FindRulePrecedences (struct lemon *xp) |
| void | FindFirstSets (struct lemon *lemp) |
| PRIVATE struct state * | getstate () |
| void | FindStates (struct lemon *lemp) |
| PRIVATE void | buildshifts () |
| PRIVATE struct state * | getstate (struct lemon *lemp) |
| int | same_symbol (struct symbol *a, struct symbol *b) |
| 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, struct symbol *errsym) |
| PRIVATE struct config * | newconfig () |
| PRIVATE void | deleteconfig (struct config *old) |
| struct config * | Configlist_add (struct rule *rp, int dot) |
| struct config * | Configlist_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) |
| int | main (int argc, char **argv) |
| static char * | merge (char *a, char *b, int(*cmp)(const char *, const char *), int offset) |
| 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 *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) |
| static void | writeRuleText (FILE *out, struct rule *rp) |
| void | ReportTable (struct lemon *lemp, int mhflag) |
| void | ReportHeader (struct lemon *lemp) |
| void | CompressTables (struct lemon *lemp) |
| static int | stateResortCompare (const void *a, const void *b) |
| void | ResortStates (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) |
| struct symbol * | Symbol_new (char *x) |
| int | Symbolcmpp (struct symbol **a, struct symbol **b) |
| int | Symbol_insert (struct symbol *data, char *key) |
| struct symbol * | Symbol_find (char *key) |
| struct symbol * | Symbol_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) |
| struct state * | State_find (struct config *key) |
| PRIVATE int | confighash (struct config *a) |
| int | Configtable_insert (struct config *data) |
| struct config * | Configtable_find (struct config *key) |
| void | Configtable_clear (int(*f)()) |
Variables | |
| static struct config * | freelist = 0 |
| static struct config * | current = 0 |
| static struct config ** | currentend = 0 |
| static struct config * | basis = 0 |
| static struct config ** | basisend = 0 |
| static int | nDefine = 0 |
| static char ** | azDefine = 0 |
| static char ** | argv |
| static struct s_options * | op |
| static FILE * | errstream |
| static char | emsg [] = "Command line syntax error: " |
| static struct plink * | plink_freelist = 0 |
| static int | size = 0 |
| static struct s_x1 * | x1a |
| static struct s_x2 * | x2a |
| static struct s_x3 * | x3a |
| static struct s_x4 * | x4a |
| #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 ISOPT | ( | X | ) | ((X)[0]=='-'||(X)[0]=='+'||strchr((X),'=')!=0) |
| #define lemonStrlen | ( | X | ) | ((int)strlen(X)) |
| #define LINESIZE 1000 |
| #define LINEWIDTH 79 |
| #define LISTSIZE 30 |
| #define MAXRHS 1000 |
| #define MemoryCheck | ( | X | ) |
Value:
if((X)==0){ \ extern void memory_error(); \ memory_error(); \ }
| #define NEXT | ( | A | ) | (*(char**)(((unsigned long)A)+offset)) |
| #define NO_OFFSET (-2147483647) |
| #define PREFIXLIMIT 30 |
| #define PRIVATE |
| #define SetFind | ( | X, | |||
| Y | ) | (X[Y]) |
| enum Boolean |
| static struct action * Action_new | ( | void | ) | [static, read] |
| void acttab_action | ( | acttab * | p, | |
| int | lookahead, | |||
| int | action | |||
| ) |
| acttab* acttab_alloc | ( | void | ) |
| void acttab_free | ( | acttab * | p | ) |
| int acttab_insert | ( | acttab * | p | ) |
| PRIVATE char* append_str | ( | char * | zText, | |
| int | n, | |||
| int | p1, | |||
| int | p2 | |||
| ) |
| static int argindex | ( | int | n | ) | [static] |
| static int axset_compare | ( | const void * | a, | |
| const void * | b | |||
| ) | [static] |
| PRIVATE void buildshifts | ( | ) |
| void CompressTables | ( | struct lemon * | lemp | ) |
| void CompressTables | ( | ) |
| int Configcmp | ( | ) |
| PRIVATE int confighash | ( | struct config * | a | ) |
| struct config* Configlist_add | ( | ) | [read] |
| struct config* Configlist_addbasis | ( | ) | [read] |
| struct config * Configlist_basis | ( | ) | [read] |
| void Configlist_closure | ( | struct lemon * | lemp | ) |
| void Configlist_closure | ( | ) |
| void Configlist_eat | ( | struct config * | cfp | ) |
| void Configlist_eat | ( | ) |
| void Configlist_init | ( | ) |
| void Configlist_reset | ( | ) |
| struct config * Configlist_return | ( | ) | [read] |
| void Configlist_sort | ( | ) |
| void Configlist_sortbasis | ( | ) |
| void ConfigPrint | ( | FILE * | fp, | |
| struct config * | cfp | |||
| ) |
| void Configtable_clear | ( | int(*)() | f | ) |
| void Configtable_clear | ( | ) |
| struct config* Configtable_find | ( | ) | [read] |
| void Configtable_init | ( | ) |
| int Configtable_insert | ( | struct config * | data | ) |
| int Configtable_insert | ( | ) |
| PRIVATE void deleteconfig | ( | struct config * | old | ) |
| static void errline | ( | int | n, | |
| int | k, | |||
| FILE * | err | |||
| ) | [static] |
| void ErrorMsg | ( | const char * | filename, | |
| int | lineno, | |||
| const char * | format, | |||
| ... | ||||
| ) |
| PRIVATE char* file_makename | ( | struct lemon * | lemp, | |
| char * | suffix | |||
| ) |
| PRIVATE FILE* file_open | ( | struct lemon * | lemp, | |
| char * | suffix, | |||
| char * | mode | |||
| ) |
| void FindActions | ( | struct lemon * | lemp | ) |
| void FindActions | ( | ) |
| static int findbreak | ( | char * | msg, | |
| int | min, | |||
| int | max | |||
| ) | [static] |
| void FindFirstSets | ( | struct lemon * | lemp | ) |
| void FindFirstSets | ( | ) |
| void FindFollowSets | ( | struct lemon * | lemp | ) |
| void FindFollowSets | ( | ) |
| void FindLinks | ( | struct lemon * | lemp | ) |
| void FindLinks | ( | ) |
| void FindRulePrecedences | ( | struct lemon * | xp | ) |
| void FindRulePrecedences | ( | ) |
| void FindStates | ( | struct lemon * | lemp | ) |
| void FindStates | ( | ) |
| PRIVATE struct state* getstate | ( | ) | [read] |
| static void handle_D_option | ( | char * | z | ) | [static] |
| static int handleflags | ( | int | i, | |
| FILE * | err | |||
| ) | [static] |
| static int handleswitch | ( | int | i, | |
| FILE * | err | |||
| ) | [static] |
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
| void memory_error | ( | ) |
| static char* merge | ( | char * | a, | |
| char * | b, | |||
| int(*)(const char *, const char *) | cmp, | |||
| int | offset | |||
| ) | [static] |
| static const char* minimum_size_type | ( | int | lwr, | |
| int | upr | |||
| ) | [static] |
| static char * msort | ( | char * | list, | |
| char ** | next, | |||
| int(*)(const char *, const char *) | cmp | |||
| ) | [static] |
| PRIVATE struct config* newconfig | ( | ) | [read] |
| char* OptArg | ( | int | n | ) |
| char* OptArg | ( | ) |
| void OptErr | ( | int | n | ) |
| void OptErr | ( | ) |
| int OptInit | ( | char ** | a, | |
| struct s_options * | o, | |||
| FILE * | err | |||
| ) |
| int OptInit | ( | ) |
| int OptNArgs | ( | ) |
| void OptPrint | ( | ) |
| void Parse | ( | struct lemon * | gp | ) |
| void Parse | ( | ) |
| static void parseonetoken | ( | struct pstate * | psp | ) | [static] |
| PRIVATE char* pathsearch | ( | char * | argv0, | |
| char * | name, | |||
| int | modemask | |||
| ) |
| void Plink_add | ( | ) |
| void Plink_copy | ( | ) |
| void Plink_delete | ( | struct plink * | plp | ) |
| void Plink_delete | ( | ) |
| struct plink * Plink_new | ( | ) | [read] |
| static void preprocess_input | ( | char * | z | ) | [static] |
| void print_stack_union | ( | FILE * | out, | |
| struct lemon * | lemp, | |||
| int * | plineno, | |||
| int | mhflag | |||
| ) |
| int PrintAction | ( | struct action * | ap, | |
| FILE * | fp, | |||
| int | indent | |||
| ) |
| void ReportHeader | ( | struct lemon * | lemp | ) |
| void ReportHeader | ( | ) |
| void ReportOutput | ( | struct lemon * | lemp | ) |
| void ReportOutput | ( | ) |
| void ReportTable | ( | struct lemon * | lemp, | |
| int | mhflag | |||
| ) |
| void ReportTable | ( | ) |
| void Reprint | ( | struct lemon * | lemp | ) |
| void Reprint | ( | ) |
| static int resolve_conflict | ( | struct action * | apx, | |
| struct action * | apy, | |||
| struct symbol * | errsym | |||
| ) | [static] |
| static int resolve_conflict | ( | ) | [static] |
| void ResortStates | ( | struct lemon * | lemp | ) |
| void ResortStates | ( | ) |
| int SetAdd | ( | char * | s, | |
| int | e | |||
| ) |
| int SetAdd | ( | ) |
| void SetFree | ( | char * | s | ) |
| void SetFree | ( | ) |
| char * SetNew | ( | ) |
| void SetSize | ( | int | n | ) |
| void SetSize | ( | ) |
| int SetUnion | ( | char * | s1, | |
| char * | s2 | |||
| ) |
| int SetUnion | ( | ) |
| struct state ** State_arrayof | ( | ) | [read] |
| struct state* State_find | ( | ) | [read] |
| void State_init | ( | ) |
| int State_insert | ( | ) |
| struct state * State_new | ( | ) | [read] |
| PRIVATE int statehash | ( | struct config * | a | ) |
| static int stateResortCompare | ( | const void * | a, | |
| const void * | b | |||
| ) | [static] |
| PRIVATE int strhash | ( | char * | x | ) |
| char* Strsafe | ( | char * | y | ) |
| char* Strsafe | ( | ) |
| char* Strsafe_find | ( | char * | key | ) |
| char* Strsafe_find | ( | ) |
| void Strsafe_init | ( | ) |
| int Strsafe_insert | ( | char * | data | ) |
| int Strsafe_insert | ( | ) |
| struct symbol ** Symbol_arrayof | ( | ) | [read] |
| int Symbol_count | ( | ) |
| struct symbol* Symbol_find | ( | char * | key | ) | [read] |
| struct symbol* Symbol_find | ( | ) | [read] |
| void Symbol_init | ( | ) |
| int Symbol_insert | ( | struct symbol * | data, | |
| char * | key | |||
| ) |
| int Symbol_insert | ( | ) |
| struct symbol* Symbol_new | ( | char * | x | ) | [read] |
| struct symbol* Symbol_new | ( | ) | [read] |
| struct symbol* Symbol_Nth | ( | int | n | ) | [read] |
| struct symbol* Symbol_Nth | ( | ) | [read] |
| int Symbolcmpp | ( | ) |
| PRIVATE void tplt_linedir | ( | FILE * | out, | |
| int | lineno, | |||
| char * | filename | |||
| ) |
| PRIVATE FILE* tplt_open | ( | struct lemon * | lemp | ) |
| PRIVATE void tplt_print | ( | FILE * | out, | |
| struct lemon * | lemp, | |||
| char * | str, | |||
| int * | lineno | |||
| ) |
| PRIVATE void tplt_xfer | ( | char * | name, | |
| FILE * | in, | |||
| FILE * | out, | |||
| int * | lineno | |||
| ) |
| static void writeRuleText | ( | FILE * | out, | |
| struct rule * | rp | |||
| ) | [static] |
char** argv [static] |
char** azDefine = 0 [static] |
struct config** currentend = 0 [static] |
char emsg[] = "Command line syntax error: " [static] |
FILE* errstream [static] |
int nDefine = 0 [static] |
struct plink* plink_freelist = 0 [static] |
int size = 0 [static] |
1.5.4