Changeset 144


Ignore:
Timestamp:
Jan 16, 2018, 4:06:32 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Handle non-numeric input text for integer value as zero.
Location:
branches/easy compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/easy compiler/Steps.txt

    r142 r144  
    33Add parser
    44Add function calls without parameters
     5- every line is one command
     6- whitespaces trimmed
    57- printhelloworld function
    68Add functions with parameters
    79- change printhelloworld function to println
    8 - add tokenizer: identifier and string constants token types
     10- add tokenizer: identifier and string constants token types, whitespaces ignored
    911Add executor
    1012Add generator
     
    1820Add begin-end block support
    1921- local variables, constants, types
     22
     23
     24TODO:
     25Expressions
     26Enumerations
     27Arrays
     28Records
     29User defined functions
     30Parametrized Types
  • branches/easy compiler/USourceExecutor.pas

    r142 r144  
    8080  Value: TSourceValue;
    8181  ExecutorVar: TExecutorVariable;
     82  Text: string;
     83  IntValue: Integer;
    8284
    8385function ReadValueReference(Reference: TSourceReference): TSourceValue;
     
    135137          end else
    136138          if ExecutorVar.Value is TSourceValueInteger then begin
    137             TSourceValueInteger(ExecutorVar.Value).Value := StrToInt(FOnInput);
     139            Text := FOnInput;
     140            if TryStrToInt(Text, IntValue) then
     141              TSourceValueInteger(ExecutorVar.Value).Value := IntValue
     142              else TSourceValueInteger(ExecutorVar.Value).Value := 0;
    138143            FOnOutput(IntToStr(TSourceValueInteger(ExecutorVar.Value).Value) + LineEnding);
    139144          end else
Note: See TracChangeset for help on using the changeset viewer.