Ignore:
Timestamp:
Feb 11, 2017, 12:47:38 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Better expression parsing.
  • Added: Executor function call context for storing local variables.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter/Source3.pas

    r99 r100  
    1515  PExecution = ^TExecution;
    1616
     17  TOperator = (opNone, opAdd, opSubtract, opAnd, opOr, opNot, opEqual, opNotEqual);
     18
    1719  TBaseType = (btBoolean, btInteger, btChar, btShortString, btArray);
    1820
     
    4850
    4951  TConstant = record
    50     Name: string;
     52    Name: shortstring;
    5153    DataType: PType;
    5254    Index: Integer;
     
    8587  TCommand = record
    8688    CmdType: TCmdType;
    87     Ptr: Pointer;
    8889    case Integer of
    8990      0: (WhileDo: PWhileDo);
     
    103104  end;
    104105
    105   TReadType = (rtVariable, rtConstant, rtExpression, rtFunctionCall);
     106  TReadType = (rtVariable, rtConstant, rtExpression, rtFunctionCall, rtValue);
    106107  TGetValue = record
    107108    ReadType: TReadType;
     
    111112      rtExpression: (Expression: PExpression);
    112113      rtFunctionCall: (FunctionCall: PExecution);
     114      rtValue: (Value: TConstant);
    113115  end;
    114116  PGetValue = ^TGetValue;
    115117
    116   TExpOperand = (eoNone, eoAdd, eoSubtract, eoAnd, eoOr, eoNot);
     118  TExpNodeType = (ntNone, ntValue, ntOperator);
    117119
    118120  TExpression = record
    119     Operand: TExpOperand;
    120     Items: array of TGetValue;
     121    NodeType: TExpNodeType;
     122    OperatorType: TOperator;
     123    Items: array of TExpression;
     124    Value: TGetValue;
     125    Parentheses: Boolean;
     126    Associated: Boolean;
    121127  end;
    122128
     
    181187function FunctionParameterCreate(Name: string; DataType: PType): TFunctionParameter;
    182188
     189var
     190  OperatorString: array[TOperator] of string = ('', '+', '-', 'and', 'or', 'not',
     191    '=', '<>');
     192
     193const
     194  OperatorPrecedence: array[0..6] of TOperator = (opNot, opAnd, opOr, opAdd,
     195    opSubtract, opEqual, opNotEqual);
     196
    183197
    184198implementation
Note: See TracChangeset for help on using the changeset viewer.