/interpreter/tags/at2dist130208/src/edu/vub/at/objects/natives/grammar/AGUnquoteSymbol.java

http://ambienttalk.googlecode.com/ · Java · 98 lines · 25 code · 7 blank · 66 comment · 0 complexity · ab34f5609b41497bb4d2e10cdb4fb04c MD5 · raw file

  1. /**
  2. * AmbientTalk/2 Project
  3. * AGUnquote.java created on 26-jul-2006 at 16:29:32
  4. * (c) Programming Technology Lab, 2006 - 2007
  5. * Authors: Tom Van Cutsem & Stijn Mostinckx
  6. *
  7. * Permission is hereby granted, free of charge, to any person
  8. * obtaining a copy of this software and associated documentation
  9. * files (the "Software"), to deal in the Software without
  10. * restriction, including without limitation the rights to use,
  11. * copy, modify, merge, publish, distribute, sublicense, and/or
  12. * sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following
  14. * conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. * OTHER DEALINGS IN THE SOFTWARE.
  27. */
  28. package edu.vub.at.objects.natives.grammar;
  29. import edu.vub.at.exceptions.InterpreterException;
  30. import edu.vub.at.exceptions.XIllegalUnquote;
  31. import edu.vub.at.objects.ATContext;
  32. import edu.vub.at.objects.ATObject;
  33. import edu.vub.at.objects.ATText;
  34. import edu.vub.at.objects.grammar.ATExpression;
  35. import edu.vub.at.objects.grammar.ATSymbol;
  36. /**
  37. * AGUnquoteSymbol is a class encapsulating an unquoted expression in a position where the
  38. * grammar of the language prescribes the presence of an { @link edu.vub.at.objects.grammar.ATSymbol}.
  39. * The implementation of this class is entirely identical to the one of its superclass
  40. * { @link edu.vub.at.objects.natives.grammar.AGUnquote } with the difference that is ensures
  41. * that the value it returns when used in a quoted expression is indeed a symbol.
  42. *
  43. * @author smostinc
  44. */
  45. public final class AGUnquoteSymbol extends AGUnquote implements ATSymbol {
  46. /**
  47. * Constructor creating an unquoted expression which should evaluate to a symbol.
  48. * @param exp the expression that is to be evaluated to produce the required symbol
  49. */
  50. public AGUnquoteSymbol(ATExpression exp) {
  51. super(exp);
  52. }
  53. /**
  54. * Quoting an unquotation means evaluating its contained expression, and returning
  55. * its value as the result of the quote. This method ensures that the result is
  56. * returned only if it is a proper symbol.
  57. */
  58. public ATObject meta_quote(ATContext ctx) throws InterpreterException {
  59. return super.meta_quote(ctx).asSymbol();
  60. }
  61. /**
  62. * The use of an unquoted symbol as if it were the symbol itself indicates that the
  63. * unquotation was most probably not used in a quotation. Therefore the sematics are
  64. * identical to the ones enforced in meta_eval, namely an error is reported.
  65. *
  66. * @throws XIllegalUnquote
  67. */
  68. public ATText base_text() throws InterpreterException {
  69. throw new XIllegalUnquote(unqExp_);
  70. }
  71. /**
  72. * The use of an unquoted symbol as if it were the symbol itself indicates that the
  73. * unquotation was most probably not used in a quotation. Therefore the sematics are
  74. * identical to the ones enforced in meta_eval, namely an error is reported.
  75. *
  76. * @throws XIllegalUnquote
  77. */
  78. public boolean isAssignmentSymbol() throws InterpreterException {
  79. throw new XIllegalUnquote(unqExp_);
  80. }
  81. /**
  82. * The use of an unquoted symbol as if it were the symbol itself indicates that the
  83. * unquotation was most probably not used in a quotation. Therefore the sematics are
  84. * identical to the ones enforced in meta_eval, namely an error is reported.
  85. *
  86. * @throws XIllegalUnquote
  87. */
  88. public AGAssignmentSymbol asAssignmentSymbol() throws InterpreterException {
  89. throw new XIllegalUnquote(unqExp_);
  90. }
  91. }