lcgen.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
/*
* this must make it through vanilla cc with no -last
*
* # comment
* :charset:
* code name ms-codepage
* :language:
* code name alt1|alt2... charset|... attr1|attr2|...
* ...
* :territory:
* code name lang1|lang2...
* :abbreviation:
*/
#include <stdio.h>
#include <ctype.h>
#ifdef __STDC__
#include <stdlib.h>
#include <string.h>
#endif
typedef struct Link_s
{
char* code;
int index;
} Link_t;
typedef struct Table_s
{
int count;
} Table_t;
typedef struct Abbreviation_s
{
char* value;
typedef struct Attribute_s
{
} Attribute_t;
typedef struct Attribute_list_s
{
struct Attribute_list_s*next;
typedef struct Charset_s
{
char* alternates;
char* ms;
} Charset_t;
typedef struct Language_s
{
char* name;
char* alternates;
} Language_t;
typedef struct Language_list_s
{
struct Language_list_s* next;
typedef struct Territory_s
{
char* name;
int primary;
int index;
} Territory_t;
typedef struct Map_s
{
} Map_t;
static struct State_s
{
} state;
#define INIT 0
#define CHARSET 1
#define LANGUAGE 2
#define TERRITORY 3
#define MAP 4
#define elementsof(x) (sizeof(x)/sizeof(x[0]))
static Link_t*
#if defined(__STDC__) || defined(__cplusplus)
#else
register Link_t* v;
#endif
{
register Link_t* x;
register Link_t* p;
return x;
if (p)
p->next = v;
else
v->next = 0;
return v;
}
static Link_t*
#if defined(__STDC__) || defined(__cplusplus)
#else
register char* s;
#endif
{
register Link_t* x;
return x;
return 0;
}
static char*
#if defined(__STDC__) || defined(__cplusplus)
copy(char** p, register char* f)
#else
copy(p, f)
char** p;
register char* f;
#endif
{
register char* t;
char* b;
if (!f)
return 0;
b = t = *p;
while (*t++ = *f++);
*p = t;
return b;
}
static void
#if defined(__STDC__) || defined(__cplusplus)
#else
FILE* f;
char* p1;
char* p2;
char* p3;
#endif
{
register int c;
register char* s;
register char* b;
register char* e;
int i;
int m;
int n;
char* part[4];
char buf[128];
part[3] = 0;
n = 0;
fprintf(f, "\n");
do
{
i = m = 0;
b = buf;
while (b < e)
{
if (!(s = part[i++]))
break;
if (i > 1)
*b++ = '_';
while ((c = *s++) && b < e)
{
if (c == '|')
{
part[i-1] = s;
m = 1;
break;
}
else if (islower(c))
c = toupper(c);
else if (!isalnum(c))
c = '_';
*b++ = c;
}
}
*b = 0;
n++;
} while (m);
fprintf(f, "0,\n");
while (n-- > 0)
fprintf(f, "#endif\n");
}
#if defined(__STDC__) || defined(__cplusplus)
int
#else
int
int argc;
char** argv;
#endif
{
register char* s;
register char** vp;
register char** ve;
Language_t* lp;
char* b;
char* f;
char* command;
char* hdr;
char* lib;
int c;
int i;
int line;
int type;
char* arg[5];
char buf[1024];
line = 0;
{
return 1;
}
{
return 1;
}
{
return 1;
}
type = 0;
{
line++;
while (isspace(*s))
s++;
if (!*s || *s == '#')
continue;
b = s;
for (;;)
{
if (!*s)
break;
for (*s++ = 0; isspace(*s); s++);
*(vp - 1) = 0;
break;
}
*vp++ = 0;
if (*arg[0] == ':')
{
{
{
return 1;
}
continue;
}
{
{
return 1;
}
continue;
}
{
{
return 1;
}
continue;
}
{
{
return 1;
}
continue;
}
else
{
return 1;
}
}
if (!arg[1])
{
return 1;
}
switch (type)
{
case CHARSET:
{
return 1;
}
b = (char*)(cp + 1);
{
return 1;
}
break;
case TERRITORY:
{
return 1;
}
b = (char*)(tp + 1);
{
i = 0;
while (*(b = s))
{
for (; *s && *s != ':' && *s != '|'; s++);
if (c = *s)
*s++ = 0;
{
return 1;
}
{
return 1;
}
else
i++;
if (c == ':')
{
for (b = s; *s && *s != '|'; s++);
if (*s)
*s++ = 0;
if (!strcmp(b, "primary"))
}
}
if (territory_language_max < i)
}
{
return 1;
}
break;
case LANGUAGE:
{
return 1;
}
b = (char*)(lp + 1);
if (!arg[3])
{
return 1;
}
lp->attributes = 0;
{
i = 0;
while (*(b = s))
{
for (f = 0; *s && *s != '|'; s++)
if (*s == ':')
{
*s++ = 0;
f = s;
}
if (*s)
*s++ = 0;
if (f)
else
{
return 1;
}
{
return 1;
}
if (!lp->attributes)
else
}
if (language_attribute_max < i)
}
{
return 1;
}
break;
case MAP:
{
return 1;
}
b = (char*)(mp + 1);
if (!arg[2])
{
return 1;
}
{
return 1;
}
{
return 1;
}
if (!arg[3])
{
return 1;
}
if (arg[4])
{
{
break;
}
{
return 1;
}
}
{
return 1;
}
break;
}
}
if (!language_attribute_max)
if (!territory_language_max)
{
if (cp->alternates)
else
else
}
for (i = 0; i < language_attribute_max; i++)
for (i = 0; i < language_attribute_max; i++)
{
if (lp->alternates)
else
for (; i < language_attribute_max; i++)
}
{
else
for (; i < territory_language_max; i++)
for (; i < territory_language_max; i++)
}
{
else
}
return 0;
}