Ignore:
Timestamp:
Aug 9, 2010, 1:53:33 PM (14 years ago)
Author:
george
Message:

Added support of parameters for function call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Analyze/UPascalParser.pas

    r47 r48  
    4949  TPascalParser = class(TBaseParser)
    5050    procedure ParseWhileDo(SourceCode: TWhileDo);
    51     function ParseExpression(SourceCode: TExpression): TExpression;
     51    procedure ParseExpression(SourceCode: TExpression);
    5252    procedure ParseUsedModuleList(SourceCode: TUsedModuleList);
    5353    procedure ParseModule(SourceCode: TModule);
     
    290290{ TExpression }
    291291
    292 function TPascalParser.ParseExpression(SourceCode: TExpression): TExpression;
     292procedure TPascalParser.ParseExpression(SourceCode: TExpression);
    293293var
    294294  Identifier: string;
     
    340340            end;
    341341          end else begin
    342             Method := CommonBlock.Methods.Search(Identifier);
     342            Method := CommonBlock.Functions.Search(Identifier);
    343343            if Assigned(Method) then begin
    344344              // Referenced method
     
    444444  LoopVariable: TVariable;
    445445  IdentName: string;
     446  FunctionName: string;
    446447begin
    447448  begin
     
    465466    if IsIdentificator(FNextToken) then begin
    466467      if Assigned(SourceCode.Variables.Search(FNextToken)) then begin
     468        // Variable assignment
    467469        Result := TAssignment.Create;
    468470        TAssignment(Result).CommonBlock := SourceCode;
     
    474476        ParseExpression(TAssignment(Result).Source);
    475477      end else
    476       if Assigned(SourceCode.Methods.Search(FNextToken)) then begin
     478      if Assigned(SourceCode.Functions.Search(FNextToken)) then begin
     479        // Function call
     480        FunctionName := ReadCode;
    477481        Result := TFunctionCall.Create;
    478482        TFunctionCall(Result).CommonBlock := SourceCode;
    479         TFunctionCall(Result).FunctionRef := SourceCode.Methods.Search(FNextToken);
    480         ReadCode;
    481   //      ParseMetVariable(TFunctionCall(Result).Target);
     483        TFunctionCall(Result).FunctionRef := SourceCode.Functions.Search(FunctionName);
     484        if FNextToken = '(' then begin
     485          Expect('(');
     486          with TFunctionCall(Result) do begin
     487            ParameterExpression.Add(TExpression.Create);
     488            TExpression(ParameterExpression.Last).CommonBlock := SourceCode;
     489            ParseExpression(TExpression(ParameterExpression.Last));
     490          end;
     491          Expect(')');
     492        end;
    482493      end else begin
    483494        Result := nil;
     
    561572        ParseTypeList(Types)
    562573      else if FNextToken = 'procedure' then
    563         ParseFunctionList(Methods)
     574        ParseFunctionList(Functions)
    564575      else if FNextToken = 'function' then
    565         ParseFunctionList(Methods)
     576        ParseFunctionList(Functions)
    566577      else begin
    567578        ParseBeginEnd(Code);
     
    583594    Expect('begin');
    584595    while (FNextToken <> 'end') and (FNextTokenType <> ttEndOfFile) do begin
    585       Commands.Add(nil);
    586596      NewCommand := ParseCommand(CommonBlock);
    587597      if Assigned(NewCommand) then Commands.Add(NewCommand);
Note: See TracChangeset for help on using the changeset viewer.