Ignore:
Timestamp:
Jun 26, 2023, 12:08:45 PM (17 months ago)
Author:
chronos
Message:
  • Added: Var function parameters support.
  • Added: Read and ReadLn procedures support.
  • Added: Interpreter now prints into console form.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Parser.pas

    r225 r230  
    3131implementation
    3232
     33resourcestring
     34  SCannotParseProgram = 'Cannot parse program.';
     35
    3336{ TParser }
    3437
     
    188191    ResultType := TypeInteger;
    189192  end;
     193  with Block.Functions.AddNew('BoolToStr') do begin
     194    InternalName := 'BoolToStr';
     195    Params.AddNew('Value', TypeBoolean);
     196    ResultType := TypeString;
     197  end;
     198  with Block.Functions.AddNew('StrToBool') do begin
     199    InternalName := 'StrToBool';
     200    Params.AddNew('Value', TypeString);
     201    ResultType := TypeBoolean;
     202  end;
    190203  with Block.Functions.AddNew('WriteLn') do begin
    191204    InternalName := 'WriteLn';
     
    195208    InternalName := 'Write';
    196209    Params.AddNew('Text', TypeString);
     210  end;
     211  with Block.Functions.AddNew('ReadLn') do begin
     212    InternalName := 'ReadLn';
     213    with Params.AddNew('Text', TypeString) do
     214      Kind := pkVar;
     215  end;
     216  with Block.Functions.AddNew('Read') do begin
     217    InternalName := 'Read';
     218    with Params.AddNew('Text', TypeString) do
     219      Kind := pkVar;
    197220  end;
    198221end;
     
    214237  if ParseProgram(SystemBlock, NewProg) then begin
    215238    Prog := NewProg;
    216   end else Tokenizer.Error('Cannot parse program.');
     239  end else Tokenizer.Error(SCannotParseProgram);
    217240end;
    218241
Note: See TracChangeset for help on using the changeset viewer.