Package: ExpressionReader

ExpressionReader

nameinstructionbranchcomplexitylinemethod
ExpressionReader(LexTokenReader)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getMkTypeName(ILexNameToken)
M: 13 C: 37
74%
M: 1 C: 2
67%
M: 1 C: 2
67%
M: 2 C: 5
71%
M: 0 C: 1
100%
isBracketed(List)
M: 19 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
readAndExpression()
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
readAnnotatedExpression()
M: 49 C: 20
29%
M: 7 C: 1
13%
M: 4 C: 1
20%
M: 9 C: 7
44%
M: 0 C: 1
100%
readApplicatorExpression()
M: 35 C: 308
90%
M: 5 C: 47
90%
M: 5 C: 24
83%
M: 9 C: 88
91%
M: 0 C: 1
100%
readBasicExpression()
M: 14 C: 254
95%
M: 1 C: 31
97%
M: 1 C: 31
97%
M: 2 C: 66
97%
M: 0 C: 1
100%
readCaseAlternatives(PExp)
M: 0 C: 39
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
readCasesExpression(ILexLocation)
M: 0 C: 60
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
readConnectiveExpression()
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
readDefEqualsExpression()
M: 6 C: 17
74%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 2 C: 4
67%
M: 0 C: 1
100%
readDefExpression(ILexLocation)
M: 0 C: 33
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
readElseIfExpression(ILexLocation)
M: 0 C: 16
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
readEvaluatorP1Expression()
M: 0 C: 91
100%
M: 0 C: 10
100%
M: 0 C: 9
100%
M: 0 C: 29
100%
M: 0 C: 1
100%
readEvaluatorP2Expression()
M: 0 C: 81
100%
M: 0 C: 9
100%
M: 0 C: 8
100%
M: 0 C: 26
100%
M: 0 C: 1
100%
readEvaluatorP3Expression()
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
readEvaluatorP4Expression()
M: 0 C: 41
100%
M: 0 C: 5
100%
M: 0 C: 4
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
readEvaluatorP5Expression()
M: 0 C: 41
100%
M: 0 C: 5
100%
M: 0 C: 4
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
readEvaluatorP6Expression()
M: 4 C: 184
98%
M: 1 C: 20
95%
M: 1 C: 19
95%
M: 1 C: 61
98%
M: 0 C: 1
100%
readExists1Expression(ILexLocation)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
readExistsExpression(ILexLocation)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
readExpression()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
readExpressionList()
M: 0 C: 22
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
readForAllExpression(ILexLocation)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
readHistoryExpression(ILexLocation)
M: 28 C: 69
71%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 5 C: 12
71%
M: 0 C: 1
100%
readIfExpression(ILexLocation)
M: 4 C: 53
93%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 12
92%
M: 0 C: 1
100%
readImpliesExpression()
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
readIotaExpression(ILexLocation)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
readIsExpression(AVariableExp)
M: 5 C: 156
97%
M: 1 C: 14
93%
M: 1 C: 11
92%
M: 1 C: 36
97%
M: 0 C: 1
100%
readIsOfBaseExpression(ILexLocation)
M: 13 C: 39
75%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 3 C: 8
73%
M: 0 C: 1
100%
readIsOfClassExpression(ILexLocation)
M: 13 C: 39
75%
M: 3 C: 3
50%
M: 3 C: 1
25%
M: 3 C: 8
73%
M: 0 C: 1
100%
readLambdaExpression(ILexLocation)
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
readLetBeStExpression(ILexLocation)
M: 0 C: 34
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
readLetDefExpression(ILexLocation)
M: 0 C: 35
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
readLetExpression(ILexLocation)
M: 2 C: 52
96%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 17
100%
M: 0 C: 1
100%
readMapExpression(ILexLocation, AMapletExp)
M: 4 C: 89
96%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 1 C: 26
96%
M: 0 C: 1
100%
readMkExpression(AVariableExp)
M: 12 C: 86
88%
M: 3 C: 11
79%
M: 3 C: 5
63%
M: 3 C: 20
87%
M: 0 C: 1
100%
readMuExpression(AVariableExp)
M: 0 C: 45
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 9
100%
M: 0 C: 1
100%
readNarrowExpression(AVariableExp)
M: 0 C: 43
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 12
100%
M: 0 C: 1
100%
readNewExpression(ILexLocation)
M: 0 C: 47
100%
M: 0 C: 4
100%
M: 0 C: 3
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
readNotExpression()
M: 0 C: 24
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
readOrExpression()
M: 0 C: 21
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
readPerExpression()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
readPreExpression(AVariableExp)
M: 0 C: 28
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 6
100%
M: 0 C: 1
100%
readRelationalExpression()
M: 8 C: 168
95%
M: 2 C: 19
90%
M: 2 C: 14
88%
M: 2 C: 46
96%
M: 0 C: 1
100%
readSameBaseExpression(ILexLocation)
M: 4 C: 21
84%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 5
83%
M: 0 C: 1
100%
readSameClassExpression(ILexLocation)
M: 4 C: 21
84%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 5
83%
M: 0 C: 1
100%
readSeqExpression(ILexLocation)
M: 0 C: 85
100%
M: 0 C: 8
100%
M: 0 C: 5
100%
M: 0 C: 23
100%
M: 0 C: 1
100%
readSetExpression(ILexLocation, PExp)
M: 0 C: 111
100%
M: 0 C: 10
100%
M: 0 C: 6
100%
M: 0 C: 29
100%
M: 0 C: 1
100%
readSetOrMapExpression(ILexLocation)
M: 0 C: 57
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 15
100%
M: 0 C: 1
100%
readTimeExpression(ILexLocation)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: *
3: *        Copyright (c) 2008 Fujitsu Services Ltd.
4: *
5: *        Author: Nick Battle
6: *
7: *        This file is part of VDMJ.
8: *
9: *        VDMJ is free software: you can redistribute it and/or modify
10: *        it under the terms of the GNU General Public License as published by
11: *        the Free Software Foundation, either version 3 of the License, or
12: *        (at your option) any later version.
13: *
14: *        VDMJ is distributed in the hope that it will be useful,
15: *        but WITHOUT ANY WARRANTY; without even the implied warranty of
16: *        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: *        GNU General Public License for more details.
18: *
19: *        You should have received a copy of the GNU General Public License
20: *        along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21: *
22: ******************************************************************************/
23:
24: package org.overture.parser.syntax;
25:
26: import java.util.Collections;
27: import java.util.List;
28: import java.util.Vector;
29:
30: import org.overture.ast.annotations.PAnnotation;
31: import org.overture.ast.definitions.PDefinition;
32: import org.overture.ast.expressions.AAnnotatedUnaryExp;
33: import org.overture.ast.expressions.ACaseAlternative;
34: import org.overture.ast.expressions.ACasesExp;
35: import org.overture.ast.expressions.ADefExp;
36: import org.overture.ast.expressions.AElseIfExp;
37: import org.overture.ast.expressions.AEqualsBinaryExp;
38: import org.overture.ast.expressions.AExists1Exp;
39: import org.overture.ast.expressions.AExistsExp;
40: import org.overture.ast.expressions.AForAllExp;
41: import org.overture.ast.expressions.AIfExp;
42: import org.overture.ast.expressions.AIotaExp;
43: import org.overture.ast.expressions.AIsExp;
44: import org.overture.ast.expressions.AIsOfBaseClassExp;
45: import org.overture.ast.expressions.AIsOfClassExp;
46: import org.overture.ast.expressions.ALambdaExp;
47: import org.overture.ast.expressions.ALetBeStExp;
48: import org.overture.ast.expressions.ALetDefExp;
49: import org.overture.ast.expressions.AMapletExp;
50: import org.overture.ast.expressions.AMuExp;
51: import org.overture.ast.expressions.ANarrowExp;
52: import org.overture.ast.expressions.ANewExp;
53: import org.overture.ast.expressions.APreExp;
54: import org.overture.ast.expressions.ARecordModifier;
55: import org.overture.ast.expressions.ASameBaseClassExp;
56: import org.overture.ast.expressions.ASameClassExp;
57: import org.overture.ast.expressions.AVariableExp;
58: import org.overture.ast.expressions.PExp;
59: import org.overture.ast.expressions.SMapExp;
60: import org.overture.ast.expressions.SSeqExp;
61: import org.overture.ast.expressions.SSetExp;
62: import org.overture.ast.factory.AstFactory;
63: import org.overture.ast.intf.lex.ILexCommentList;
64: import org.overture.ast.intf.lex.ILexLocation;
65: import org.overture.ast.intf.lex.ILexNameToken;
66: import org.overture.ast.lex.Dialect;
67: import org.overture.ast.lex.LexBooleanToken;
68: import org.overture.ast.lex.LexCharacterToken;
69: import org.overture.ast.lex.LexIdentifierToken;
70: import org.overture.ast.lex.LexIntegerToken;
71: import org.overture.ast.lex.LexKeywordToken;
72: import org.overture.ast.lex.LexNameList;
73: import org.overture.ast.lex.LexNameToken;
74: import org.overture.ast.lex.LexQuoteToken;
75: import org.overture.ast.lex.LexRealToken;
76: import org.overture.ast.lex.LexStringToken;
77: import org.overture.ast.lex.LexToken;
78: import org.overture.ast.lex.VDMToken;
79: import org.overture.ast.node.NodeList;
80: import org.overture.ast.patterns.ATypeBind;
81: import org.overture.ast.patterns.PBind;
82: import org.overture.ast.patterns.PMultipleBind;
83: import org.overture.ast.patterns.PPattern;
84: import org.overture.ast.typechecker.NameScope;
85: import org.overture.ast.types.AUnresolvedType;
86: import org.overture.ast.types.PType;
87: import org.overture.config.Release;
88: import org.overture.config.Settings;
89: import org.overture.parser.lex.LexException;
90: import org.overture.parser.lex.LexTokenReader;
91:
92: /**
93: * A syntax analyser to parse expressions.
94: */
95:
96: public class ExpressionReader extends SyntaxReader
97: {
98:         public ExpressionReader(LexTokenReader reader)
99:         {
100:                 super(reader);
101:         }
102:
103:         public List<PExp> readExpressionList() throws ParserException, LexException
104:         {
105:                 List<PExp> list = new NodeList<PExp>(null);
106:                 list.add(readExpression());
107:
108:•                while (ignore(VDMToken.COMMA))
109:                 {
110:                         list.add(readExpression());
111:                 }
112:
113:                 return list;
114:         }
115:
116:         // Constructor Family...
117:
118:         public PExp readExpression() throws ParserException, LexException
119:         {
120:                 return readConnectiveExpression();
121:         }
122:
123:         // Connectives Family. All (recursive) right grouping...
124:
125:         private PExp readConnectiveExpression() throws ParserException,
126:                         LexException
127:         {
128:                 PExp exp = readImpliesExpression();
129:                 LexToken token = lastToken();
130:
131:•                if (token.is(VDMToken.EQUIVALENT))
132:                 {
133:                         nextToken();
134:                         exp = AstFactory.newAEquivalentBooleanBinaryExp(exp, token, readConnectiveExpression());
135:                 }
136:
137:                 return exp;
138:         }
139:
140:         private PExp readImpliesExpression() throws ParserException, LexException
141:         {
142:                 PExp exp = readOrExpression();
143:                 LexToken token = lastToken();
144:
145:•                if (token.is(VDMToken.IMPLIES))
146:                 {
147:                         nextToken();
148:                         exp = AstFactory.newAImpliesBooleanBinaryExp(exp, token, readImpliesExpression());
149:                 }
150:
151:                 return exp;
152:         }
153:
154:         private PExp readOrExpression() throws ParserException, LexException
155:         {
156:                 PExp exp = readAndExpression();
157:                 LexToken token = lastToken();
158:
159:•                if (token.is(VDMToken.OR))
160:                 {
161:                         nextToken();
162:                         exp = AstFactory.newAOrBooleanBinaryExp(exp, token, readOrExpression());
163:                 }
164:
165:                 return exp;
166:         }
167:
168:         private PExp readAndExpression() throws ParserException, LexException
169:         {
170:                 PExp exp = readNotExpression();
171:                 LexToken token = lastToken();
172:
173:•                if (token.is(VDMToken.AND))
174:                 {
175:                         nextToken();
176:                         exp = AstFactory.newAAndBooleanBinaryExp(exp, token, readAndExpression());
177:                 }
178:
179:                 return exp;
180:         }
181:
182:         private PExp readNotExpression() throws ParserException, LexException
183:         {
184:                 PExp exp = null;
185:                 LexToken token = lastToken();
186:
187:•                if (token.is(VDMToken.NOT))
188:                 {
189:                         nextToken();
190:                         exp = AstFactory.newANotUnaryExp(token.location, readNotExpression());
191:                 } else
192:                 {
193:                         exp = readRelationalExpression();
194:                 }
195:
196:                 return exp;
197:         }
198:
199:         // Relations Family...
200:
201:         public AEqualsBinaryExp readDefEqualsExpression() throws ParserException,
202:                         LexException
203:         {
204:                 // This is an oddball parse for the "def" expression :-)
205:
206:                 PExp exp = readEvaluatorP1Expression();
207:                 LexToken token = lastToken();
208:
209:•                if (readToken().is(VDMToken.EQUALS))
210:                 {
211:                         return AstFactory.newAEqualsBinaryExp(exp, token, readEvaluatorP1Expression());
212:                 }
213:
214:                 throwMessage(2029, "Expecting <set bind> = <expression>");
215:                 return null;
216:         }
217:
218:         private PExp readRelationalExpression() throws ParserException,
219:                         LexException
220:         {
221:                 PExp exp = readEvaluatorP1Expression();
222:                 LexToken token = lastToken();
223:
224:•                if (token.is(VDMToken.NOT))
225:                 {
226:                         // Check for "not in set"
227:                         reader.push();
228:
229:•                        if (nextToken().is(VDMToken.IN))
230:                         {
231:•                                if (nextToken().is(VDMToken.SET))
232:                                 {
233:                                         token = new LexKeywordToken(VDMToken.NOTINSET, token.location);
234:                                         reader.unpush();
235:                                 } else
236:                                 {
237:                                         reader.pop();
238:                                 }
239:                         } else
240:                         {
241:                                 reader.pop();
242:                         }
243:•                } else if (token.is(VDMToken.IN))
244:                 {
245:                         // Check for "in set"
246:                         reader.push();
247:
248:•                        if (nextToken().is(VDMToken.SET))
249:                         {
250:                                 token = new LexKeywordToken(VDMToken.INSET, token.location);
251:                                 reader.unpush();
252:                         } else
253:                         {
254:                                 reader.pop();
255:                         }
256:                 }
257:
258:                 // No grouping for relationals...
259:•                switch (token.type)
260:                 {
261:                         case LT:
262:                                 nextToken();
263:                                 exp = AstFactory.newALessNumericBinaryExp(exp, token, readNotExpression());
264:                                 break;
265:
266:                         case LE:
267:                                 nextToken();
268:                                 exp = AstFactory.newALessEqualNumericBinaryExp(exp, token, readNotExpression());
269:                                 break;
270:
271:                         case GT:
272:                                 nextToken();
273:                                 exp = AstFactory.newAGreaterNumericBinaryExp(exp, token, readNotExpression());
274:                                 break;
275:
276:                         case GE:
277:                                 nextToken();
278:                                 exp = AstFactory.newAGreaterEqualNumericBinaryExp(exp, token, readNotExpression());
279:                                 break;
280:
281:                         case NE:
282:                                 nextToken();
283:                                 exp = AstFactory.newANotEqualBinaryExp(exp, token, readNotExpression());
284:                                 break;
285:
286:                         case EQUALS:
287:                                 nextToken();
288:                                 exp = AstFactory.newAEqualsBinaryExp(exp, token, readNotExpression());
289:                                 break;
290:
291:                         case SUBSET:
292:                                 nextToken();
293:                                 exp = AstFactory.newASubsetBinaryExp(exp, token, readNotExpression());
294:                                 break;
295:
296:                         case PSUBSET:
297:                                 nextToken();
298:                                 exp = AstFactory.newAProperSubsetBinaryExp(exp, token, readNotExpression());
299:                                 break;
300:
301:                         case INSET:
302:                                 nextToken();
303:                                 exp = AstFactory.newAInSetBinaryExp(exp, token, readNotExpression());
304:                                 break;
305:
306:                         case NOTINSET:
307:                                 nextToken();
308:                                 exp = AstFactory.newANotInSetBinaryExp(exp, token, readNotExpression());
309:                                 break;
310:                         default:
311:                                 break;
312:                 }
313:
314:                 return exp;
315:         }
316:
317:         // Evaluator Family...
318:
319:         private PExp readEvaluatorP1Expression() throws ParserException,
320:                         LexException
321:         {
322:                 PExp exp = readEvaluatorP2Expression();
323:                 boolean more = true;
324:
325:•                while (more) // Left grouping
326:                 {
327:                         LexToken token = lastToken();
328:
329:•                        switch (token.type)
330:                         {
331:                                 case PLUS:
332:                                         nextToken();
333:                                         exp = AstFactory.newAPlusNumericBinaryExp(exp, token, readEvaluatorP2Expression());
334:                                         break;
335:
336:                                 case MINUS:
337:                                         nextToken();
338:                                         exp = AstFactory.newASubstractNumericBinaryExp(exp, token, readEvaluatorP2Expression());
339:                                         break;
340:
341:                                 case UNION:
342:                                         nextToken();
343:                                         exp = AstFactory.newASetUnionBinaryExp(exp, token, readEvaluatorP2Expression());
344:                                         break;
345:
346:                                 case SETDIFF:
347:                                         nextToken();
348:                                         exp = AstFactory.newASetDifferenceBinaryExp(exp, token, readEvaluatorP2Expression());
349:                                         break;
350:
351:                                 case MUNION:
352:                                         nextToken();
353:                                         exp = AstFactory.newAMapUnionBinaryExp(exp, token, readEvaluatorP2Expression());
354:                                         break;
355:
356:                                 case PLUSPLUS:
357:                                         nextToken();
358:                                         exp = AstFactory.newAPlusPlusBinaryExp(exp, token, readEvaluatorP2Expression());
359:                                         break;
360:
361:                                 case CONCATENATE:
362:                                         nextToken();
363:                                         exp = AstFactory.newASeqConcatBinaryExp(exp, token, readEvaluatorP2Expression());
364:                                         break;
365:
366:                                 default:
367:                                         more = false;
368:                                         break;
369:                         }
370:                 }
371:
372:                 return exp;
373:         }
374:
375:         private PExp readEvaluatorP2Expression() throws ParserException,
376:                         LexException
377:         {
378:                 PExp exp = readEvaluatorP3Expression();
379:                 boolean more = true;
380:
381:•                while (more) // Left grouping
382:                 {
383:                         LexToken token = lastToken();
384:
385:•                        switch (token.type)
386:                         {
387:                                 case TIMES:
388:                                         nextToken();
389:                                         exp = AstFactory.newATimesNumericBinaryExp(exp, token, readEvaluatorP3Expression());
390:                                         break;
391:
392:                                 case DIVIDE:
393:                                         nextToken();
394:                                         exp = AstFactory.newADivideNumericBinaryExp(exp, token, readEvaluatorP3Expression());
395:                                         break;
396:
397:                                 case REM:
398:                                         nextToken();
399:                                         exp = AstFactory.newARemNumericBinaryExp(exp, token, readEvaluatorP3Expression());
400:                                         break;
401:
402:                                 case MOD:
403:                                         nextToken();
404:                                         exp = AstFactory.newAModNumericBinaryExp(exp, token, readEvaluatorP3Expression());
405:                                         break;
406:
407:                                 case DIV:
408:                                         nextToken();
409:                                         exp = AstFactory.newADivNumericBinaryExp(exp, token, readEvaluatorP3Expression());
410:                                         break;
411:
412:                                 case INTER:
413:                                         nextToken();
414:                                         exp = AstFactory.newASetIntersectBinaryExp(exp, token, readEvaluatorP3Expression());
415:                                         break;
416:
417:                                 default:
418:                                         more = false;
419:                                         break;
420:                         }
421:                 }
422:
423:                 return exp;
424:         }
425:
426:         private PExp readEvaluatorP3Expression() throws ParserException,
427:                         LexException
428:         {
429:                 PExp exp = null;
430:                 LexToken token = lastToken();
431:
432:•                if (token.is(VDMToken.INVERSE))
433:                 {
434:                         nextToken();
435:                         // Unary, so recursion OK for left grouping
436:                         exp = AstFactory.newAMapInverseUnaryExp(token.location, readEvaluatorP3Expression());
437:                 } else
438:                 {
439:                         exp = readEvaluatorP4Expression();
440:                 }
441:
442:                 return exp;
443:         }
444:
445:         private PExp readEvaluatorP4Expression() throws ParserException,
446:                         LexException
447:         {
448:                 PExp exp = readEvaluatorP5Expression();
449:                 boolean more = true;
450:
451:•                while (more)
452:                 {
453:                         LexToken token = lastToken();
454:
455:•                        switch (token.type)
456:                         {
457:                                 case DOMRESTO:
458:                                         nextToken();
459:                                         exp = AstFactory.newADomainResToBinaryExp(exp, token, readEvaluatorP5Expression());
460:                                         break;
461:
462:                                 case DOMRESBY:
463:                                         nextToken();
464:                                         exp = AstFactory.newADomainResByBinaryExp(exp, token, readEvaluatorP5Expression());
465:                                         break;
466:
467:                                 default:
468:                                         more = false;
469:                                         break;
470:                         }
471:                 }
472:
473:                 return exp;
474:         }
475:
476:         private PExp readEvaluatorP5Expression() throws ParserException,
477:                         LexException
478:         {
479:                 PExp exp = readEvaluatorP6Expression();
480:                 boolean more = true;
481:
482:•                while (more)
483:                 {
484:                         LexToken token = lastToken();
485:
486:•                        switch (token.type)
487:                         {
488:                                 case RANGERESTO:
489:                                         nextToken();
490:                                         exp = AstFactory.newARangeResToBinaryExp(exp, token, readEvaluatorP6Expression());
491:                                         break;
492:
493:                                 case RANGERESBY:
494:                                         nextToken();
495:                                         exp = AstFactory.newARangeResByBinaryExp(exp, token, readEvaluatorP6Expression());
496:                                         break;
497:
498:                                 default:
499:                                         more = false;
500:                                         break;
501:                         }
502:                 }
503:
504:                 return exp;
505:         }
506:
507:         private PExp readEvaluatorP6Expression() throws ParserException,
508:                         LexException
509:         {
510:                 PExp exp = null;
511:                 LexToken token = lastToken();
512:                 ILexLocation location = token.location;
513:
514:                 // Unary operators, so recursion OK for left grouping
515:•                switch (token.type)
516:                 {
517:                         case PLUS:
518:                                 nextToken();
519:                                 exp = AstFactory.newAUnaryPlusUnaryExp(location, readEvaluatorP6Expression());
520:                                 break;
521:
522:                         case MINUS:
523:                                 nextToken();
524:                                 exp = AstFactory.newAUnaryMinusUnaryExp(location, readEvaluatorP6Expression());
525:                                 break;
526:
527:                         case CARD:
528:                                 nextToken();
529:                                 exp = AstFactory.newACardinalityUnaryExp(location, readEvaluatorP6Expression());
530:                                 break;
531:
532:                         case DOM:
533:                                 nextToken();
534:                                 exp = AstFactory.newAMapDomainUnaryExp(location, readEvaluatorP6Expression());
535:                                 break;
536:
537:                         case LEN:
538:                                 nextToken();
539:                                 exp = AstFactory.newALenUnaryExp(location, readEvaluatorP6Expression());
540:                                 break;
541:
542:                         case POWER:
543:                                 nextToken();
544:                                 exp = AstFactory.newAPowerSetUnaryExp(location, readEvaluatorP6Expression());
545:                                 break;
546:
547:                         case RNG:
548:                                 nextToken();
549:                                 exp = AstFactory.newAMapRangeUnaryExp(location, readEvaluatorP6Expression());
550:                                 break;
551:
552:                         case ELEMS:
553:                                 nextToken();
554:                                 exp = AstFactory.newAElementsUnaryExp(location, readEvaluatorP6Expression());
555:                                 break;
556:
557:                         case ABS:
558:                                 nextToken();
559:                                 exp = AstFactory.newAAbsoluteUnaryExp(location, readEvaluatorP6Expression());
560:                                 break;
561:
562:                         case DINTER:
563:                                 nextToken();
564:                                 exp = AstFactory.newADistIntersectUnaryExp(location, readEvaluatorP6Expression());
565:                                 break;
566:
567:                         case MERGE:
568:                                 nextToken();
569:                                 exp = AstFactory.newADistMergeUnaryExp(location, readEvaluatorP6Expression());
570:                                 break;
571:
572:                         case HEAD:
573:                                 nextToken();
574:                                 exp = AstFactory.newAHeadUnaryExp(location, readEvaluatorP6Expression());
575:                                 break;
576:
577:                         case TAIL:
578:                                 nextToken();
579:                                 exp = AstFactory.newATailUnaryExp(location, readEvaluatorP6Expression());
580:                                 break;
581:
582:                         case REVERSE:
583:•                                if (Settings.release == Release.CLASSIC)
584:                                 {
585:                                         throwMessage(2291, "'reverse' not available in VDM classic");
586:                                 }
587:
588:                                 nextToken();
589:                                 exp = AstFactory.newAReverseUnaryExp(location, readEvaluatorP6Expression());
590:                                 break;
591:
592:                         case FLOOR:
593:                                 nextToken();
594:                                 exp = AstFactory.newAFloorUnaryExp(location, readEvaluatorP6Expression());
595:                                 break;
596:
597:                         case DUNION:
598:                                 nextToken();
599:                                 exp = AstFactory.newADistUnionUnaryExp(location, readEvaluatorP6Expression());
600:                                 break;
601:
602:                         case DISTCONC:
603:                                 nextToken();
604:                                 exp = AstFactory.newADistConcatUnaryExp(location, readEvaluatorP6Expression());
605:                                 break;
606:
607:                         case INDS:
608:                                 nextToken();
609:                                 exp = AstFactory.newAIndicesUnaryExp(location, readEvaluatorP6Expression());
610:                                 break;
611:
612:                         default:
613:                                 exp = readApplicatorExpression();
614:                                 break;
615:                 }
616:
617:                 return exp;
618:         }
619:
620:         // Applicator Family. Left grouping(?)
621:
622:         private PExp readApplicatorExpression() throws ParserException,
623:                         LexException
624:         {
625:                 PExp exp = readAnnotatedExpression();
626:                 PAnnotation annotation = null;
627:                 
628:•                if (exp instanceof AAnnotatedUnaryExp)
629:                 {
630:                         // Remember and re-apply the annotation while exp is rewired.
631:                         AAnnotatedUnaryExp ae = (AAnnotatedUnaryExp)exp;
632:                         annotation = ae.getAnnotation();
633:                         exp = ae.getExp();
634:                 }
635:
636:                 boolean more = true;
637:
638:•                while (more)
639:                 {
640:                         LexToken token = lastToken();
641:
642:•                        switch (token.type)
643:                         {
644:                                 case BRA:
645:                                         // Either sequence(from, ..., to) or func(args) or map(key)
646:                                         // or mk_*(), is_*(), mu(), pre_*(), post_*(),
647:                                         // init_*() or inv_*()
648:
649:•                                        if (nextToken().is(VDMToken.KET))
650:                                         {
651:•                                                if (exp instanceof AVariableExp)
652:                                                 {
653:                                                         AVariableExp ve = (AVariableExp) exp;
654:                                                         String name = ve.getName().getName();
655:
656:•                                                        if (name.startsWith("mk_"))
657:                                                         {
658:                                                                 // a mk_TYPE() with no field values
659:                                                                 exp = readMkExpression(ve);
660:                                                                 break;
661:                                                         }
662:                                                 }
663:
664:                                                 exp = AstFactory.newAApplyExp(exp);
665:                                                 nextToken();
666:                                         } else
667:                                         {
668:•                                                if (exp instanceof AVariableExp)
669:                                                 {
670:                                                         AVariableExp ve = (AVariableExp) exp;
671:                                                         String name = ve.getName().getName();
672:
673:•                                                        if (name.equals("mu"))
674:                                                         {
675:                                                                 exp = readMuExpression(ve);
676:                                                                 break;
677:•                                                        } else if (name.startsWith("mk_"))
678:                                                         {
679:                                                                 exp = readMkExpression(ve);
680:                                                                 break;
681:•                                                        } else if (name.startsWith("is_"))
682:                                                         {
683:                                                                 exp = readIsExpression(ve);
684:                                                                 break;
685:•                                                        } else if (name.equals("pre_"))
686:                                                         {
687:                                                                 exp = readPreExpression(ve);
688:                                                                 break;
689:•                                                        } else if (name.equals("narrow_"))
690:                                                         {
691:•                                                                if (Settings.release == Release.CLASSIC)
692:                                                                 {
693:                                                                         throwMessage(2303, "Narrow not available in VDM classic", ve.getName());
694:                                                                 } else
695:                                                                 {
696:                                                                         exp = readNarrowExpression(ve);
697:                                                                 }
698:                                                                 break;
699:                                                         }
700:                                                 }
701:
702:                                                 // So we're a function/operation call, a list subsequence or
703:                                                 // a map index...
704:
705:                                                 PExp first = readExpression();
706:
707:•                                                if (lastToken().is(VDMToken.COMMA))
708:                                                 {
709:                                                         reader.push();
710:
711:•                                                        if (nextToken().is(VDMToken.RANGE))
712:                                                         {
713:                                                                 nextToken();
714:                                                                 checkFor(VDMToken.COMMA, 2120, "Expecting 'e1,...,e2' in subsequence");
715:                                                                 PExp last = readExpression();
716:                                                                 checkFor(VDMToken.KET, 2121, "Expecting ')' after subsequence");
717:                                                                 reader.unpush();
718:                                                                 exp = AstFactory.newASubseqExp(exp, first, last);
719:                                                                 break;
720:                                                         }
721:
722:                                                         reader.pop(); // Not a subsequence then...
723:                                                 }
724:
725:                                                 // OK, so read a (list, of, arguments)...
726:
727:                                                 List<PExp> args = new NodeList<PExp>(null);
728:                                                 args.add(first);
729:
730:•                                                while (ignore(VDMToken.COMMA))
731:                                                 {
732:                                                         args.add(readExpression());
733:                                                 }
734:
735:                                                 checkFor(VDMToken.KET, 2122, "Expecting ')' after function args");
736:                                                 exp = AstFactory.newAApplyExp(exp, args);
737:                                         }
738:                                         break;
739:
740:                                 case SEQ_OPEN:
741:                                         // Polymorphic function instantiation
742:                                         List<PType> types = new Vector<PType>();
743:                                         TypeReader tr = getTypeReader();
744:
745:                                         nextToken();
746:                                         types.add(tr.readType());
747:
748:•                                        while (ignore(VDMToken.COMMA))
749:                                         {
750:                                                 types.add(tr.readType());
751:                                         }
752:
753:                                         checkFor(VDMToken.SEQ_CLOSE, 2123, "Expecting ']' after function instantiation");
754:                                         exp = AstFactory.newAFuncInstatiationExp(exp, types);
755:                                         break;
756:
757:                                 case POINT:
758:                                         // Field selection by name or number
759:•                                        switch (nextToken().type)
760:                                         {
761:                                                 case NAME:
762:•                                                        if (dialect != Dialect.VDM_SL)
763:                                                         {
764:                                                                 exp = AstFactory.newAFieldExp(exp, lastNameToken());
765:                                                         } else
766:                                                         {
767:                                                                 throwMessage(2030, "Expecting simple field identifier");
768:                                                         }
769:                                                         break;
770:
771:                                                 case IDENTIFIER:
772:                                                         exp = AstFactory.newAFieldExp(exp, lastIdToken());
773:                                                         break;
774:
775:                                                 case HASH:
776:•                                                        if (nextToken().isNot(VDMToken.NUMBER))
777:                                                         {
778:                                                                 throwMessage(2031, "Expecting field number after .#");
779:                                                         }
780:
781:                                                         LexIntegerToken num = (LexIntegerToken) lastToken();
782:                                                         exp = AstFactory.newAFieldNumberExp(exp, num);
783:                                                         break;
784:
785:                                                 default:
786:                                                         throwMessage(2032, "Expecting field name");
787:                                         }
788:
789:                                         nextToken();
790:                                         break;
791:
792:                                 default:
793:                                         more = false;
794:                                         break;
795:                         }
796:                 }
797:
798:                 // If we've collected as many applicators as we can, but we're still
799:                 // just a variable, this is a bare variable expression. In VDM++, these
800:                 // are always qualified (ie. x refers to C`x where it was declared, not
801:                 // an overriding version lower down).
802:
803:•                if (exp instanceof AVariableExp)
804:                 {
805:                         AVariableExp ve = (AVariableExp) exp;
806:                         ve.setName(ve.getName().getExplicit(true));
807:                 }
808:
809:                 // Combinator Family. Right grouping.
810:                 LexToken token = lastToken();
811:
812:•                if (token.is(VDMToken.COMP))
813:                 {
814:                         nextToken();
815:                         exp = AstFactory.newACompBinaryExp(exp, token, readApplicatorExpression());
816:                 }
817:•                else if (token.is(VDMToken.STARSTAR))
818:                 {
819:                         nextToken();
820:                         exp = AstFactory.newAStarStarBinaryExp(exp, token, readEvaluatorP6Expression());
821:                 }
822:                 
823:•                if (annotation != null)
824:                 {
825:                         // Re-apply annotation, now that exp has been rewired.
826:                         exp = AstFactory.newAAnnotatedUnaryExp(exp.getLocation(), annotation, exp);
827:                 }
828:
829:                 return exp;
830:         }
831:
832:         private PExp readAnnotatedExpression() throws ParserException, LexException
833:         {
834:                 ILexCommentList comments = getComments();
835:                 List<PAnnotation> annotations = readAnnotations(comments);
836:                 PExp body = null;
837:
838:•                if (!annotations.isEmpty())
839:                 {
840:•                        if (lastToken().isNot(VDMToken.BRA) && isBracketed(annotations))
841:                         {
842:                                 warning(5030, "Annotation is not followed by bracketed sub-expression", lastToken().location);
843:                         }
844:
845:                         beforeAnnotations(this, annotations);
846:                         body = readBasicExpression();
847:                         afterAnnotations(this, annotations, body);
848:
849:                         Collections.reverse(annotations);        // Build the chain backwards
850:                         
851:•                        for (PAnnotation annotation: annotations)
852:                         {
853:                                 body = AstFactory.newAAnnotatedUnaryExp(annotation.getName().getLocation(), annotation, body);
854:                         }
855:                 }
856:                 else
857:                 {
858:                         body = readBasicExpression();
859:                 }
860:                 
861:                 body.setComments(comments);
862:                 return body;
863:         }
864:
865:         private boolean isBracketed(List<PAnnotation> annotations)
866:         {
867:•                for (PAnnotation annotation: annotations)
868:                 {
869:•                        if (annotation.getImpl().isBracketed())
870:                         {
871:                                 return true;
872:                         }
873:                 }
874:
875:                 return false;
876:         }
877:
878:         private PExp readBasicExpression() throws ParserException, LexException
879:         {
880:                 LexToken token = lastToken();
881:
882:•                switch (token.type)
883:                 {
884:                         case NUMBER:
885:                                 nextToken();
886:                                 return AstFactory.newAIntLiteralExp((LexIntegerToken) token);
887:
888:                         case REALNUMBER:
889:                                 nextToken();
890:                                 return AstFactory.newARealLiteralExp((LexRealToken) token);
891:
892:                         case NAME:
893:                                 // Includes mk_ constructors
894:                                 LexNameToken name = lastNameToken();
895:                                 nextToken();
896:                                 return AstFactory.newAVariableExp(name);
897:
898:                         case IDENTIFIER:
899:                                 // Includes mk_ constructors
900:                                 // Note we can't use lastNameToken as this checks that we don't
901:                                 // use old~ names.
902:                                 LexNameToken id = new LexNameToken(reader.currentModule, (LexIdentifierToken) token);
903:                                 nextToken();
904:                                 return AstFactory.newAVariableExp(id);
905:
906:                         case STRING:
907:                                 nextToken();
908:                                 return AstFactory.newAStringLiteralExp((LexStringToken) token);
909:
910:                         case CHARACTER:
911:                                 nextToken();
912:                                 return AstFactory.newACharLiteralExp((LexCharacterToken) token);
913:
914:                         case QUOTE:
915:                                 nextToken();
916:                                 return AstFactory.newAQuoteLiteralExp((LexQuoteToken) token);
917:
918:                         case TRUE:
919:                         case FALSE:
920:                                 nextToken();
921:                                 return AstFactory.newABooleanConstExp((LexBooleanToken) token);
922:
923:                         case UNDEFINED:
924:                                 nextToken();
925:                                 return AstFactory.newAUndefinedExp(token.location);
926:                                 // return new UndefinedExpression(token.location);
927:
928:                         case NIL:
929:                                 nextToken();
930:                                 return AstFactory.newANilExp(token.location);
931:
932:                         case THREADID:
933:                                 nextToken();
934:                                 return AstFactory.newAThreadIdExp(token.location);
935:
936:                         case BRA:
937:                                 nextToken();
938:                                 PExp exp = readExpression();
939:                                 checkFor(VDMToken.KET, 2124, "Expecting ')'");
940:                                 return exp;
941:
942:                         case SET_OPEN:
943:                                 nextToken();
944:                                 return readSetOrMapExpression(token.location);
945:
946:                         case SEQ_OPEN:
947:                                 nextToken();
948:                                 return readSeqExpression(token.location);
949:
950:                         case FORALL:
951:                                 nextToken();
952:                                 return readForAllExpression(token.location);
953:
954:                         case EXISTS:
955:                                 nextToken();
956:                                 return readExistsExpression(token.location);
957:
958:                         case EXISTS1:
959:                                 nextToken();
960:                                 return readExists1Expression(token.location);
961:
962:                         case IOTA:
963:                                 nextToken();
964:                                 return readIotaExpression(token.location);
965:
966:                         case LAMBDA:
967:                                 nextToken();
968:                                 return readLambdaExpression(token.location);
969:
970:                         case IF:
971:                                 nextToken();
972:                                 return readIfExpression(token.location);
973:
974:                         case CASES:
975:                                 nextToken();
976:                                 return readCasesExpression(token.location);
977:
978:                         case LET:
979:                                 nextToken();
980:                                 return readLetExpression(token.location);
981:
982:                         case DEF:
983:                                 nextToken();
984:                                 return readDefExpression(token.location);
985:
986:                         case NEW:
987:                                 nextToken();
988:                                 return readNewExpression(token.location);
989:
990:                         case SELF:
991:                                 nextToken();
992:                                 return AstFactory.newASelfExp(token.location);
993:
994:                         case ISOFBASECLASS:
995:                                 nextToken();
996:                                 return readIsOfBaseExpression(token.location);
997:
998:                         case ISOFCLASS:
999:                                 nextToken();
1000:                                 return readIsOfClassExpression(token.location);
1001:
1002:                         case SAMEBASECLASS:
1003:                                 nextToken();
1004:                                 return readSameBaseExpression(token.location);
1005:
1006:                         case SAMECLASS:
1007:                                 nextToken();
1008:                                 return readSameClassExpression(token.location);
1009:
1010:                         case REQ:
1011:                         case ACT:
1012:                         case FIN:
1013:                         case ACTIVE:
1014:                         case WAITING:
1015:                                 return readHistoryExpression(token.location);
1016:
1017:                         case TIME:
1018:                                 return readTimeExpression(token.location);
1019:
1020:                         default:
1021:                                 throwMessage(2034, "Unexpected token in expression: " + token.type);
1022:                                 return null;
1023:                 }
1024:         }
1025:
1026:         private PExp readTimeExpression(ILexLocation location) throws LexException
1027:         {
1028:                 nextToken();
1029:                 return AstFactory.newATimeExp(location);
1030:         }
1031:
1032:         private AMuExp readMuExpression(AVariableExp ve) throws ParserException,
1033:                         LexException
1034:         {
1035:                 List<ARecordModifier> args = new Vector<ARecordModifier>();
1036:                 PExp record = readExpression();
1037:
1038:                 do
1039:                 {
1040:                         checkFor(VDMToken.COMMA, 2128, "Expecting comma separated record modifiers");
1041:                         LexIdentifierToken id = readIdToken("Expecting <identifier> |-> <expression>", true);
1042:                         checkFor(VDMToken.MAPLET, 2129, "Expecting <identifier> |-> <expression>");
1043:                         args.add(AstFactory.newARecordModifier(id, readExpression()));
1044:•                } while (lastToken().is(VDMToken.COMMA));
1045:
1046:                 checkFor(VDMToken.KET, 2130, "Expecting ')' after mu maplets");
1047:                 return AstFactory.newAMuExp(ve.getLocation(), record, args);
1048:         }
1049:
1050:         private PExp readMkExpression(AVariableExp ve) throws ParserException,
1051:                         LexException
1052:         {
1053:                 List<PExp> args = new NodeList<PExp>(null);
1054:
1055:•                if (lastToken().isNot(VDMToken.KET)) // NB. mk_T() is legal
1056:                 {
1057:                         args.add(readExpression());
1058:
1059:•                        while (ignore(VDMToken.COMMA))
1060:                         {
1061:                                 args.add(readExpression());
1062:                         }
1063:                 }
1064:
1065:                 checkFor(VDMToken.KET, 2131, "Expecting ')' after mk_ tuple");
1066:                 PExp exp = null;
1067:
1068:•                if (ve.getName().getName().equals("mk_"))
1069:                 {
1070:•                        if (args.size() < 2)
1071:                         {
1072:                                 throwMessage(2035, "Tuple must have >1 argument");
1073:                         }
1074:
1075:                         exp = AstFactory.newATupleExp(ve.getLocation(), args);
1076:                 } else
1077:                 {
1078:                         LexNameToken typename = getMkTypeName(ve.getName());
1079:                         VDMToken type = VDMToken.lookup(typename.name, Dialect.VDM_SL);
1080:
1081:•                        if (type != null)
1082:                         {
1083:•                                if (args.size() != 1)
1084:                                 {
1085:                                         throwMessage(2300, "mk_<type> must have a single argument");
1086:                                 }
1087:
1088:                                 PExp value = args.get(0);
1089:
1090:•                                if (type == VDMToken.TOKEN)
1091:                                 {
1092:                                         exp = AstFactory.newAMkBasicExp(AstFactory.newATokenBasicType(ve.getLocation()), value);
1093:                                 }
1094:                                 else
1095:                                 {
1096:                                         throwMessage(2036, "Expecting mk_token");
1097:                                 }
1098:                         } else
1099:                         {
1100:                                 exp = AstFactory.newAMkTypeExp(typename, args);
1101:                         }
1102:                 }
1103:
1104:                 return exp;
1105:         }
1106:
1107:         private LexNameToken getMkTypeName(ILexNameToken mktoken)
1108:                         throws ParserException, LexException
1109:         {
1110:                 String typename = mktoken.getName().substring(3); // mk_... or is_...
1111:                 String[] parts = typename.split("`");
1112:
1113:•                switch (parts.length)
1114:                 {
1115:                         case 1:
1116:                                 return new LexNameToken(getCurrentModule(), parts[0], mktoken.getLocation());
1117:
1118:                         case 2:
1119:                                 return new LexNameToken(parts[0], parts[1], mktoken.getLocation(), false, true);
1120:
1121:                         default:
1122:                                 throwMessage(2037, "Malformed mk_<type> name " + typename);
1123:                 }
1124:
1125:                 return null;
1126:         }
1127:
1128:         private AIsExp readIsExpression(AVariableExp ve) throws ParserException,
1129:                         LexException
1130:         {
1131:                 String name = ve.getName().getName();
1132:                 AIsExp exp = null;
1133:
1134:•                if (name.equals("is_"))
1135:                 {
1136:                         PExp test = readExpression();
1137:                         checkFor(VDMToken.COMMA, 2132, "Expecting is_(expression, type)");
1138:                         TypeReader tr = getTypeReader();
1139:                         PType type = tr.readType();
1140:
1141:•                        if (type instanceof AUnresolvedType)
1142:                         {
1143:                                 AUnresolvedType nt = (AUnresolvedType) type;
1144:                                 exp = AstFactory.newAIsExp(ve.getLocation(), nt.getName(), test);
1145:                         } else
1146:                         {
1147:                                 exp = AstFactory.newAIsExp(ve.getLocation(), type, test);
1148:                         }
1149:                 } else
1150:                 {
1151:                         LexNameToken typename = getMkTypeName(ve.getName());
1152:                         VDMToken type = VDMToken.lookup(typename.name, Dialect.VDM_SL);
1153:
1154:•                        if (type != null)
1155:                         {
1156:•                                switch (type)
1157:                                 {
1158:                                         case BOOL:
1159:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newABooleanBasicType(ve.getLocation()), readExpression());
1160:                                                 break;
1161:
1162:                                         case NAT:
1163:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newANatNumericBasicType(ve.getLocation()), readExpression());
1164:                                                 break;
1165:
1166:                                         case NAT1:
1167:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newANatOneNumericBasicType(ve.getLocation()), readExpression());
1168:                                                 break;
1169:
1170:                                         case INT:
1171:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newAIntNumericBasicType(ve.getLocation()), readExpression());
1172:                                                 break;
1173:
1174:                                         case RAT:
1175:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newARationalNumericBasicType(ve.getLocation()), readExpression());
1176:                                                 break;
1177:
1178:                                         case REAL:
1179:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newARealNumericBasicType(ve.getLocation()), readExpression());
1180:                                                 break;
1181:
1182:                                         case CHAR:
1183:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newACharBasicType(ve.getLocation()), readExpression());
1184:                                                 break;
1185:
1186:                                         case TOKEN:
1187:                                                 exp = AstFactory.newAIsExp(ve.getLocation(), AstFactory.newATokenBasicType(ve.getLocation()), readExpression());
1188:                                                 break;
1189:
1190:                                         default:
1191:                                                 throwMessage(2038, "Expecting is_<type>");
1192:                                 }
1193:                         } else
1194:                         {
1195:                                 exp = AstFactory.newAIsExp(ve.getLocation(), typename, readExpression());
1196:                         }
1197:                 }
1198:
1199:                 checkFor(VDMToken.KET, 2133, "Expecting ')' after is_ expression");
1200:                 return exp;
1201:         }
1202:
1203:         private PExp readNarrowExpression(AVariableExp ve) throws ParserException,
1204:                         LexException
1205:         {
1206:                 ANarrowExp exp = null;
1207:
1208:                 PExp test = readExpression();
1209:                 checkFor(VDMToken.COMMA, 2301, "Expecting narrow_(expression, type)");
1210:                 TypeReader tr = getTypeReader();
1211:                 PType type = tr.readType();
1212:
1213:•                if (type instanceof AUnresolvedType)
1214:                 {
1215:                         AUnresolvedType nt = (AUnresolvedType) type;
1216:                         exp = AstFactory.newANarrowExpression(ve.getLocation(), nt.getName(), test);
1217:                 } else
1218:                 {
1219:                         exp = AstFactory.newANarrowExpression(ve.getLocation(), type, test);
1220:                 }
1221:
1222:                 checkFor(VDMToken.KET, 2302, "Expecting ')' after narrow_ expression");
1223:
1224:                 return exp;
1225:         }
1226:
1227:         private APreExp readPreExpression(AVariableExp ve) throws ParserException,
1228:                         LexException
1229:         {
1230:                 List<PExp> args = new Vector<PExp>();
1231:                 PExp function = readExpression();
1232:
1233:•                while (ignore(VDMToken.COMMA))
1234:                 {
1235:                         args.add(readExpression());
1236:                 }
1237:
1238:                 checkFor(VDMToken.KET, 2134, "Expecting pre_(function [,args])");
1239:
1240:                 return AstFactory.newAPreExp(ve.getLocation(), function, args);
1241:         }
1242:
1243:         private PExp readSetOrMapExpression(ILexLocation start)
1244:                         throws ParserException, LexException
1245:         {
1246:                 LexToken token = lastToken();
1247:
1248:•                if (token.is(VDMToken.SET_CLOSE))
1249:                 {
1250:                         nextToken();
1251:                         return AstFactory.newASetEnumSetExp(start); // empty set
1252:•                } else if (token.is(VDMToken.MAPLET))
1253:                 {
1254:                         nextToken();
1255:                         checkFor(VDMToken.SET_CLOSE, 2135, "Expecting '}' in empty map");
1256:                         return AstFactory.newAMapEnumMapExp(start); // empty map
1257:                 }
1258:
1259:                 PExp first = readExpression();
1260:                 token = lastToken();
1261:
1262:•                if (token.is(VDMToken.MAPLET))
1263:                 {
1264:                         nextToken();
1265:                         AMapletExp maplet = AstFactory.newAMapletExp(first, token, readExpression());
1266:                         return readMapExpression(start, maplet);
1267:                 } else
1268:                 {
1269:                         return readSetExpression(start, first);
1270:                 }
1271:         }
1272:
1273:         private SSetExp readSetExpression(ILexLocation start, PExp first)
1274:                         throws ParserException, LexException
1275:         {
1276:                 SSetExp result = null;
1277:
1278:•                if (lastToken().is(VDMToken.PIPE))
1279:                 {
1280:                         nextToken();
1281:                         BindReader br = getBindReader();
1282:                         List<PMultipleBind> bindings = br.readBindList();
1283:                         PExp exp = null;
1284:
1285:•                        if (lastToken().is(VDMToken.AMPERSAND))
1286:                         {
1287:                                 nextToken();
1288:                                 exp = readExpression();
1289:                         }
1290:
1291:                         checkFor(VDMToken.SET_CLOSE, 2136, "Expecting '}' after set comprehension");
1292:                         result = AstFactory.newASetCompSetExp(start, first, bindings, exp);
1293:                 } else
1294:                 {
1295:•                        if (lastToken().is(VDMToken.COMMA))
1296:                         {
1297:                                 reader.push();
1298:
1299:•                                if (nextToken().is(VDMToken.RANGE))
1300:                                 {
1301:                                         nextToken();
1302:                                         checkFor(VDMToken.COMMA, 2137, "Expecting 'e1,...,e2' in set range");
1303:                                         PExp end = readExpression();
1304:                                         checkFor(VDMToken.SET_CLOSE, 2138, "Expecting '}' after set range");
1305:                                         reader.unpush();
1306:                                         return AstFactory.newASetRangeSetExp(start, first, end);
1307:                                 }
1308:
1309:                                 reader.pop(); // Not a set range then...
1310:                         }
1311:
1312:                         List<PExp> members = new NodeList<PExp>(null);
1313:                         members.add(first);
1314:
1315:•                        while (ignore(VDMToken.COMMA))
1316:                         {
1317:                                 members.add(readExpression());
1318:                         }
1319:
1320:                         checkFor(VDMToken.SET_CLOSE, 2139, "Expecting '}' after set enumeration");
1321:                         result = AstFactory.newASetEnumSetExp(start, members);
1322:                 }
1323:
1324:                 return result;
1325:         }
1326:
1327:         private SMapExp readMapExpression(ILexLocation start, AMapletExp first)
1328:                         throws ParserException, LexException
1329:         {
1330:                 SMapExp result = null;
1331:
1332:•                if (lastToken().is(VDMToken.PIPE))
1333:                 {
1334:                         nextToken();
1335:                         BindReader br = getBindReader();
1336:                         List<PMultipleBind> bindings = br.readBindList();
1337:                         PExp exp = null;
1338:
1339:•                        if (lastToken().is(VDMToken.AMPERSAND))
1340:                         {
1341:                                 nextToken();
1342:                                 exp = readExpression();
1343:                         }
1344:
1345:                         checkFor(VDMToken.SET_CLOSE, 2140, "Expecting '}' after map comprehension");
1346:                         result = AstFactory.newAMapCompMapExp(start, first, bindings, exp);
1347:                 } else
1348:                 {
1349:                         List<AMapletExp> members = new Vector<AMapletExp>();
1350:                         members.add(first);
1351:
1352:•                        while (ignore(VDMToken.COMMA))
1353:                         {
1354:                                 PExp member = readExpression();
1355:                                 LexToken token = lastToken();
1356:
1357:•                                if (token.is(VDMToken.MAPLET))
1358:                                 {
1359:                                         nextToken();
1360:                                         AMapletExp maplet = AstFactory.newAMapletExp(member, token, readExpression());
1361:                                         members.add(maplet);
1362:                                 } else
1363:                                 {
1364:                                         throwMessage(2039, "Expecting maplet in map enumeration");
1365:                                 }
1366:                         }
1367:
1368:                         checkFor(VDMToken.SET_CLOSE, 2141, "Expecting '}' after map enumeration");
1369:                         result = AstFactory.newAMapEnumMapExp(start, members);
1370:                 }
1371:
1372:                 return result;
1373:         }
1374:
1375:         private SSeqExp readSeqExpression(ILexLocation start)
1376:                         throws ParserException, LexException
1377:         {
1378:•                if (lastToken().is(VDMToken.SEQ_CLOSE))
1379:                 {
1380:                         nextToken();
1381:                         return AstFactory.newASeqEnumSeqExp(start);
1382:                 }
1383:
1384:                 SSeqExp result = null;
1385:                 PExp first = readExpression();
1386:
1387:•                if (lastToken().is(VDMToken.PIPE))
1388:                 {
1389:                         nextToken();
1390:                         BindReader br = getBindReader();
1391:                         PBind setbind = br.readBind();
1392:                         PExp exp = null;
1393:
1394:•                        if (lastToken().is(VDMToken.AMPERSAND))
1395:                         {
1396:                                 nextToken();
1397:                                 exp = readExpression();
1398:                         }
1399:
1400:                         checkFor(VDMToken.SEQ_CLOSE, 2142, "Expecting ']' after list comprehension");
1401:                         result = AstFactory.newASeqCompSeqExp(start, first, setbind, exp);
1402:                 }
1403:                 else
1404:                 {
1405:                         List<PExp> members = new NodeList<PExp>(null);
1406:                         members.add(first);
1407:
1408:•                        while (ignore(VDMToken.COMMA))
1409:                         {
1410:                                 members.add(readExpression());
1411:                         }
1412:
1413:                         checkFor(VDMToken.SEQ_CLOSE, 2143, "Expecting ']' after list enumeration");
1414:                         result = AstFactory.newASeqEnumSeqExp(start, members);
1415:                 }
1416:
1417:                 return result;
1418:         }
1419:
1420:         private AIfExp readIfExpression(ILexLocation start) throws ParserException,
1421:                         LexException
1422:         {
1423:                 PExp exp = readExpression();
1424:                 checkFor(VDMToken.THEN, 2144, "Missing 'then'");
1425:                 PExp thenExp = readExpression();
1426:                 List<AElseIfExp> elseList = new Vector<AElseIfExp>();
1427:
1428:•                while (lastToken().is(VDMToken.ELSEIF))
1429:                 {
1430:                         nextToken();
1431:                         elseList.add(readElseIfExpression(lastToken().location));
1432:                 }
1433:
1434:                 PExp elseExp = null;
1435:
1436:•                if (lastToken().is(VDMToken.ELSE))
1437:                 {
1438:                         nextToken();
1439:                         elseExp = readConnectiveExpression(); // Precedence < maplet?
1440:                 } else
1441:                 {
1442:                         throwMessage(2040, "Expecting 'else' in 'if' expression");
1443:                 }
1444:
1445:                 return AstFactory.newAIfExp(start, exp, thenExp, elseList, elseExp);
1446:         }
1447:
1448:         private AElseIfExp readElseIfExpression(ILexLocation start)
1449:                         throws ParserException, LexException
1450:         {
1451:                 PExp exp = readExpression();
1452:                 checkFor(VDMToken.THEN, 2145, "Missing 'then' after 'elseif'");
1453:                 PExp thenExp = readExpression();
1454:                 return AstFactory.newAElseIfExp(start, exp, thenExp);
1455:         }
1456:
1457:         private ACasesExp readCasesExpression(ILexLocation start)
1458:                         throws ParserException, LexException
1459:         {
1460:                 PExp exp = readExpression();
1461:                 checkFor(VDMToken.COLON, 2146, "Expecting ':' after cases expression");
1462:
1463:                 List<ACaseAlternative> cases = new Vector<ACaseAlternative>();
1464:                 PExp others = null;
1465:                 cases.addAll(readCaseAlternatives(exp));
1466:
1467:•                while (lastToken().is(VDMToken.COMMA))
1468:                 {
1469:•                        if (nextToken().is(VDMToken.OTHERS))
1470:                         {
1471:                                 nextToken();
1472:                                 checkFor(VDMToken.ARROW, 2147, "Expecting '->' after others");
1473:                                 others = readExpression();
1474:                                 break;
1475:                         } else
1476:                         {
1477:                                 cases.addAll(readCaseAlternatives(exp));
1478:                         }
1479:                 }
1480:
1481:                 checkFor(VDMToken.END, 2148, "Expecting ', case alternative' or 'end' after cases");
1482:                 return AstFactory.newACasesExp(start, exp, cases, others);
1483:         }
1484:
1485:         private List<ACaseAlternative> readCaseAlternatives(PExp exp)
1486:                         throws ParserException, LexException
1487:         {
1488:                 List<ACaseAlternative> alts = new Vector<ACaseAlternative>();
1489:                 List<PPattern> plist = getPatternReader().readPatternList();
1490:                 checkFor(VDMToken.ARROW, 2149, "Expecting '->' after case pattern list");
1491:                 PExp then = readExpression();
1492:
1493:•                for (PPattern p : plist)
1494:                 {
1495:                         alts.add(AstFactory.newACaseAlternative(exp.clone(), p.clone(), then.clone()));
1496:                 }
1497:
1498:                 return alts;
1499:         }
1500:
1501:         private PExp readLetExpression(ILexLocation start) throws ParserException,
1502:                         LexException
1503:         {
1504:                 ParserException letDefError = null;
1505:
1506:                 try
1507:                 {
1508:                         reader.push();
1509:                         ALetDefExp exp = readLetDefExpression(start);
1510:                         reader.unpush();
1511:                         return exp;
1512:                 } catch (ParserException e)
1513:                 {
1514:                         e.adjustDepth(reader.getTokensRead());
1515:                         reader.pop();
1516:                         letDefError = e;
1517:                 }
1518:
1519:                 try
1520:                 {
1521:                         reader.push();
1522:                         ALetBeStExp exp = readLetBeStExpression(start);
1523:                         reader.unpush();
1524:                         return exp;
1525:                 } catch (ParserException e)
1526:                 {
1527:                         e.adjustDepth(reader.getTokensRead());
1528:                         reader.pop();
1529:•                        throw e.deeperThan(letDefError) ? e : letDefError;
1530:                 }
1531:         }
1532:
1533:         private ALetDefExp readLetDefExpression(ILexLocation start)
1534:                         throws ParserException, LexException
1535:         {
1536:                 DefinitionReader dr = getDefinitionReader();
1537:
1538:                 List<PDefinition> localDefs = new Vector<PDefinition>();
1539:
1540:                 localDefs.add(dr.readLocalDefinition(NameScope.LOCAL));
1541:
1542:•                while (ignore(VDMToken.COMMA))
1543:                 {
1544:                         localDefs.add(dr.readLocalDefinition(NameScope.LOCAL));
1545:                 }
1546:
1547:                 checkFor(VDMToken.IN, 2150, "Expecting 'in' after local definitions");
1548:                 // Note we read a Connective expression for the body, so that |->
1549:                 // terminates the parse.
1550:                 return AstFactory.newALetDefExp(start, localDefs, readConnectiveExpression());
1551:         }
1552:
1553:         private ALetBeStExp readLetBeStExpression(ILexLocation start)
1554:                         throws ParserException, LexException
1555:         {
1556:                 PMultipleBind bind = getBindReader().readMultipleBind();
1557:                 PExp stexp = null;
1558:
1559:•                if (lastToken().is(VDMToken.BE))
1560:                 {
1561:                         nextToken();
1562:                         checkFor(VDMToken.ST, 2151, "Expecting 'st' after 'be' in let expression");
1563:                         stexp = readExpression();
1564:                 }
1565:
1566:                 checkFor(VDMToken.IN, 2152, "Expecting 'in' after bind in let expression");
1567:                 // Note we read a Connective expression for the body, so that |->
1568:                 // terminates the parse.
1569:                 return AstFactory.newALetBeStExp(start, bind, stexp, readConnectiveExpression());
1570:         }
1571:
1572:         private AForAllExp readForAllExpression(ILexLocation start)
1573:                         throws ParserException, LexException
1574:         {
1575:                 List<PMultipleBind> bindList = getBindReader().readBindList();
1576:                 checkFor(VDMToken.AMPERSAND, 2153, "Expecting '&' after bind list in forall");
1577:                 return AstFactory.newAForAllExp(start, bindList, readExpression());
1578:         }
1579:
1580:         private AExistsExp readExistsExpression(ILexLocation start)
1581:                         throws ParserException, LexException
1582:         {
1583:                 List<PMultipleBind> bindList = getBindReader().readBindList();
1584:                 checkFor(VDMToken.AMPERSAND, 2154, "Expecting '&' after bind list in exists");
1585:                 return AstFactory.newAExistsExp(start, bindList, readExpression());
1586:         }
1587:
1588:         private AExists1Exp readExists1Expression(ILexLocation start)
1589:                         throws ParserException, LexException
1590:         {
1591:                 PBind bind = getBindReader().readBind();
1592:                 checkFor(VDMToken.AMPERSAND, 2155, "Expecting '&' after single bind in exists1");
1593:                 return AstFactory.newAExists1Exp(start, bind, readExpression());
1594:         }
1595:
1596:         private AIotaExp readIotaExpression(ILexLocation start)
1597:                         throws ParserException, LexException
1598:         {
1599:                 PBind bind = getBindReader().readBind();
1600:                 checkFor(VDMToken.AMPERSAND, 2156, "Expecting '&' after single bind in iota");
1601:                 return AstFactory.newAIotaExp(start, bind, readExpression());
1602:         }
1603:
1604:         private ALambdaExp readLambdaExpression(ILexLocation start)
1605:                         throws ParserException, LexException
1606:         {
1607:                 List<ATypeBind> bindList = getBindReader().readTypeBindList();
1608:                 checkFor(VDMToken.AMPERSAND, 2157, "Expecting '&' after bind list in lambda");
1609:                 return AstFactory.newALambdaExp(start, bindList, readExpression());
1610:         }
1611:
1612:         private ADefExp readDefExpression(ILexLocation start)
1613:                         throws ParserException, LexException
1614:         {
1615:                 DefinitionReader dr = getDefinitionReader();
1616:                 List<PDefinition> equalsDefs = new Vector<PDefinition>();
1617:
1618:•                while (lastToken().isNot(VDMToken.IN))
1619:                 {
1620:                         equalsDefs.add(dr.readEqualsDefinition());
1621:                         ignore(VDMToken.SEMICOLON);
1622:                 }
1623:
1624:                 checkFor(VDMToken.IN, 2158, "Expecting 'in' after equals definitions");
1625:                 return AstFactory.newADefExp(start, equalsDefs, readExpression());
1626:         }
1627:
1628:         private ANewExp readNewExpression(ILexLocation start)
1629:                         throws ParserException, LexException
1630:         {
1631:                 LexIdentifierToken name = readIdToken("Expecting class name after 'new'");
1632:                 checkFor(VDMToken.BRA, 2159, "Expecting '(' after new class name");
1633:
1634:                 List<PExp> args = new NodeList<PExp>(null);
1635:                 ExpressionReader er = getExpressionReader();
1636:
1637:•                if (lastToken().isNot(VDMToken.KET))
1638:                 {
1639:                         args.add(er.readExpression());
1640:
1641:•                        while (ignore(VDMToken.COMMA))
1642:                         {
1643:                                 args.add(er.readExpression());
1644:                         }
1645:                 }
1646:
1647:                 checkFor(VDMToken.KET, 2124, "Expecting ')' after constructor args");
1648:                 return AstFactory.newANewExp(start, name, args);
1649:         }
1650:
1651:         private AIsOfBaseClassExp readIsOfBaseExpression(ILexLocation start)
1652:                         throws ParserException, LexException
1653:         {
1654:                 checkFor(VDMToken.BRA, 2160, "Expecting '(' after 'isofbase'");
1655:                 List<PExp> args = readExpressionList();
1656:                 checkFor(VDMToken.KET, 2161, "Expecting ')' after 'isofbase' args");
1657:
1658:•                if (args.size() != 2)
1659:                 {
1660:                         throwMessage(2041, "Expecting two arguments for 'isofbase'");
1661:                 }
1662:
1663:•                if (!(args.get(0) instanceof AVariableExp))
1664:                 {
1665:                         throwMessage(2042, "Expecting (<class>,<exp>) arguments for 'isofbase'");
1666:                 }
1667:
1668:                 ILexNameToken classname = ((AVariableExp) args.get(0)).getName();
1669:
1670:•                if (classname.getOld())
1671:                 {
1672:                         throwMessage(2295, "Can't use old name here", classname);
1673:                 }
1674:
1675:                 return AstFactory.newAIsOfBaseClassExp(start, classname, args.get(1));
1676:         }
1677:
1678:         private AIsOfClassExp readIsOfClassExpression(ILexLocation start)
1679:                         throws ParserException, LexException
1680:         {
1681:                 checkFor(VDMToken.BRA, 2162, "Expecting '(' after 'isofclass'");
1682:                 List<PExp> args = readExpressionList();
1683:                 checkFor(VDMToken.KET, 2163, "Expecting ')' after 'isofclass' args");
1684:
1685:•                if (args.size() != 2)
1686:                 {
1687:                         throwMessage(2043, "Expecting two arguments for 'isofclass'");
1688:                 }
1689:
1690:•                if (!(args.get(0) instanceof AVariableExp))
1691:                 {
1692:                         throwMessage(2044, "Expecting (<class>,<exp>) arguments for 'isofclass'");
1693:                 }
1694:
1695:                 ILexNameToken classname = ((AVariableExp) args.get(0)).getName();
1696:
1697:•                if (classname.getOld())
1698:                 {
1699:                         throwMessage(2295, "Can't use old name here", classname);
1700:                 }
1701:
1702:                 return AstFactory.newAIsOfClassExp(start, classname, args.get(1));
1703:         }
1704:
1705:         private ASameBaseClassExp readSameBaseExpression(ILexLocation start)
1706:                         throws ParserException, LexException
1707:         {
1708:                 checkFor(VDMToken.BRA, 2164, "Expecting '(' after 'samebaseclass'");
1709:                 List<PExp> args = readExpressionList();
1710:                 checkFor(VDMToken.KET, 2165, "Expecting ')' after 'samebaseclass' args");
1711:
1712:•                if (args.size() != 2)
1713:                 {
1714:                         throwMessage(2045, "Expecting two expressions in 'samebaseclass'");
1715:                 }
1716:
1717:                 return AstFactory.newASameBaseClassExp(start, args);
1718:         }
1719:
1720:         private ASameClassExp readSameClassExpression(ILexLocation start)
1721:                         throws ParserException, LexException
1722:         {
1723:                 checkFor(VDMToken.BRA, 2166, "Expecting '(' after 'sameclass'");
1724:                 List<PExp> args = readExpressionList();
1725:                 checkFor(VDMToken.KET, 2167, "Expecting ')' after 'sameclass' args");
1726:
1727:•                if (args.size() != 2)
1728:                 {
1729:                         throwMessage(2046, "Expecting two expressions in 'sameclass'");
1730:                 }
1731:
1732:                 return AstFactory.newASameClassExp(start, args);
1733:         }
1734:
1735:         private boolean inPerExpression = false;
1736:
1737:         public PExp readPerExpression() throws ParserException, LexException
1738:         {
1739:                 inPerExpression = true;
1740:                 PExp e = readExpression();
1741:                 inPerExpression = false;
1742:                 return e;
1743:         }
1744:
1745:         private PExp readHistoryExpression(ILexLocation location)
1746:                         throws ParserException, LexException
1747:         {
1748:•                if (!inPerExpression)
1749:                 {
1750:                         throwMessage(2047, "Can't use history expression here");
1751:                 }
1752:
1753:                 LexToken op = lastToken();
1754:                 String s = op.type.toString().toLowerCase();
1755:
1756:•                switch (op.type)
1757:                 {
1758:                         case ACT:
1759:                         case FIN:
1760:                         case ACTIVE:
1761:                         case REQ:
1762:                         case WAITING:
1763:                                 nextToken();
1764:                                 checkFor(VDMToken.BRA, 2168, "Expecting " + s + "(name(s))");
1765:
1766:                                 LexNameList opnames = new LexNameList();
1767:                                 LexNameToken opname = readNameToken("Expecting a name");
1768:                                 opnames.add(opname);
1769:
1770:•                                while (ignore(VDMToken.COMMA))
1771:                                 {
1772:                                         opname = readNameToken("Expecting " + s + "(name(s))");
1773:                                         opnames.add(opname);
1774:                                 }
1775:
1776:                                 checkFor(VDMToken.KET, 2169, "Expecting " + s + "(name(s))");
1777:                                 return AstFactory.newAHistoryExp(location, op, opnames);
1778:
1779:                         default:
1780:                                 throwMessage(2048, "Expecting #act, #active, #fin, #req or #waiting");
1781:                                 return null;
1782:                 }
1783:         }
1784: }