Ignore:
Timestamp:
Jul 26, 2017, 11:35:26 PM (7 years ago)
Author:
chronos
Message:

*Modified: Better parsing of variable reference.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter/interpreter4/Source.pas

    r106 r108  
    99  PAssignment = ^TAssignment;
    1010  PVariable = ^TVariable;
     11  PVariableRef = ^TVariableRef;
    1112  PConstant = ^TConstant;
    1213  PIfThenElse = ^TIfThenElse;
     
    1920  PFunction = ^TFunction;
    2021  PVariables = ^TVariables;
    21 
    22   TOperator = (opNone, opAdd, opSubtract, opAnd, opOr, opNot, opEqual, opNotEqual);
     22  PGetValue = ^TGetValue;
     23
     24  TOperator = (opNone, opAdd, opSubtract, opAnd, opOr, opNot, opEqual, opNotEqual,
     25  opLess, opGreater, opLessOrEqual, opGreaterOrEqual);
    2326
    2427  TBaseType = (btNone, btBoolean, btInteger, btChar, btShortString, btArray,
     
    9497  end;
    9598
     99  TVariableRef = record
     100    Variable: PVariable;
     101    case TBaseType of
     102      btRecord: (Field: PType);
     103      btArray: (Index: PGetValue);
     104  end;
     105
    96106  TFunctionParameter = record
    97107    Name: string;
     
    135145    ReadType: TReadType;
    136146    case TReadType of
    137       rtVariable: (Variable: PVariable);
     147      rtVariable: (VariableRef: PVariableRef);
    138148      rtConstant: (Constant: PConstant);
    139149      rtExpression: (Expression: PExpression);
     
    141151      rtValue: (Value: TConstant);
    142152  end;
    143   PGetValue = ^TGetValue;
    144153
    145154  TExpNodeType = (ntNone, ntValue, ntOperator);
     
    155164
    156165  TAssignment = record
    157     Destination: PVariable;
     166    Destination: PVariableRef;
    158167    Source: TGetValue;
    159168  end;
     
    249258var
    250259  OperatorString: array[TOperator] of string = ('', '+', '-', 'and', 'or', 'not',
    251     '=', '<>');
     260    '=', '<>', '<', '>', '<=', '>=');
    252261
    253262const
    254   OperatorPrecedence: array[0..6] of TOperator = (opNot, opAnd, opOr, opAdd,
    255     opSubtract, opEqual, opNotEqual);
     263  OperatorPrecedence: array[0..10] of TOperator = (opNot, opAnd, opOr, opAdd,
     264    opSubtract, opEqual, opNotEqual, opLess, opGreater, opLessOrEqual, opGreaterOrEqual);
    256265  Keywords: array[0..18] of string = ('begin', 'end', 'if', 'then', 'else', 'while',
    257266    'do', 'type', 'var', 'const', 'uses', 'unit', 'program', 'array', 'procedure',
Note: See TracChangeset for help on using the changeset viewer.