#include "common.h"#include "linefile.h"#include "tokenizer.h"#include "asParse.h"Include dependency graph for asParse.c:

Go to the source code of this file.
Functions | |
| static struct asTypeInfo * | findLowType (struct tokenizer *tkz) |
| static struct asColumn * | mustFindColumn (struct asObject *table, char *colName) |
| static struct asObject * | findObType (struct asObject *objList, char *obName) |
| static void | asParseColArraySpec (struct tokenizer *tkz, struct asObject *obj, struct asColumn *col) |
| static void | asParseColSymSpec (struct tokenizer *tkz, struct asObject *obj, struct asColumn *col) |
| static void | asParseColDef (struct tokenizer *tkz, struct asObject *obj) |
| static struct asObject * | asParseTableDef (struct tokenizer *tkz) |
| static void | asLinkEmbeddedObjects (struct asObject *obj, struct asObject *objList) |
| static struct asObject * | asParseTokens (struct tokenizer *tkz) |
| static struct asObject * | asParseLineFile (struct lineFile *lf) |
| asObject * | asParseFile (char *fileName) |
| asObject * | asParseText (char *text) |
Variables | |
| static char const | rcsid [] = "$Id: asParse.c,v 1.6 2007/02/11 21:43:15 kent Exp $" |
| asTypeInfo | asTypes [] |
Definition at line 182 of file asParse.c.
References asObject::columnList, errAbort(), findObType(), asObject::isSimple, asColumn::name, asObject::name, asColumn::next, asColumn::obName, and asColumn::obType.
Referenced by asParseTokens().
00184 { 00185 struct asColumn *col; 00186 for (col = obj->columnList; col != NULL; col = col->next) 00187 { 00188 if (col->obName != NULL) 00189 { 00190 if ((col->obType = findObType(objList, col->obName)) == NULL) 00191 errAbort("%s used but not defined", col->obName); 00192 if (obj->isSimple) 00193 { 00194 if (!col->obType->isSimple) 00195 errAbort("Simple object %s with embedded non-simple object %s", 00196 obj->name, col->name); 00197 } 00198 } 00199 } 00200 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void asParseColArraySpec | ( | struct tokenizer * | tkz, | |
| struct asObject * | obj, | |||
| struct asColumn * | col | |||
| ) | [static] |
Definition at line 76 of file asParse.c.
References cloneString(), asColumn::fixedSize, asColumn::isArray, asColumn::isList, asObject::isSimple, asColumn::isSizeLink, asColumn::linkedSize, asColumn::linkedSizeName, asColumn::lowType, mustFindColumn(), tokenizer::string, t_simple, tokenizerErrAbort(), tokenizerMustHaveNext(), tokenizerMustMatch(), TRUE, and asTypeInfo::type.
Referenced by asParseColDef().
00079 { 00080 if (col->lowType->type == t_simple) 00081 col->isArray = TRUE; 00082 else 00083 col->isList = TRUE; 00084 tokenizerMustHaveNext(tkz); 00085 if (isdigit(tkz->string[0])) 00086 { 00087 col->fixedSize = atoi(tkz->string); 00088 tokenizerMustHaveNext(tkz); 00089 } 00090 else if (isalpha(tkz->string[0])) 00091 { 00092 #ifdef OLD 00093 if (obj->isSimple) 00094 tokenizerErrAbort(tkz, "simple objects can't include variable length arrays\n"); 00095 #endif /* OLD */ 00096 col->linkedSizeName = cloneString(tkz->string); 00097 col->linkedSize = mustFindColumn(obj, col->linkedSizeName); 00098 col->linkedSize->isSizeLink = TRUE; 00099 tokenizerMustHaveNext(tkz); 00100 } 00101 else 00102 tokenizerErrAbort(tkz, "must have column name or integer inside []'s\n"); 00103 tokenizerMustMatch(tkz, "]"); 00104 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file asParse.c.
References AllocVar, asParseColArraySpec(), asParseColSymSpec(), cloneString(), asObject::columnList, asColumn::comment, FALSE, findLowType(), asColumn::fixedSize, asColumn::isList, asColumn::lowType, asColumn::name, asColumn::obName, slAddHead, tokenizer::string, t_char, t_object, t_simple, tokenizerMustHaveNext(), tokenizerMustMatch(), and asTypeInfo::type.
Referenced by asParseTableDef().
00127 { 00128 struct asColumn *col; 00129 AllocVar(col); 00130 00131 col->lowType = findLowType(tkz); 00132 tokenizerMustHaveNext(tkz); 00133 00134 if (col->lowType->type == t_object || col->lowType->type == t_simple) 00135 { 00136 col->obName = cloneString(tkz->string); 00137 tokenizerMustHaveNext(tkz); 00138 } 00139 00140 if (tkz->string[0] == '[') 00141 asParseColArraySpec(tkz, obj, col); 00142 else if (tkz->string[0] == '(') 00143 asParseColSymSpec(tkz, obj, col); 00144 00145 col->name = cloneString(tkz->string); 00146 tokenizerMustHaveNext(tkz); 00147 tokenizerMustMatch(tkz, ";"); 00148 col->comment = cloneString(tkz->string); 00149 tokenizerMustHaveNext(tkz); 00150 if (col->lowType->type == t_char && col->fixedSize != 0) 00151 col->isList = FALSE; /* It's not really a list... */ 00152 slAddHead(&obj->columnList, col); 00153 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static void asParseColSymSpec | ( | struct tokenizer * | tkz, | |
| struct asObject * | obj, | |||
| struct asColumn * | col | |||
| ) | [static] |
Definition at line 106 of file asParse.c.
References slNameNew, slReverse(), slSafeAddHead(), tokenizer::string, tokenizerErrAbort(), tokenizerMustHaveNext(), tokenizerMustMatch(), and asColumn::values.
Referenced by asParseColDef().
00109 { 00110 tokenizerMustHaveNext(tkz); 00111 while (tkz->string[0] != ')') 00112 { 00113 slSafeAddHead(&col->values, slNameNew(tkz->string)); 00114 /* look for `,' or `)', but allow `,' after last token */ 00115 tokenizerMustHaveNext(tkz); 00116 if (!((tkz->string[0] == ',') || (tkz->string[0] == ')'))) 00117 tokenizerErrAbort(tkz, "expected `,' or `)' got `%s'", tkz->string); 00118 if (tkz->string[0] != ')') 00119 tokenizerMustHaveNext(tkz); 00120 } 00121 tokenizerMustMatch(tkz, ")"); 00122 slReverse(&col->values); 00123 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct asObject* asParseFile | ( | char * | fileName | ) | [read] |
Definition at line 231 of file asParse.c.
References asParseLineFile(), lineFileOpen(), and TRUE.
00233 { 00234 return asParseLineFile(lineFileOpen(fileName, TRUE)); 00235 }
Here is the call graph for this function:

Definition at line 222 of file asParse.c.
References asParseTokens(), tokenizer::lf, tokenizerFree(), and tokenizerOnLineFile().
Referenced by asParseFile(), and asParseText().
00224 { 00225 struct tokenizer *tkz = tokenizerOnLineFile(lf); 00226 struct asObject *objList = asParseTokens(tkz); 00227 tokenizerFree(&tkz); 00228 return objList; 00229 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 155 of file asParse.c.
References AllocVar, asParseColDef(), cloneString(), asObject::columnList, asObject::comment, asObject::isSimple, asObject::isTable, asObject::name, sameWord, slReverse(), tokenizer::string, tokenizerErrAbort(), tokenizerMustHaveNext(), tokenizerMustMatch(), and TRUE.
Referenced by asParseTokens().
00157 { 00158 struct asObject *obj; 00159 AllocVar(obj); 00160 if (sameWord(tkz->string, "table")) 00161 obj->isTable = TRUE; 00162 else if (sameWord(tkz->string, "simple")) 00163 obj->isSimple = TRUE; 00164 else if (sameWord(tkz->string, "object")) 00165 ; 00166 else 00167 tokenizerErrAbort(tkz, "Expecting 'table' or 'object' got '%s'", tkz->string); 00168 tokenizerMustHaveNext(tkz); 00169 obj->name = cloneString(tkz->string); 00170 tokenizerMustHaveNext(tkz); 00171 obj->comment = cloneString(tkz->string); 00172 00173 /* parse columns */ 00174 tokenizerMustHaveNext(tkz); 00175 tokenizerMustMatch(tkz, "("); 00176 while (tkz->string[0] != ')') 00177 asParseColDef(tkz, obj); 00178 slReverse(&obj->columnList); 00179 return obj; 00180 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct asObject* asParseText | ( | char * | text | ) | [read] |
Definition at line 238 of file asParse.c.
References asParseLineFile(), cloneString(), lineFileOnString(), and TRUE.
00240 { 00241 char *dupe = cloneString(text); 00242 struct lineFile *lf = lineFileOnString("text", TRUE, dupe); 00243 struct asObject *objList = asParseLineFile(lf); 00244 return objList; 00245 }
Here is the call graph for this function:

Definition at line 202 of file asParse.c.
References asLinkEmbeddedObjects(), asParseTableDef(), findObType(), asObject::name, asObject::next, slAddTail(), tokenizerErrAbort(), and tokenizerNext().
Referenced by asParseLineFile().
00204 { 00205 struct asObject *objList = NULL; 00206 struct asObject *obj; 00207 00208 while (tokenizerNext(tkz)) 00209 { 00210 obj = asParseTableDef(tkz); 00211 if (findObType(objList, obj->name)) 00212 tokenizerErrAbort(tkz, "Duplicate definition of %s", obj->name); 00213 slAddTail(&objList, obj); 00214 } 00215 00216 for (obj = objList; obj != NULL; obj = obj->next) 00217 asLinkEmbeddedObjects(obj, objList); 00218 00219 return objList; 00220 }
Here is the call graph for this function:

Here is the caller graph for this function:

| static struct asTypeInfo* findLowType | ( | struct tokenizer * | tkz | ) | [static, read] |
Definition at line 35 of file asParse.c.
References ArraySize, name, sameWord, tokenizer::string, and tokenizerErrAbort().
Referenced by asParseColDef().
00038 { 00039 char *s = tkz->string; 00040 int i; 00041 for (i=0; i<ArraySize(asTypes); ++i) 00042 { 00043 if (sameWord(asTypes[i].name, s)) 00044 return &asTypes[i]; 00045 } 00046 tokenizerErrAbort(tkz, "Unknown type '%s'", s); 00047 return NULL; 00048 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 64 of file asParse.c.
References asObject::name, asObject::next, and sameWord.
Referenced by asLinkEmbeddedObjects(), and asParseTokens().
00066 { 00067 struct asObject *obj; 00068 for (obj = objList; obj != NULL; obj = obj->next) 00069 { 00070 if (sameWord(obj->name, obName)) 00071 return obj; 00072 } 00073 return NULL; 00074 }
Here is the caller graph for this function:

Definition at line 50 of file asParse.c.
References asObject::columnList, errAbort(), asColumn::name, asColumn::next, and sameWord.
Referenced by asParseColArraySpec().
00052 { 00053 struct asColumn *col; 00054 00055 for (col = table->columnList; col != NULL; col = col->next) 00056 { 00057 if (sameWord(col->name, colName)) 00058 return col; 00059 } 00060 errAbort("Couldn't find column %s", colName); 00061 return NULL; 00062 }
Here is the call graph for this function:

Here is the caller graph for this function:

| struct asTypeInfo asTypes[] |
Initial value:
{
{t_double, "double", FALSE, FALSE, "double", "double", "Double", "Double", "%g"},
{t_float, "float", FALSE, FALSE, "float", "float", "Float", "Float", "%g"},
{t_char, "char", FALSE, FALSE, "char", "char", "Char", "Char", "%c"},
{t_int, "int", FALSE, FALSE, "int", "int", "Signed", "Signed", "%d"},
{t_uint, "uint", TRUE, FALSE, "int unsigned", "unsigned", "Unsigned","Unsigned", "%u"},
{t_short, "short", FALSE, FALSE, "smallint", "short", "Short", "Signed", "%d"},
{t_ushort, "ushort", TRUE, FALSE, "smallint unsigned","unsigned short","Ushort", "Unsigned", "%u"},
{t_byte, "byte", FALSE, FALSE, "tinyint", "signed char", "Byte", "Signed", "%d"},
{t_ubyte, "ubyte", TRUE, FALSE, "tinyint unsigned", "unsigned char", "Ubyte", "Unsigned", "%u"},
{t_off, "bigint", FALSE, FALSE,"bigint", "long long", "LongLong", "LongLong", "%lld"},
{t_string, "string", FALSE, TRUE, "varchar(255)", "char *", "String", "String", "%s"},
{t_lstring, "lstring", FALSE, TRUE, "longblob", "char *", "String", "String", "%s"},
{t_enum, "enum", FALSE, FALSE, "enum", "!error!", "Enum", "Enum", NULL},
{t_set, "set", FALSE, FALSE, "set", "unsigned", "Set", "Set", NULL},
{t_object, "object", FALSE, FALSE, "longblob", "!error!", "Object", "Object", NULL},
{t_object, "table", FALSE, FALSE, "longblob", "!error!", "Object", "Object", NULL},
{t_simple, "simple", FALSE, FALSE, "longblob", "!error!", "Simple", "Simple", NULL},
}
char const rcsid[] = "$Id: asParse.c,v 1.6 2007/02/11 21:43:15 kent Exp $" [static] |
1.5.2