Guest User

Untitled

a guest
Nov 19th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. /**
  2. * A structural type for an expression that has a getFirst and a getSecond method
  3. * which both return a Symbols.Type.
  4. */
  5. type TwoPartExpression = {
  6. def getFirst : Symbols.Type
  7. def getSecond : Symbols.Type
  8. }
  9.  
  10. /**
  11. * Determines the type of the given two part expression's operands.
  12. *
  13. * If the types are divergent, throws an exception.
  14. */
  15. def expressionType(expression:TwoPartExpression) : Symbols.Type = {
  16. val (firstType, secondType) = (expression.getFirst, expression.getSecond)
  17.  
  18. if (firstType == secondType)
  19. firstType
  20. else
  21. throw new Exception(...)
  22. }
Add Comment
Please, Sign In to add comment