Changeset 6 for trunk/Compiler/Analyze
- Timestamp:
- Nov 5, 2010, 11:31:04 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Analyze/UPascalParser.pas
r5 r6 27 27 Expressions: TListExpression): Boolean; 28 28 function ParseExpressionFunctionCall(SourceCode: TExpression; 29 Expressions: TListExpression; var Func: TFunction ): Boolean;29 Expressions: TListExpression; var Func: TFunctionCall): Boolean; 30 30 function ParseUses(SourceCode: TUsedModuleList; AExported: Boolean): Boolean; 31 31 function ParseModule(ProgramCode: TProgram): TModule; … … 225 225 UseConstant: TConstant; 226 226 UseFunction: TFunction; 227 FunctionCall: TFunctionCall; 227 228 NewExpression: TExpression; 228 229 Identifier: string; … … 236 237 if Assigned(UseType) then begin 237 238 ReadToken; 239 if NextToken = '(' then begin 240 Expect('('); 241 // Typecasting 242 NewExpression := TExpression.Create; 243 NewExpression.CommonBlock := SourceCode.CommonBlock; 244 NewExpression.NodeType := ntTypecast; 245 NewExpression.UseType := UseType; 246 ParseExpression(NewExpression); 247 Expect(')'); 248 end else 238 249 if (UseType is TTypeRecord) or (UseType is TTypeClass) then begin 239 // type.variable or type.function250 // Type context 240 251 Expect('.'); 241 252 Identifier := ReadToken; 242 253 UseVariable := TTypeRecord(UseType).CommonBlock.Variables.Search(Identifier); 243 254 if Assigned(UseVariable) then begin 255 // Record or class variable 244 256 NewExpression := TExpression.Create; 245 257 NewExpression.CommonBlock := SourceCode.CommonBlock; … … 250 262 UseFunction := TTypeRecord(UseType).CommonBlock.Functions.Search(Identifier); 251 263 if Assigned(UseFunction) then begin 264 // Record or class functions 265 ParseExpressionFunctionCall(SourceCode, Expressions, FunctionCall); 252 266 NewExpression := TExpression.Create; 253 267 NewExpression.CommonBlock := SourceCode.CommonBlock; 254 268 NewExpression.NodeType := ntFunction; 255 NewExpression.FunctionCall := UseFunction;269 NewExpression.FunctionCall := FunctionCall; 256 270 end; 257 271 end; … … 273 287 if not Assigned(NewExpression) then begin 274 288 // Function call 275 ParseExpressionFunctionCall(SourceCode, Expressions, UseFunction);276 if Assigned( UseFunction) then begin289 ParseExpressionFunctionCall(SourceCode, Expressions, FunctionCall); 290 if Assigned(FunctionCall) then begin 277 291 NewExpression := TExpression.Create; 278 292 NewExpression.CommonBlock := SourceCode.CommonBlock; 279 293 NewExpression.NodeType := ntFunction; 280 NewExpression.FunctionCall := UseFunction;294 NewExpression.FunctionCall := FunctionCall; 281 295 end; 282 296 end; … … 319 333 320 334 function TPascalParser.ParseExpressionFunctionCall(SourceCode: TExpression; 321 Expressions: TListExpression; var Func: TFunction ): Boolean;335 Expressions: TListExpression; var Func: TFunctionCall): Boolean; 322 336 var 323 337 UseFunction: TFunction; 338 NewExpression: TExpression; 339 I: Integer; 324 340 begin 325 341 Func := nil; … … 328 344 if Assigned(UseFunction) then begin 329 345 ReadToken; 330 Func := UseFunction; 346 Func := TFunctionCall.Create; 347 Func.CommonBlock := SourceCode.CommonBlock; 348 Func.FunctionRef := UseFunction; 331 349 if NextToken = '(' then begin 332 350 Expect('('); 333 while NextToken = ',' do begin 334 Expect(','); 335 Expect(')'); 336 end; 351 for I := 0 to Func.FunctionRef.Parameters.Count - 1 do begin 352 if I > 0 then Expect(','); 353 NewExpression := TExpression.Create; 354 NewExpression.CommonBlock := SourceCode.CommonBlock; 355 ParseExpression(NewExpression); 356 Func.ParameterExpression.Add(NewExpression); 357 end; 358 Expect(')'); 337 359 end; 338 360 Result := True;
Note:
See TracChangeset
for help on using the changeset viewer.