next up previous
Next: Support code Up: Determining the types yielded Previous: Operator indications

Expression contexts

Certain abstract tree node contexts inherit computational roles from the operator identification module.

Operator identification[53]:

SYMBOL post_lvalue_opr     INHERITS OperatorSymbol   END;
SYMBOL lvalue_operator     INHERITS OperatorSymbol   END;
SYMBOL assignment_operator INHERITS OperatorSymbol   END;
SYMBOL normal_operator     INHERITS OperatorSymbol   END;
SYMBOL logical_operator    INHERITS OperatorSymbol   END;

SYMBOL Expression          INHERITS ExpressionSymbol END;
SYMBOL RHSExpr             INHERITS ExpressionSymbol END;
SYMBOL DerefExpr           INHERITS ExpressionSymbol END;

RULE: Expression ::= IdUse COMPUTE
  PrimaryContext(Expression,IdUse.Type);
END;

RULE: Expression ::= character_constant COMPUTE
  PrimaryContext(Expression,TypeIs_char);
END;

RULE: Expression ::= floating_constant COMPUTE
  PrimaryContext(Expression,TypeIs_double);
END;

RULE: Expression ::= integer_constant COMPUTE
/* FIXME: Check the suffix */
  PrimaryContext(
    Expression,
    IF(EQ(strtol(StringTable(integer_constant),0,0),0),
      TypeIs_NULL,
      TypeIs_int));
END;
RULE: Expression ::= StringSeq
COMPUTE
  PrimaryContext(Expression,TypeIs_string);
END;

RULE: Expression ::= Expression '[' Expression ']' COMPUTE
  DyadicContext(Expression[1],,Expression[2],Expression[3]);
  Indication(Subscript_Indication);
END;

SYMBOL Arguments INHERITS OpndExprListRoot COMPUTE
  SYNT.LstMsg=
    IF(THIS.LstErr,
      IF(AND(EQ(THIS.LstTyp,TypeIs_void),NOT(THIS.LstNxt)),
        "A single 'void' means no arguments, so no message",
        message(ERROR,"Too few arguments",0,COORDREF)));
END;

SYMBOL Argument  INHERITS OpndExprListElem END;

RULE: Argument ::= Expression COMPUTE
  ConversionContext(Argument,,Expression);
  Indication(Cast_Indication);
END;

RULE: Expression ::= Expression '(' Arguments ')' COMPUTE
  ListContext(Expression[1],,Arguments);
  Indication(Expression[2].Type);
END;

SYMBOL MemberIdUse INHERITS TypedUseId END;

RULE: Expression ::= Expression '.' MemberIdUse
COMPUTE
  MemberIdUse.MemberScopeKey=Expression[2].Type;
  PrimaryContext(Expression[1],MemberIdUse.Type);
END;

RULE: Expression ::= DerefExpr '->' MemberIdUse COMPUTE
  MemberIdUse.MemberScopeKey=DerefExpr.Type;
  PrimaryContext(Expression,MemberIdUse.Type);
END;

RULE: DerefExpr ::= Expression COMPUTE
  MonadicContext(DerefExpr,,Expression);
  Indication(Star_Indication);
END;

RULE: Expression ::= Expression post_lvalue_opr COMPUTE
  MonadicContext(Expression[1],post_lvalue_opr,Expression[2]);
END;

RULE: Expression ::= lvalue_operator Expression COMPUTE
  MonadicContext(Expression[1],lvalue_operator,Expression[2]);
END;

RULE: Expression ::= normal_operator Expression COMPUTE
  MonadicContext(Expression[1],normal_operator,Expression[2]);
END;

RULE: Expression ::= 'sizeof' '(' type_name ')' COMPUTE
  PrimaryContext(Expression[1],TypeIs_int);
END;

RULE: Expression ::= '(' type_name ')' Expression COMPUTE
  PrimaryContext(Expression[1],type_name.TotalType);
  RootContext(type_name.TotalType,,Expression[2]);
  Indication(Cast_Indication);
END;

RULE: Expression ::= Expression normal_operator Expression COMPUTE
  DyadicContext(Expression[1],normal_operator,Expression[2],Expression[3]);
END;

RULE: Expression ::= Expression logical_operator Expression COMPUTE
  DyadicContext(Expression[1],logical_operator,Expression[2],Expression[3]);
END;

RULE: Expression ::= Expression '?' Expression ':' Expression COMPUTE
  BalanceContext(Expression[1],Expression[3],Expression[4]);
  Expression[2].Required=scalarType;
END;

RULE: Expression ::= Expression assignment_operator RHSExpr COMPUTE
  DyadicContext(Expression[1],assignment_operator,Expression[2],RHSExpr);
END;

RULE: RHSExpr ::= Expression COMPUTE
  ConversionContext(RHSExpr,,Expression);
  Indication(Cast_Indication);
END;

RULE: Expression ::= Expression ',' Expression COMPUTE
  TransferContext(Expression[1],Expression[3]);
END;
This macro is defined in definitions 53.
This macro is invoked in definition 1.


next up previous
Next: Support code Up: Determining the types yielded Previous: Operator indications
2008-08-30