示例#1
0
文件: asParse.c 项目: hjanime/bwtool
static void asParseColArraySpec(struct tokenizer *tkz, struct asObject *obj,
                                struct asColumn *col)
/* parse the array length specification for a column */
{
    if (col->lowType->type == t_simple)
        col->isArray = TRUE;
    else
        col->isList = TRUE;
    tokenizerMustHaveNext(tkz);
    if (isdigit(tkz->string[0]))
    {
        col->fixedSize = atoi(tkz->string);
        tokenizerMustHaveNext(tkz);
    }
    else if (isalpha(tkz->string[0]))
    {
#ifdef OLD
        if (obj->isSimple)
            tokenizerErrAbort(tkz, "simple objects can't include variable length arrays\n");
#endif /* OLD */
        col->linkedSizeName = cloneString(tkz->string);
        col->linkedSize = mustFindColumn(obj, col->linkedSizeName);
        col->linkedSize->isSizeLink = TRUE;
        tokenizerMustHaveNext(tkz);
    }
    else
        tokenizerErrAbort(tkz, "must have column name or integer inside []'s\n");
    tokenizerMustMatch(tkz, "]");
}
示例#2
0
文件: asParse.c 项目: hjanime/bwtool
static struct asObject *asParseTableDef(struct tokenizer *tkz)
/* Parse a table or object definintion */
{
    struct asObject *obj;
    AllocVar(obj);
    if (sameWord(tkz->string, "table"))
        obj->isTable = TRUE;
    else if (sameWord(tkz->string, "simple"))
        obj->isSimple = TRUE;
    else if (sameWord(tkz->string, "object"))
        ;
    else
        tokenizerErrAbort(tkz, "Expecting 'table' or 'object' got '%s'", tkz->string);
    tokenizerMustHaveNext(tkz);
    obj->name = cloneString(tkz->string);
    tokenizerMustHaveNext(tkz);
    obj->comment = cloneString(tkz->string);

    /* parse columns */
    tokenizerMustHaveNext(tkz);
    tokenizerMustMatch(tkz, "(");
    while (tkz->string[0] != ')')
        asParseColDef(tkz, obj);
    slReverse(&obj->columnList);
    return obj;
}
示例#3
0
文件: asParse.c 项目: hjanime/bwtool
static struct asTypeInfo *findLowType(struct tokenizer *tkz)
/* Return low type info.  Squawk and die if s doesn't
 * correspond to one. */
{
    struct asTypeInfo *type = asTypeFindLow(tkz->string);
    if (type == NULL)
        tokenizerErrAbort(tkz, "Unknown type '%s'", tkz->string);
    return type;
}
示例#4
0
void tokenizerMustMatch(struct tokenizer *tkz, char *string)
/* Require next token to match string.  Return next token
 * if it does, otherwise abort. */
{
if (sameWord(tkz->string, string))
    tokenizerMustHaveNext(tkz);
else
    tokenizerErrAbort(tkz, "Expecting %s got %s", string, tkz->string);
}
示例#5
0
文件: asParse.c 项目: hjanime/bwtool
static void asParseColSymSpec(struct tokenizer *tkz, struct asObject *obj,
                              struct asColumn *col)
/* parse the enum or set symbolic values for a column */
{
    tokenizerMustHaveNext(tkz);
    while (tkz->string[0] != ')')
    {
        slSafeAddHead(&col->values, slNameNew(tkz->string));
        /* look for `,' or `)', but allow `,' after last token */
        tokenizerMustHaveNext(tkz);
        if (!((tkz->string[0] == ',') || (tkz->string[0] == ')')))
            tokenizerErrAbort(tkz, "expected `,' or `)' got `%s'", tkz->string);
        if (tkz->string[0] != ')')
            tokenizerMustHaveNext(tkz);
    }
    tokenizerMustMatch(tkz, ")");
    slReverse(&col->values);
}
示例#6
0
文件: asParse.c 项目: hjanime/bwtool
static struct asObject *asParseTokens(struct tokenizer *tkz)
/* Parse file into a list of objects. */
{
    struct asObject *objList = NULL;
    struct asObject *obj;

    while (tokenizerNext(tkz))
    {
        obj = asParseTableDef(tkz);
        if (findObType(objList, obj->name))
            tokenizerErrAbort(tkz, "Duplicate definition of %s", obj->name);
        slAddTail(&objList, obj);
    }

    for (obj = objList; obj != NULL; obj = obj->next)
        asLinkEmbeddedObjects(obj, objList);

    return objList;
}