next up previous
Next: Statements Up: Type Analysis Previous: Procedure and function declarations


Operator.d

Operator.d[35]:

PreDefInd('=',   operator, equal)
PreDefInd('<>',  operator, lsgt)
PreDefInd('<',   operator, less)
PreDefInd('>',   operator, greater)
PreDefInd('<=',  operator, lessequal)
PreDefInd('>=',  operator, greaterequal)
PreDefInd('in',  operator, in)
PreDefInd('+',   operator, plus)
PreDefInd('-',   operator, minus)
PreDefInd('or',  operator, or)
PreDefInd('*',   operator, star)
PreDefInd('/',   operator, slash)
PreDefInd('div', operator, div)
PreDefInd('mod', operator, mod)
PreDefInd('and', operator, and)
PreDefInd('not', operator, not)
This macro is attached to a non-product file.

Expressions[36]:
TREE SYMBOL PrcIdUse INHERITS TypedUseId, ChkTypedUseId END;
TREE SYMBOL FncIdUse INHERITS TypedUseId, ChkTypedUseId END;
TREE SYMBOL ExpIdUse INHERITS TypedUseId, ChkTypedUseId END;
TREE SYMBOL FldIdUse INHERITS TypedUseId, ChkTypedUseId END;

SYMBOL expression    INHERITS ExpressionSymbol END;
SYMBOL variable      INHERITS ExpressionSymbol END;
SYMBOL Subscript     INHERITS ExpressionSymbol END;
SYMBOL operator      INHERITS OperatorSymbol   END;

RULE: expression ::= integer_constant COMPUTE
  PrimaryContext(expression,intType);
END;

RULE: expression ::= real_constant COMPUTE
  PrimaryContext(expression,realType);
END;

RULE: expression ::= Literal COMPUTE
  PrimaryContext(expression,Literal.Type);
END;

RULE: expression ::= 'nil' COMPUTE
  PrimaryContext(expression,nilType);
END;

RULE: expression ::= variable COMPUTE
  TransferContext(expression,variable);
END;

RULE: variable ::= ExpIdUse COMPUTE
  PrimaryContext(variable,ExpIdUse.Type);
END;

RULE: variable ::= variable '[' Subscript ']' COMPUTE
  DyadicContext(variable[1],,variable[2],Subscript);
  Indication(arrayAccess);
  IF(BadOperator,message(ERROR,"Invalid array reference",0,COORDREF));
END;

ATTR Sym: int;
ATTR env: Environment;
ATTR bnd: Binding;
ATTR ScopeKey, Key: DefTableKey;

RULE: variable ::= variable '.' FldIdUse COMPUTE
  variable[2].Required=NoKey <- FldIdUse.Type;
  PrimaryContext(variable[1],FldIdUse.Type);
END;

RULE: variable ::= variable '^' COMPUTE
  MonadicContext(variable[1],,variable[2]);
  Indication(deref);
  IF(BadOperator,message(ERROR,"Invalid pointer access",0,COORDREF));
END;

RULE: Subscript ::= expression COMPUTE
  ConversionContext(Subscript,,expression);
  Indication(assignCvt);
END;

SYMBOL Actual  INHERITS OpndExprListElem END;
SYMBOL FncArgs INHERITS OpndExprListRoot END;

RULE: expression ::= FncIdUse FncArgs COMPUTE
  ListContext(expression,,FncArgs);
  Indication(FncIdUse.Type);
  IF(BadOperator,message(ERROR,"Illegal function call",0,COORDREF));
END;

RULE: Actual ::= expression COMPUTE
  ConversionContext(Actual,,expression);
  Indication(assignCvt);
END;

SYMBOL PrcArgs INHERITS OpndExprListRoot END;

RULE: ProcCall ::= PrcIdUse PrcArgs COMPUTE
  ListContext(ProcCall,,PrcArgs);
  Indication(PrcIdUse.Type);
  IF(BadOperator,message(ERROR,"Illegal procedure call",0,COORDREF));
END;

/* FIXME: Need some type checking here */

RULE: InOutStmt ::= 'read' '(' RdArgs ')'
END;

RULE: InOutStmt ::= 'readln'
END;

RULE: InOutStmt ::= 'readln' '(' RdArgs ')'
END;

RULE: InOutStmt ::= 'write' '(' WrtArgs ')'
END;

RULE: InOutStmt ::= 'writeln'
END;

RULE: InOutStmt ::= 'writeln' '(' WrtArgs ')'
END;

RULE: WrtArg ::= expression ':' expression ':' expression COMPUTE
  expression[2].Required=intType;
  expression[3].Required=intType;
END;

RULE: WrtArg ::= expression ':' expression COMPUTE
  expression[2].Required=intType;
END;

RULE: WrtArg ::= expression COMPUTE
  Indication(assignCvt);
END;

SYMBOL Members INHERITS BalanceListRoot END;
SYMBOL Member  INHERITS BalanceListElem END;

RULE: expression ::= '[' Members ']' COMPUTE
  MonadicContext(expression,,Members);
  Indication(makeset);
  IF(BadOperator,message(ERROR,"No set with this base type",0,COORDREF));
END;

RULE: expression ::= '[' ']' COMPUTE
  PrimaryContext(expression,emptyType);
END;

RULE: Member ::= expression COMPUTE
  TransferContext(Member,expression);
END;

RULE: Member ::= expression '..' expression COMPUTE
  BalanceContext(Member,expression[1],expression[2]);
END;

RULE: expression ::= operator expression COMPUTE
  MonadicContext(expression[1],operator,expression[2]);
END;

RULE: expression ::= expression operator expression COMPUTE
  DyadicContext(expression[1],operator,expression[2],expression[3]);
END;
This macro is defined in definitions 36.
This macro is invoked in definition 1.


next up previous
Next: Statements Up: Type Analysis Previous: Procedure and function declarations
2008-08-29