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 Declarator funcDecl = null;
153 while(decl && decl.type != identifierDeclarator)
155 if(decl.type == functionDeclarator)
157 decl = decl.declarator;
164 public Declarator SpecDeclFromString(char * string, OldList * specs, Declarator baseDecl)
166 Location oldLocation = yylloc;
167 Declarator decl = null;
168 File backFileInput = fileInput;
170 //char * classOp, * type;
175 classOp = strstr(string, "::");
176 type = classOp ? (classOp + 2) : string;
179 fileInput = TempFile { };
180 fileInput.Write(string, 1, strlen(string));
181 fileInput.Seek(0, start);
183 //type_yydebug = true;
185 parseTypeError = false;
187 declMode = structDeclMode = defaultAccess;
190 bool oldParsingType = parsingType;
193 parsingType = oldParsingType;
195 declMode = structDeclMode = privateAccess;
197 type_yydebug = false;
203 if(parsedType.qualifiers)
206 for(;(spec = parsedType.qualifiers->first);)
208 parsedType.qualifiers->Remove(spec);
212 if(parsedType.bitCount)
214 parsedType.declarator = MkStructDeclarator(parsedType.declarator, parsedType.bitCount);
215 parsedType.bitCount = null;
217 decl = PlugDeclarator(parsedType.declarator, baseDecl);
218 FreeTypeName(parsedType);
223 Compiler_Warning($"parsing type %s\n", string);
224 // Compiler_Error($"parsing type %s\n", string);
229 Compiler_Warning($"parsing type %s\n", string);
230 // Compiler_Error($"parsing type %s\n", string);
231 //eSystem_Logf("parsing type %s\n", string);
236 yylloc = oldLocation;
238 fileInput = backFileInput;