PageRenderTime 34ms CodeModel.GetById 19ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/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 */
28package edu.vub.at.objects.natives.grammar;
29
30import edu.vub.at.exceptions.InterpreterException;
31import edu.vub.at.exceptions.XIllegalUnquote;
32import edu.vub.at.objects.ATContext;
33import edu.vub.at.objects.ATObject;
34import edu.vub.at.objects.ATText;
35import edu.vub.at.objects.grammar.ATExpression;
36import edu.vub.at.objects.grammar.ATSymbol;
37
38/**
39 * AGUnquoteSymbol is a class encapsulating an unquoted expression in a position where the 
40 * grammar of the language prescribes the presence of an { @link edu.vub.at.objects.grammar.ATSymbol}.
41 * The implementation of this class is entirely identical to the one of its superclass 
42 * { @link edu.vub.at.objects.natives.grammar.AGUnquote } with the difference that is ensures
43 * that the value it returns when used in a quoted expression is indeed a symbol.
44 *
45 * @author smostinc
46 */
47public final class AGUnquoteSymbol extends AGUnquote implements ATSymbol {
48
49	/**
50	 * Constructor creating an unquoted expression which should evaluate to a symbol. 
51	 * @param exp the expression that is to be evaluated to produce the required symbol
52	 */
53	public AGUnquoteSymbol(ATExpression exp) {
54		super(exp);
55	}
56	
57	/**
58	 * Quoting an unquotation means evaluating its contained expression, and returning
59	 * its value as the result of the quote. This method ensures that the result is 
60	 * returned only if it is a proper symbol.
61	 */
62	public ATObject meta_quote(ATContext ctx) throws InterpreterException {
63		return super.meta_quote(ctx).asSymbol();
64	}
65	
66	/**
67	 * The use of an unquoted symbol as if it were the symbol itself indicates that the 
68	 * unquotation was most probably not used in a quotation. Therefore the sematics are
69	 * identical to the ones enforced in meta_eval, namely an error is reported.
70	 * 
71	 * @throws XIllegalUnquote
72	 */
73	public ATText base_text() throws InterpreterException {
74		throw new XIllegalUnquote(unqExp_);
75	}
76
77	/**
78	 * The use of an unquoted symbol as if it were the symbol itself indicates that the 
79	 * unquotation was most probably not used in a quotation. Therefore the sematics are
80	 * identical to the ones enforced in meta_eval, namely an error is reported.
81	 * 
82	 * @throws XIllegalUnquote
83	 */
84	public boolean isAssignmentSymbol() throws InterpreterException {
85		throw new XIllegalUnquote(unqExp_);
86	}
87	
88	/**
89	 * The use of an unquoted symbol as if it were the symbol itself indicates that the 
90	 * unquotation was most probably not used in a quotation. Therefore the sematics are
91	 * identical to the ones enforced in meta_eval, namely an error is reported.
92	 * 
93	 * @throws XIllegalUnquote
94	 */
95	public AGAssignmentSymbol asAssignmentSymbol() throws InterpreterException {
96		throw new XIllegalUnquote(unqExp_);
97	}
98}