2 public import static "ecere"
10 public void SetParsingType(bool b) { parsingType = b; }
12 extern TypeName parsedType;
14 extern bool type_yydebug;
15 extern Location yylloc;
18 void resetScannerPos(CodePosition pos);
20 Declarator PlugDeclarator(Declarator decl, Declarator baseDecl)
22 if(decl && decl.type != identifierDeclarator)
25 decl = CopyDeclarator(decl);
28 if(base.type != identifierDeclarator)
30 for(; base.declarator && base.declarator.type != identifierDeclarator; base = base.declarator)
38 FreeDeclarator(base.declarator);
39 base.declarator = baseDecl;
41 else if(base.type == identifierDeclarator)
53 // *** Shortcut Functions ***
54 Declarator QMkPtrDecl(char * id)
56 Declarator declarator = id ? MkDeclaratorIdentifier(MkIdentifier(id)) : null;
57 return MkDeclaratorPointer(MkPointer(null,null), declarator);
60 TypeName QMkType(char * spec, Declarator decl)
62 OldList * specs = MkList();
63 ListAdd(specs, MkSpecifierName(spec));
64 return MkTypeName(specs, decl);
67 TypeName QMkClass(char * spec, Declarator decl)
69 OldList * specs = MkList();
70 ListAdd(specs, MkSpecifierName/*MkClassName*/(spec));
71 return MkTypeName(specs, decl);
74 Expression QBrackets(Expression exp)
76 OldList * expList = MkList();
77 ListAdd(expList, exp);
78 return MkExpBrackets(expList);
81 Expression QMkExpId(char * id)
83 return MkExpIdentifier(MkIdentifier(id));
86 Expression QMkExpCond(Expression cond, Expression exp, Expression elseExp)
88 OldList * expList = MkList();
89 ListAdd(expList, exp);
90 return MkExpCondition(cond, expList, elseExp);
93 Declaration QMkDeclaration(char * name, InitDeclarator initDecl)
95 OldList * specs = MkList(), * initDecls = null;
96 ListAdd(specs, MkSpecifierName(name));
100 ListAdd(initDecls, initDecl);
102 return MkDeclaration(specs, initDecls);
105 Declaration QMkDeclarationBase(int base, InitDeclarator initDecl)
107 OldList * specs = MkList(), * initDecls = null;
108 ListAdd(specs, MkSpecifier(base));
111 initDecls = MkList();
112 ListAdd(initDecls, initDecl);
114 return MkDeclaration(specs, initDecls);
117 char * QMkString(char * source)
126 for(i = 0; (ch = source[i]); i++)
129 if(ch == '\"' || ch == '\\')
133 string = new char[len+3];
136 for(i = 0; (ch = source[i]); i++)
138 if(ch == '\"' || ch == '\\')
146 string = CopyString("0");
150 public Declarator GetFuncDecl(Declarator decl)
152 while(decl && decl.type != functionDeclarator && decl.type != identifierDeclarator)
153 decl = decl.declarator;
154 return (decl && decl.type == functionDeclarator) ? decl : null;
159 public Declarator SpecDeclFromString(char * string, OldList * specs, Declarator baseDecl)
161 Location oldLocation = yylloc;
162 Declarator decl = null;
163 File backFileInput = fileInput;
165 //char * classOp, * type;
170 classOp = strstr(string, "::");
171 type = classOp ? (classOp + 2) : string;
174 fileInput = TempFile { };
175 fileInput.Write(string, 1, strlen(string));
176 fileInput.Seek(0, start);
178 //type_yydebug = true;
180 parseTypeError = false;
185 bool oldParsingType = parsingType;
188 parsingType = oldParsingType;
190 declMode = privateAccess;
192 type_yydebug = false;
198 if(parsedType.qualifiers)
201 for(;(spec = parsedType.qualifiers->first);)
203 parsedType.qualifiers->Remove(spec);
207 if(parsedType.bitCount)
209 parsedType.declarator = MkStructDeclarator(parsedType.declarator, parsedType.bitCount);
210 parsedType.bitCount = null;
212 decl = PlugDeclarator(parsedType.declarator, baseDecl);
213 FreeTypeName(parsedType);
218 Compiler_Warning("parsing type %s\n", string);
219 // Compiler_Error("parsing type %s\n", string);
224 Compiler_Warning("parsing type %s\n", string);
225 // Compiler_Error("parsing type %s\n", string);
226 //eSystem_Logf("parsing type %s\n", string);
231 yylloc = oldLocation;
233 fileInput = backFileInput;