|
Added
Link Here
|
| 1 |
--/** |
| 2 |
-- * <copyright> |
| 3 |
-- * |
| 4 |
-- * Copyright (c) 2005, 2009 IBM Corporation and others. |
| 5 |
-- * All rights reserved. This program and the accompanying materials |
| 6 |
-- * are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
-- * which accompanies this distribution, and is available at |
| 8 |
-- * http://www.eclipse.org/legal/epl-v10.html |
| 9 |
-- * |
| 10 |
-- * Contributors: |
| 11 |
-- * See (or edit) Notice Declaration below |
| 12 |
-- * |
| 13 |
-- * </copyright> |
| 14 |
-- * |
| 15 |
-- * $Id: EssentialOCL.g,v 1.16 2009/11/09 22:03:57 ewillink Exp $ |
| 16 |
-- */ |
| 17 |
-- |
| 18 |
-- The EssentialOCL Parser |
| 19 |
-- |
| 20 |
|
| 21 |
|
| 22 |
%Define |
| 23 |
|
| 24 |
-- Definition of macros used in the parser template |
| 25 |
-- |
| 26 |
$prs_stream_class /.AbstractOCLParser./ |
| 27 |
$prs_parser_class /.DeterministicParser./ |
| 28 |
$prs_parser_exception /.NotDeterministicParseTableException./ |
| 29 |
$prs_parser_throw /.throw new RuntimeException("****Error: Regenerate $prs_type.java with -NOBACKTRACK option")./ |
| 30 |
$prs_parse_args /../ |
| 31 |
$lex_stream_class /.AbstractLexer./ |
| 32 |
$action_class /.$file_prefix./ |
| 33 |
$copyright_contributions /.*./ |
| 34 |
|
| 35 |
-- package namespace of the LPG Runtime API |
| 36 |
$lpg_ns /.lpg.runtime./ |
| 37 |
|
| 38 |
$NewCase |
| 39 |
/. $Header |
| 40 |
case $rule_number:./ |
| 41 |
|
| 42 |
-- From bt/dtParserTemplateD.g |
| 43 |
------------------------------------------------------ |
| 44 |
$Header |
| 45 |
/. |
| 46 |
// |
| 47 |
// Rule $rule_number: $rule_text |
| 48 |
//./ |
| 49 |
|
| 50 |
$BeginAction |
| 51 |
/. $Header |
| 52 |
case $rule_number: {./ |
| 53 |
|
| 54 |
$EndAction |
| 55 |
/. break; |
| 56 |
}./ |
| 57 |
|
| 58 |
$BeginJava |
| 59 |
/../ |
| 60 |
|
| 61 |
$EndJava |
| 62 |
/../ |
| 63 |
|
| 64 |
$BeginCode |
| 65 |
/.$BeginAction |
| 66 |
$symbol_declarations./ |
| 67 |
|
| 68 |
$EndCode /.$EndAction./ |
| 69 |
|
| 70 |
$NoAction |
| 71 |
/. $Header |
| 72 |
case $rule_number: |
| 73 |
break;./ |
| 74 |
|
| 75 |
$NullAction |
| 76 |
/. $Header |
| 77 |
case $rule_number: |
| 78 |
$setResult(null); |
| 79 |
break;./ |
| 80 |
|
| 81 |
-- Deprecated, code inline with correct generic parameter type |
| 82 |
$EmptyListAction |
| 83 |
/. $Header |
| 84 |
case $rule_number: |
| 85 |
$setResult(new BasicEList<Object>()); |
| 86 |
break;./ |
| 87 |
|
| 88 |
$BeginActions |
| 89 |
/. |
| 90 |
@SuppressWarnings("unchecked") |
| 91 |
public void ruleAction(int ruleNumber) |
| 92 |
{ |
| 93 |
switch (ruleNumber) { |
| 94 |
./ |
| 95 |
|
| 96 |
$EndActions |
| 97 |
/. |
| 98 |
default: |
| 99 |
break; |
| 100 |
} |
| 101 |
return; |
| 102 |
}./ |
| 103 |
|
| 104 |
$additional_interfaces /../ |
| 105 |
$action_class /.$file_prefix./ |
| 106 |
$setSym1 /.dtParser.setSym1./ |
| 107 |
$setResult /.dtParser.setSym1./ |
| 108 |
$getSym /.dtParser.getSym./ |
| 109 |
$getToken /.dtParser.getToken./ |
| 110 |
$getIToken /.getIToken./ |
| 111 |
$getLeftSpan /.dtParser.getFirstToken./ |
| 112 |
$getRightSpan /.dtParser.getLastToken./ |
| 113 |
$prs_stream /.prsStream./ |
| 114 |
|
| 115 |
-- modified to include throwing exceptions |
| 116 |
$parserCore |
| 117 |
/. |
| 118 |
public class $action_class extends $prs_stream_class implements RuleAction$additional_interfaces |
| 119 |
{ |
| 120 |
protected static ParseTable prs = new $prs_type(); |
| 121 |
private $prs_parser_class dtParser; |
| 122 |
|
| 123 |
public $action_class($lex_stream_class lexer) { |
| 124 |
super(lexer); |
| 125 |
} |
| 126 |
|
| 127 |
public int getEOFTokenKind() { return $prs_type.EOFT_SYMBOL; } |
| 128 |
|
| 129 |
public $environment_class getOCLEnvironment() { |
| 130 |
return getLexer().getOCLEnvironment(); |
| 131 |
} |
| 132 |
|
| 133 |
@Override |
| 134 |
public $lex_stream_class getLexer() { |
| 135 |
return ($lex_stream_class)super.getLexer(); |
| 136 |
} |
| 137 |
|
| 138 |
public String getTokenKindName(int kind) { return $sym_type.orderedTerminalSymbols[kind]; } |
| 139 |
|
| 140 |
@Override |
| 141 |
public String[] orderedTerminalSymbols() { return $sym_type.orderedTerminalSymbols; } |
| 142 |
|
| 143 |
@SuppressWarnings("nls") |
| 144 |
@Override |
| 145 |
public $ast_type parseTokensToCST(Monitor monitor, int error_repair_count) { |
| 146 |
ParseTable prsTable = new $prs_type(); |
| 147 |
|
| 148 |
try { |
| 149 |
dtParser = new $prs_parser_class(monitor, this, prsTable, this); |
| 150 |
} |
| 151 |
catch ($prs_parser_exception e) { |
| 152 |
$prs_parser_throw; |
| 153 |
} |
| 154 |
catch (BadParseSymFileException e) { |
| 155 |
throw new RuntimeException("****Error: Bad Parser Symbol File -- $sym_type.java. Regenerate $prs_type.java"); |
| 156 |
} |
| 157 |
|
| 158 |
try { |
| 159 |
return ($ast_type) dtParser.parse($prs_parse_args); |
| 160 |
} |
| 161 |
catch (BadParseException e) { |
| 162 |
reset(e.error_token); // point to error token |
| 163 |
|
| 164 |
DiagnoseParser diagnoseParser = new DiagnoseParser(this, prsTable); |
| 165 |
diagnoseParser.diagnose(e.error_token); |
| 166 |
} |
| 167 |
|
| 168 |
return null; |
| 169 |
} |
| 170 |
|
| 171 |
/** |
| 172 |
* Initializes a concrete-syntax node's start and end offsets from the |
| 173 |
* current token in the parser stream. |
| 174 |
* |
| 175 |
* @param cstNode a concrete-syntax node |
| 176 |
* |
| 177 |
* @since 1.2 |
| 178 |
*/ |
| 179 |
protected void setOffsets(CSTNode cstNode) { |
| 180 |
IToken firstToken = getIToken($getToken(1)); |
| 181 |
cstNode.setStartToken(firstToken); |
| 182 |
cstNode.setEndToken(firstToken); |
| 183 |
cstNode.setStartOffset(firstToken.getStartOffset()); |
| 184 |
cstNode.setEndOffset(firstToken.getEndOffset()-1); |
| 185 |
} |
| 186 |
./ |
| 187 |
%End |
| 188 |
|
| 189 |
%Notice |
| 190 |
/./** |
| 191 |
* Essential OCL Grammar |
| 192 |
* <copyright> |
| 193 |
* |
| 194 |
* Copyright (c) 2005, 2009 IBM Corporation and others. |
| 195 |
* All rights reserved. This program and the accompanying materials |
| 196 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 197 |
* which accompanies this distribution, and is available at |
| 198 |
* http://www.eclipse.org/legal/epl-v10.html |
| 199 |
* |
| 200 |
* Contributors: |
| 201 |
* IBM - Initial API and implementation |
| 202 |
* E.D.Willink - Elimination of some shift-reduce conflicts |
| 203 |
* E.D.Willink - Remove unnecessary warning suppression |
| 204 |
* E.D.Willink - Bugs 184048, 225493, 243976, 259818, 282882, 287993, 288040, 292112 |
| 205 |
* Borland - Bug 242880 |
| 206 |
* Adolfo Sanchez-Barbudo Herrera (Open Canarias) - LPG v 2.0.17 adoption (242153) |
| 207 |
$copyright_contributions |
| 208 |
* </copyright> |
| 209 |
* |
| 210 |
* $Id: EssentialOCL.g,v 1.16 2009/11/09 22:03:57 ewillink Exp $ |
| 211 |
*/ |
| 212 |
./ |
| 213 |
%End |
| 214 |
|
| 215 |
%Globals |
| 216 |
/.import org.eclipse.emf.common.util.BasicEList; |
| 217 |
import org.eclipse.emf.common.util.EList; |
| 218 |
import org.eclipse.ocl.cst.BooleanLiteralExpCS; |
| 219 |
import org.eclipse.ocl.cst.CSTNode; |
| 220 |
import org.eclipse.ocl.cst.CallExpCS; |
| 221 |
import org.eclipse.ocl.cst.CollectionLiteralExpCS; |
| 222 |
import org.eclipse.ocl.cst.CollectionLiteralPartCS; |
| 223 |
import org.eclipse.ocl.cst.CollectionTypeCS; |
| 224 |
import org.eclipse.ocl.cst.CollectionTypeIdentifierEnum; |
| 225 |
import org.eclipse.ocl.cst.FeatureCallExpCS; |
| 226 |
import org.eclipse.ocl.cst.IfExpCS; |
| 227 |
import org.eclipse.ocl.cst.IntegerLiteralExpCS; |
| 228 |
import org.eclipse.ocl.cst.InvalidLiteralExpCS; |
| 229 |
import org.eclipse.ocl.cst.IsMarkedPreCS; |
| 230 |
import org.eclipse.ocl.cst.IterateExpCS; |
| 231 |
import org.eclipse.ocl.cst.IteratorExpCS; |
| 232 |
import org.eclipse.ocl.cst.LetExpCS; |
| 233 |
import org.eclipse.ocl.cst.NullLiteralExpCS; |
| 234 |
import org.eclipse.ocl.cst.OCLExpressionCS; |
| 235 |
import org.eclipse.ocl.cst.OperationCallExpCS; |
| 236 |
import org.eclipse.ocl.cst.PathNameCS; |
| 237 |
import org.eclipse.ocl.cst.PrimitiveTypeCS; |
| 238 |
import org.eclipse.ocl.cst.RealLiteralExpCS; |
| 239 |
import org.eclipse.ocl.cst.SimpleNameCS; |
| 240 |
import org.eclipse.ocl.cst.SimpleTypeEnum; |
| 241 |
import org.eclipse.ocl.cst.StringLiteralExpCS; |
| 242 |
import org.eclipse.ocl.cst.TupleLiteralExpCS; |
| 243 |
import org.eclipse.ocl.cst.TupleTypeCS; |
| 244 |
import org.eclipse.ocl.cst.TypeCS; |
| 245 |
import org.eclipse.ocl.cst.UnlimitedNaturalLiteralExpCS; |
| 246 |
import org.eclipse.ocl.cst.VariableCS; |
| 247 |
import org.eclipse.ocl.cst.VariableExpCS; |
| 248 |
|
| 249 |
import $lpg_ns.BadParseException; |
| 250 |
import $lpg_ns.BadParseSymFileException; |
| 251 |
import $lpg_ns.$prs_parser_class; |
| 252 |
import $lpg_ns.DiagnoseParser; |
| 253 |
import $lpg_ns.IToken; |
| 254 |
import $lpg_ns.Monitor; |
| 255 |
import $lpg_ns.$prs_parser_exception; |
| 256 |
import $lpg_ns.ParseTable; |
| 257 |
import $lpg_ns.RuleAction; |
| 258 |
./ |
| 259 |
%End |
| 260 |
|
| 261 |
%KeyWords |
| 262 |
-- Reserved keywords |
| 263 |
and implies not or xor |
| 264 |
if then else endif |
| 265 |
let in |
| 266 |
false true |
| 267 |
null invalid |
| 268 |
self |
| 269 |
|
| 270 |
-- Restricted keywords |
| 271 |
Bag Collection OrderedSet Sequence Set |
| 272 |
Tuple |
| 273 |
Boolean Integer Real String UnlimitedNatural |
| 274 |
OclAny OclInvalid OclVoid |
| 275 |
%End |
| 276 |
|
| 277 |
-- Terminals |
| 278 |
%Identifier |
| 279 |
IDENTIFIER |
| 280 |
%End |
| 281 |
|
| 282 |
%Terminals |
| 283 |
|
| 284 |
INTEGER_LITERAL REAL_LITERAL STRING_LITERAL |
| 285 |
|
| 286 |
PLUS ::= '+' |
| 287 |
MINUS ::= '-' |
| 288 |
MULTIPLY ::= '*' |
| 289 |
DIVIDE ::= '/' |
| 290 |
|
| 291 |
GREATER ::= '>' |
| 292 |
LESS ::= '<' |
| 293 |
EQUAL ::= '=' |
| 294 |
GREATER_EQUAL ::= '>=' |
| 295 |
LESS_EQUAL ::= '<=' |
| 296 |
NOT_EQUAL ::= '<>' |
| 297 |
|
| 298 |
LPAREN ::= '(' |
| 299 |
RPAREN ::= ')' |
| 300 |
LBRACE ::= '{' |
| 301 |
RBRACE ::= '}' |
| 302 |
LBRACKET ::= '[' |
| 303 |
RBRACKET ::= ']' |
| 304 |
|
| 305 |
ARROW ::= '->' |
| 306 |
BAR ::= '|' |
| 307 |
COMMA ::= ',' |
| 308 |
COLON ::= ':' |
| 309 |
COLONCOLON ::= '::' |
| 310 |
SEMICOLON ::= ';' |
| 311 |
DOT ::= '.' |
| 312 |
DOTDOT ::= '..' |
| 313 |
%End |
| 314 |
|
| 315 |
%EOF |
| 316 |
EOF_TOKEN |
| 317 |
%End |
| 318 |
|
| 319 |
%ERROR |
| 320 |
ERROR_TOKEN |
| 321 |
%End |
| 322 |
|
| 323 |
%Headers |
| 324 |
/.$parserCore |
| 325 |
|
| 326 |
./ |
| 327 |
%End |
| 328 |
|
| 329 |
%Rules |
| 330 |
/.$BeginActions./ |
| 331 |
|
| 332 |
----------------------------------------------------------------------- |
| 333 |
-- Names |
| 334 |
----------------------------------------------------------------------- |
| 335 |
-- Temporary backward compatibility support for 7.4.8 conceptual usage |
| 336 |
conceptualOperationName -> and |
| 337 |
conceptualOperationName -> implies |
| 338 |
conceptualOperationName -> not |
| 339 |
conceptualOperationName -> or |
| 340 |
conceptualOperationName -> xor |
| 341 |
conceptualOperationName -> '<' |
| 342 |
conceptualOperationName -> '<=' |
| 343 |
conceptualOperationName -> '>=' |
| 344 |
conceptualOperationName -> '>' |
| 345 |
conceptualOperationName -> '=' |
| 346 |
conceptualOperationName -> '<>' |
| 347 |
conceptualOperationName -> '+' |
| 348 |
conceptualOperationName -> '-' |
| 349 |
conceptualOperationName -> '*' |
| 350 |
conceptualOperationName -> '/' |
| 351 |
conceptualOperationNameCS ::= conceptualOperationName |
| 352 |
/.$BeginCode |
| 353 |
IToken iToken = getIToken($getToken(1)); |
| 354 |
SimpleNameCS result = createConceptualOperationNameCS(iToken); |
| 355 |
setOffsets(result, iToken); |
| 356 |
$setResult(result); |
| 357 |
$EndCode |
| 358 |
./ |
| 359 |
|
| 360 |
reservedKeyword -> and |
| 361 |
reservedKeyword -> else |
| 362 |
reservedKeyword -> endif |
| 363 |
reservedKeyword -> if |
| 364 |
reservedKeyword -> implies |
| 365 |
reservedKeyword -> in |
| 366 |
reservedKeyword -> let |
| 367 |
reservedKeyword -> not |
| 368 |
reservedKeyword -> or |
| 369 |
reservedKeyword -> then |
| 370 |
reservedKeyword -> xor |
| 371 |
|
| 372 |
tupleKeywordCS ::= Tuple |
| 373 |
/.$NewCase./ |
| 374 |
reservedKeywordCS ::= reservedKeyword |
| 375 |
/.$BeginCode |
| 376 |
IToken iToken = getIToken($getToken(1)); |
| 377 |
SimpleNameCS result = createSimpleNameCS( |
| 378 |
SimpleTypeEnum.KEYWORD_LITERAL, |
| 379 |
iToken |
| 380 |
); |
| 381 |
setOffsets(result, iToken); |
| 382 |
$setResult(result); |
| 383 |
$EndCode |
| 384 |
./ |
| 385 |
restrictedKeywordCS -> CollectionTypeIdentifierCS |
| 386 |
-- restrictedKeywordCS -> BooleanLiteralExpCS |
| 387 |
-- restrictedKeywordCS -> InvalidLiteralExpCS |
| 388 |
-- restrictedKeywordCS -> NullLiteralExpCS |
| 389 |
-- restrictedKeywordCS -> selfKeywordCS |
| 390 |
restrictedKeywordCS -> primitiveTypeCS |
| 391 |
restrictedKeywordCS -> tupleKeywordCS |
| 392 |
|
| 393 |
selfKeywordCS ::= self |
| 394 |
/.$BeginCode |
| 395 |
IToken iToken = getIToken($getToken(1)); |
| 396 |
SimpleNameCS result = createSimpleNameCS( |
| 397 |
SimpleTypeEnum.SELF_LITERAL, |
| 398 |
iToken |
| 399 |
); |
| 400 |
setOffsets(result, iToken); |
| 401 |
$setResult(result); |
| 402 |
$EndCode |
| 403 |
./ |
| 404 |
|
| 405 |
simpleNameCS ::= IDENTIFIER |
| 406 |
/.$BeginCode |
| 407 |
IToken iToken = getIToken($getToken(1)); |
| 408 |
SimpleNameCS result = createSimpleNameCS( |
| 409 |
SimpleTypeEnum.IDENTIFIER_LITERAL, |
| 410 |
iToken |
| 411 |
); |
| 412 |
setOffsets(result, iToken); |
| 413 |
$setResult(result); |
| 414 |
$EndCode |
| 415 |
./ |
| 416 |
|
| 417 |
unreservedSimpleNameCS -> simpleNameCS |
| 418 |
unreservedSimpleNameCS -> restrictedKeywordCS |
| 419 |
|
| 420 |
pathNameCS ::= simpleNameCS |
| 421 |
/.$BeginCode |
| 422 |
SimpleNameCS simpleName = (SimpleNameCS)$getSym(1); |
| 423 |
PathNameCS result = createPathNameCS(simpleName); |
| 424 |
setOffsets(result, simpleName); |
| 425 |
$setResult(result); |
| 426 |
$EndCode |
| 427 |
./ |
| 428 |
pathNameCS ::= pathNameCS '::' unreservedSimpleNameCS |
| 429 |
/.$BeginCode |
| 430 |
PathNameCS result = (PathNameCS)$getSym(1); |
| 431 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 432 |
result = extendPathNameCS(result, simpleNameCS); |
| 433 |
setOffsets(result, result, simpleNameCS); |
| 434 |
$setResult(result); |
| 435 |
$EndCode |
| 436 |
./ |
| 437 |
|
| 438 |
----------------------------------------------------------------------- |
| 439 |
-- Types |
| 440 |
----------------------------------------------------------------------- |
| 441 |
primitiveTypeCS ::= Boolean |
| 442 |
/.$BeginCode |
| 443 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 444 |
SimpleTypeEnum.BOOLEAN_LITERAL, |
| 445 |
getTokenText($getToken(1)) |
| 446 |
); |
| 447 |
setOffsets(result, getIToken($getToken(1))); |
| 448 |
$setResult(result); |
| 449 |
$EndCode |
| 450 |
./ |
| 451 |
primitiveTypeCS ::= Integer |
| 452 |
/.$BeginCode |
| 453 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 454 |
SimpleTypeEnum.INTEGER_LITERAL, |
| 455 |
getTokenText($getToken(1)) |
| 456 |
); |
| 457 |
setOffsets(result, getIToken($getToken(1))); |
| 458 |
$setResult(result); |
| 459 |
$EndCode |
| 460 |
./ |
| 461 |
primitiveTypeCS ::= Real |
| 462 |
/.$BeginCode |
| 463 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 464 |
SimpleTypeEnum.REAL_LITERAL, |
| 465 |
getTokenText($getToken(1)) |
| 466 |
); |
| 467 |
setOffsets(result, getIToken($getToken(1))); |
| 468 |
$setResult(result); |
| 469 |
$EndCode |
| 470 |
./ |
| 471 |
primitiveTypeCS ::= String |
| 472 |
/.$BeginCode |
| 473 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 474 |
SimpleTypeEnum.STRING_LITERAL, |
| 475 |
getTokenText($getToken(1)) |
| 476 |
); |
| 477 |
setOffsets(result, getIToken($getToken(1))); |
| 478 |
$setResult(result); |
| 479 |
$EndCode |
| 480 |
./ |
| 481 |
primitiveTypeCS ::= UnlimitedNatural |
| 482 |
/.$BeginCode |
| 483 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 484 |
SimpleTypeEnum.UNLIMITED_NATURAL_LITERAL, |
| 485 |
getTokenText($getToken(1)) |
| 486 |
); |
| 487 |
setOffsets(result, getIToken($getToken(1))); |
| 488 |
$setResult(result); |
| 489 |
$EndCode |
| 490 |
./ |
| 491 |
|
| 492 |
primitiveTypeCS ::= OclAny |
| 493 |
/.$BeginCode |
| 494 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 495 |
SimpleTypeEnum.OCL_ANY_LITERAL, |
| 496 |
getTokenText($getToken(1)) |
| 497 |
); |
| 498 |
setOffsets(result, getIToken($getToken(1))); |
| 499 |
$setResult(result); |
| 500 |
$EndCode |
| 501 |
./ |
| 502 |
primitiveTypeCS ::= OclInvalid |
| 503 |
/.$BeginCode |
| 504 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 505 |
SimpleTypeEnum.OCL_INVALID_LITERAL, |
| 506 |
getTokenText($getToken(1)) |
| 507 |
); |
| 508 |
setOffsets(result, getIToken($getToken(1))); |
| 509 |
$setResult(result); |
| 510 |
$EndCode |
| 511 |
./ |
| 512 |
primitiveTypeCS ::= OclVoid |
| 513 |
/.$BeginCode |
| 514 |
PrimitiveTypeCS result = createPrimitiveTypeCS( |
| 515 |
SimpleTypeEnum.OCL_VOID_LITERAL, |
| 516 |
getTokenText($getToken(1)) |
| 517 |
); |
| 518 |
setOffsets(result, getIToken($getToken(1))); |
| 519 |
$setResult(result); |
| 520 |
$EndCode |
| 521 |
./ |
| 522 |
|
| 523 |
CollectionTypeIdentifierCS ::= Set |
| 524 |
/.$BeginCode |
| 525 |
SimpleNameCS result = createCollectionTypeCS( |
| 526 |
CollectionTypeIdentifierEnum.SET_LITERAL, |
| 527 |
getTokenText($getToken(1)) |
| 528 |
); |
| 529 |
setOffsets(result, getIToken($getToken(1))); |
| 530 |
$setResult(result); |
| 531 |
$EndCode |
| 532 |
./ |
| 533 |
CollectionTypeIdentifierCS ::= Bag |
| 534 |
/.$BeginCode |
| 535 |
SimpleNameCS result = createCollectionTypeCS( |
| 536 |
CollectionTypeIdentifierEnum.BAG_LITERAL, |
| 537 |
getTokenText($getToken(1)) |
| 538 |
); |
| 539 |
setOffsets(result, getIToken($getToken(1))); |
| 540 |
$setResult(result); |
| 541 |
$EndCode |
| 542 |
./ |
| 543 |
CollectionTypeIdentifierCS ::= Sequence |
| 544 |
/.$BeginCode |
| 545 |
SimpleNameCS result = createCollectionTypeCS( |
| 546 |
CollectionTypeIdentifierEnum.SEQUENCE_LITERAL, |
| 547 |
getTokenText($getToken(1)) |
| 548 |
); |
| 549 |
setOffsets(result, getIToken($getToken(1))); |
| 550 |
$setResult(result); |
| 551 |
$EndCode |
| 552 |
./ |
| 553 |
CollectionTypeIdentifierCS ::= Collection |
| 554 |
/.$BeginCode |
| 555 |
SimpleNameCS result = createCollectionTypeCS( |
| 556 |
CollectionTypeIdentifierEnum.COLLECTION_LITERAL, |
| 557 |
getTokenText($getToken(1)) |
| 558 |
); |
| 559 |
setOffsets(result, getIToken($getToken(1))); |
| 560 |
$setResult(result); |
| 561 |
$EndCode |
| 562 |
./ |
| 563 |
CollectionTypeIdentifierCS ::= OrderedSet |
| 564 |
/.$BeginCode |
| 565 |
SimpleNameCS result = createCollectionTypeCS( |
| 566 |
CollectionTypeIdentifierEnum.ORDERED_SET_LITERAL, |
| 567 |
getTokenText($getToken(1)) |
| 568 |
); |
| 569 |
setOffsets(result, getIToken($getToken(1))); |
| 570 |
$setResult(result); |
| 571 |
$EndCode |
| 572 |
./ |
| 573 |
|
| 574 |
typeCS -> primitiveTypeCS |
| 575 |
typeCS -> pathNameCS |
| 576 |
typeCS -> collectionTypeCS |
| 577 |
typeCS -> tupleTypeCS |
| 578 |
|
| 579 |
collectionTypeCS ::= CollectionTypeIdentifierCS '(' typeCS ')' |
| 580 |
/.$BeginCode |
| 581 |
CollectionTypeCS result = (CollectionTypeCS)$getSym(1); |
| 582 |
result.setTypeCS((TypeCS)$getSym(3)); |
| 583 |
setOffsets(result, result, getIToken($getToken(4))); |
| 584 |
$setResult(result); |
| 585 |
$EndCode |
| 586 |
./ |
| 587 |
|
| 588 |
tupleTypeCS ::= Tuple '(' tupleTypePartsCSopt ')' |
| 589 |
/.$BeginCode |
| 590 |
TupleTypeCS result = createTupleTypeCS((EList<VariableCS>)$getSym(3)); |
| 591 |
setOffsets(result, getIToken($getToken(1)), getIToken($getToken(4))); |
| 592 |
$setResult(result); |
| 593 |
$EndCode |
| 594 |
./ |
| 595 |
|
| 596 |
tupleTypePartsCSopt ::= %empty |
| 597 |
/.$BeginCode |
| 598 |
$setResult(new BasicEList<VariableCS>()); |
| 599 |
$EndCode |
| 600 |
./ |
| 601 |
tupleTypePartsCSopt -> tupleTypePartsCS |
| 602 |
|
| 603 |
tupleTypePartsCS ::= typedUninitializedVariableCS |
| 604 |
/.$BeginCode |
| 605 |
EList<VariableCS> result = new BasicEList<VariableCS>(); |
| 606 |
result.add((VariableCS)$getSym(1)); |
| 607 |
$setResult(result); |
| 608 |
$EndCode |
| 609 |
./ |
| 610 |
tupleTypePartsCS ::= tupleTypePartsCS ',' typedUninitializedVariableCS |
| 611 |
/.$BeginCode |
| 612 |
EList<VariableCS> result = (EList<VariableCS>)$getSym(1); |
| 613 |
result.add((VariableCS)$getSym(3)); |
| 614 |
$setResult(result); |
| 615 |
$EndCode |
| 616 |
./ |
| 617 |
|
| 618 |
----------------------------------------------------------------------- |
| 619 |
-- Declarations |
| 620 |
----------------------------------------------------------------------- |
| 621 |
untypedUninitializedVariableCS ::= simpleNameCS |
| 622 |
/.$BeginCode |
| 623 |
SimpleNameCS name = (SimpleNameCS)$getSym(1); |
| 624 |
VariableCS result = createVariableCS(name, null, null); |
| 625 |
setOffsets(result, name); |
| 626 |
$setResult(result); |
| 627 |
$EndCode |
| 628 |
./ |
| 629 |
|
| 630 |
typedUninitializedVariableCS ::= simpleNameCS ':' typeCS |
| 631 |
/.$BeginCode |
| 632 |
SimpleNameCS name = (SimpleNameCS)$getSym(1); |
| 633 |
TypeCS type = (TypeCS)$getSym(3); |
| 634 |
VariableCS result = createVariableCS(name, type, null); |
| 635 |
setOffsets(result, name, type); |
| 636 |
$setResult(result); |
| 637 |
$EndCode |
| 638 |
./ |
| 639 |
|
| 640 |
untypedInitializedVariableCS ::= simpleNameCS '=' OclExpressionCS |
| 641 |
/.$BeginCode |
| 642 |
SimpleNameCS name = (SimpleNameCS)$getSym(1); |
| 643 |
OCLExpressionCS initExpression = (OCLExpressionCS)$getSym(3); |
| 644 |
VariableCS result = createVariableCS(name, null, initExpression); |
| 645 |
setOffsets(result, name, initExpression); |
| 646 |
$setResult(result); |
| 647 |
$EndCode |
| 648 |
./ |
| 649 |
|
| 650 |
typedInitializedVariableCS ::= simpleNameCS ':' typeCS '=' OclExpressionCS |
| 651 |
/.$BeginCode |
| 652 |
SimpleNameCS name = (SimpleNameCS)$getSym(1); |
| 653 |
TypeCS type = (TypeCS)$getSym(3); |
| 654 |
OCLExpressionCS initExpression = (OCLExpressionCS)$getSym(5); |
| 655 |
VariableCS result = createVariableCS(name, type, initExpression); |
| 656 |
setOffsets(result, name, initExpression); |
| 657 |
$setResult(result); |
| 658 |
$EndCode |
| 659 |
./ |
| 660 |
|
| 661 |
initializedVariableCS -> untypedInitializedVariableCS |
| 662 |
initializedVariableCS -> typedInitializedVariableCS |
| 663 |
|
| 664 |
uninitializedVariableCS -> untypedUninitializedVariableCS |
| 665 |
uninitializedVariableCS -> typedUninitializedVariableCS |
| 666 |
|
| 667 |
VariableDeclarationCS -> untypedUninitializedVariableCS |
| 668 |
VariableDeclarationCS -> untypedInitializedVariableCS |
| 669 |
VariableDeclarationCS -> typedUninitializedVariableCS |
| 670 |
VariableDeclarationCS -> typedInitializedVariableCS |
| 671 |
|
| 672 |
----------------------------------------------------------------------- |
| 673 |
-- Literals |
| 674 |
----------------------------------------------------------------------- |
| 675 |
-- EnumLiteralExpCS is parsed as a PropertyCallExpCS[C] |
| 676 |
-- LiteralExpCS -> EnumLiteralExpCS |
| 677 |
LiteralExpCS -> CollectionLiteralExpCS |
| 678 |
LiteralExpCS -> TupleLiteralExpCS |
| 679 |
LiteralExpCS -> PrimitiveLiteralExpCS |
| 680 |
LiteralExpCS -> TypeLiteralExpCS |
| 681 |
|
| 682 |
CollectionLiteralExpCS ::= CollectionTypeIdentifierCS |
| 683 |
'{' CollectionLiteralPartsCSopt '}' |
| 684 |
/.$BeginCode |
| 685 |
CollectionTypeCS typeCS = (CollectionTypeCS)$getSym(1); |
| 686 |
CollectionLiteralExpCS result = createCollectionLiteralExpCS( |
| 687 |
typeCS, |
| 688 |
(EList<CollectionLiteralPartCS>)$getSym(3) |
| 689 |
); |
| 690 |
setOffsets(result, typeCS, getIToken($getToken(4))); |
| 691 |
$setResult(result); |
| 692 |
$EndCode |
| 693 |
./ |
| 694 |
CollectionLiteralExpCS ::= collectionTypeCS '{' CollectionLiteralPartsCSopt '}' |
| 695 |
/.$BeginCode |
| 696 |
CollectionTypeCS typeCS = (CollectionTypeCS)$getSym(1); |
| 697 |
CollectionLiteralExpCS result = createCollectionLiteralExpCS( |
| 698 |
typeCS, |
| 699 |
(EList<CollectionLiteralPartCS>)$getSym(3) |
| 700 |
); |
| 701 |
setOffsets(result, typeCS, getIToken($getToken(4))); |
| 702 |
$setResult(result); |
| 703 |
$EndCode |
| 704 |
./ |
| 705 |
|
| 706 |
CollectionLiteralPartsCSopt ::= %empty |
| 707 |
/.$BeginCode |
| 708 |
$setResult(new BasicEList<CollectionLiteralPartCS>()); |
| 709 |
$EndCode |
| 710 |
./ |
| 711 |
CollectionLiteralPartsCSopt -> CollectionLiteralPartsCS |
| 712 |
|
| 713 |
CollectionLiteralPartsCS ::= CollectionLiteralPartCS |
| 714 |
/.$BeginCode |
| 715 |
EList<CollectionLiteralPartCS> result = new BasicEList<CollectionLiteralPartCS>(); |
| 716 |
result.add((CollectionLiteralPartCS)$getSym(1)); |
| 717 |
$setResult(result); |
| 718 |
$EndCode |
| 719 |
./ |
| 720 |
CollectionLiteralPartsCS ::= CollectionLiteralPartsCS ',' CollectionLiteralPartCS |
| 721 |
/.$BeginCode |
| 722 |
EList<CollectionLiteralPartCS> result = (EList<CollectionLiteralPartCS>)$getSym(1); |
| 723 |
result.add((CollectionLiteralPartCS)$getSym(3)); |
| 724 |
$setResult(result); |
| 725 |
$EndCode |
| 726 |
./ |
| 727 |
|
| 728 |
CollectionLiteralPartCS -> CollectionRangeCS |
| 729 |
CollectionLiteralPartCS ::= OclExpressionCS |
| 730 |
/.$BeginCode |
| 731 |
CollectionLiteralPartCS result = createCollectionLiteralPartCS( |
| 732 |
(OCLExpressionCS)$getSym(1) |
| 733 |
); |
| 734 |
setOffsets(result, (CSTNode)$getSym(1)); |
| 735 |
$setResult(result); |
| 736 |
$EndCode |
| 737 |
./ |
| 738 |
|
| 739 |
CollectionRangeCS ::= OclExpressionCS '..' OclExpressionCS |
| 740 |
/.$BeginCode |
| 741 |
CollectionLiteralPartCS result = createCollectionRangeCS( |
| 742 |
(OCLExpressionCS)$getSym(1), |
| 743 |
(OCLExpressionCS)$getSym(3) |
| 744 |
); |
| 745 |
setOffsets(result, (CSTNode)$getSym(1), (CSTNode)$getSym(3)); |
| 746 |
$setResult(result); |
| 747 |
$EndCode |
| 748 |
./ |
| 749 |
|
| 750 |
PrimitiveLiteralExpCS -> IntegerLiteralExpCS |
| 751 |
PrimitiveLiteralExpCS -> RealLiteralExpCS |
| 752 |
PrimitiveLiteralExpCS -> StringLiteralExpCS |
| 753 |
PrimitiveLiteralExpCS -> BooleanLiteralExpCS |
| 754 |
PrimitiveLiteralExpCS -> UnlimitedNaturalLiteralExpCS |
| 755 |
PrimitiveLiteralExpCS -> InvalidLiteralExpCS |
| 756 |
PrimitiveLiteralExpCS -> NullLiteralExpCS |
| 757 |
|
| 758 |
TupleLiteralExpCS ::= Tuple '{' TupleLiteralPartsCS '}' |
| 759 |
/.$BeginCode |
| 760 |
TupleLiteralExpCS result = createTupleLiteralExpCS((EList<VariableCS>)$getSym(3)); |
| 761 |
setOffsets(result, getIToken($getToken(1)), getIToken($getToken(4))); |
| 762 |
$setResult(result); |
| 763 |
$EndCode |
| 764 |
./ |
| 765 |
|
| 766 |
TupleLiteralPartsCS ::= initializedVariableCS |
| 767 |
/.$BeginCode |
| 768 |
EList<VariableCS> result = new BasicEList<VariableCS>(); |
| 769 |
result.add((VariableCS)$getSym(1)); |
| 770 |
$setResult(result); |
| 771 |
$EndCode |
| 772 |
./ |
| 773 |
TupleLiteralPartsCS ::= TupleLiteralPartsCS ',' initializedVariableCS |
| 774 |
/.$BeginCode |
| 775 |
EList<VariableCS> result = (EList<VariableCS>)$getSym(1); |
| 776 |
result.add((VariableCS)$getSym(3)); |
| 777 |
$setResult(result); |
| 778 |
$EndCode |
| 779 |
./ |
| 780 |
|
| 781 |
IntegerLiteralExpCS ::= INTEGER_LITERAL |
| 782 |
/.$BeginCode |
| 783 |
IntegerLiteralExpCS result = createIntegerLiteralExpCS(getTokenText($getToken(1))); |
| 784 |
setOffsets(result, getIToken($getToken(1))); |
| 785 |
$setResult(result); |
| 786 |
$EndCode |
| 787 |
./ |
| 788 |
|
| 789 |
RealLiteralExpCS ::= REAL_LITERAL |
| 790 |
/.$BeginCode |
| 791 |
RealLiteralExpCS result = createRealLiteralExpCS(getTokenText($getToken(1))); |
| 792 |
setOffsets(result, getIToken($getToken(1))); |
| 793 |
$setResult(result); |
| 794 |
$EndCode |
| 795 |
./ |
| 796 |
|
| 797 |
StringLiteralExpCS ::= STRING_LITERAL |
| 798 |
/.$BeginCode |
| 799 |
IToken literalToken = getIToken($getToken(1)); |
| 800 |
StringLiteralExpCS result = createStringLiteralExpCS(literalToken); |
| 801 |
setOffsets(result, literalToken); |
| 802 |
$setResult(result); |
| 803 |
$EndCode |
| 804 |
./ |
| 805 |
StringLiteralExpCS ::= StringLiteralExpCS STRING_LITERAL |
| 806 |
/.$BeginCode |
| 807 |
StringLiteralExpCS string = (StringLiteralExpCS)$getSym(1); |
| 808 |
IToken literalToken = getIToken($getToken(2)); |
| 809 |
StringLiteralExpCS result = extendStringLiteralExpCS(string, literalToken); |
| 810 |
setOffsets(result, string, literalToken); |
| 811 |
$setResult(result); |
| 812 |
$EndCode |
| 813 |
./ |
| 814 |
|
| 815 |
BooleanLiteralExpCS ::= true |
| 816 |
/.$BeginCode |
| 817 |
BooleanLiteralExpCS result = createBooleanLiteralExpCS(getTokenText($getToken(1))); |
| 818 |
setOffsets(result, getIToken($getToken(1))); |
| 819 |
$setResult(result); |
| 820 |
$EndCode |
| 821 |
./ |
| 822 |
BooleanLiteralExpCS ::= false |
| 823 |
/.$BeginCode |
| 824 |
BooleanLiteralExpCS result = createBooleanLiteralExpCS(getTokenText($getToken(1))); |
| 825 |
setOffsets(result, getIToken($getToken(1))); |
| 826 |
$setResult(result); |
| 827 |
$EndCode |
| 828 |
./ |
| 829 |
|
| 830 |
UnlimitedNaturalLiteralExpCS ::= '*' |
| 831 |
/.$BeginCode |
| 832 |
UnlimitedNaturalLiteralExpCS result = createUnlimitedNaturalLiteralExpCS(getTokenText($getToken(1))); |
| 833 |
setOffsets(result, getIToken($getToken(1))); |
| 834 |
$setResult(result); |
| 835 |
$EndCode |
| 836 |
./ |
| 837 |
|
| 838 |
InvalidLiteralExpCS ::= invalid |
| 839 |
/.$BeginCode |
| 840 |
InvalidLiteralExpCS result = createInvalidLiteralExpCS(getTokenText($getToken(1))); |
| 841 |
setOffsets(result, getIToken($getToken(1))); |
| 842 |
$setResult(result); |
| 843 |
$EndCode |
| 844 |
./ |
| 845 |
|
| 846 |
NullLiteralExpCS ::= null |
| 847 |
/.$BeginCode |
| 848 |
NullLiteralExpCS result = createNullLiteralExpCS(getTokenText($getToken(1))); |
| 849 |
setOffsets(result, getIToken($getToken(1))); |
| 850 |
$setResult(result); |
| 851 |
$EndCode |
| 852 |
./ |
| 853 |
|
| 854 |
-- unqualified pathNameCS is parsed as SimpleNameExpCS |
| 855 |
-- qualified pathNameCS is parsed as PropertyCallExpCS[C] |
| 856 |
TypeLiteralExpCS ::= primitiveTypeCS |
| 857 |
/.$NewCase./ |
| 858 |
TypeLiteralExpCS ::= collectionTypeCS |
| 859 |
/.$NewCase./ |
| 860 |
TypeLiteralExpCS ::= tupleTypeCS |
| 861 |
/.$BeginCode |
| 862 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(1); |
| 863 |
VariableExpCS result = createVariableExpCS( |
| 864 |
simpleNameCS, |
| 865 |
new BasicEList<OCLExpressionCS>(), |
| 866 |
null |
| 867 |
); |
| 868 |
setOffsets(result, simpleNameCS); |
| 869 |
$setResult(result); |
| 870 |
$EndCode |
| 871 |
./ |
| 872 |
|
| 873 |
----------------------------------------------------------------------- |
| 874 |
-- Calls |
| 875 |
----------------------------------------------------------------------- |
| 876 |
CallExpCS -> FeatureCallExpCS |
| 877 |
CallExpCS -> LoopExpCS |
| 878 |
|
| 879 |
LoopExpCS -> IteratorExpCS |
| 880 |
LoopExpCS -> IterateExpCS |
| 881 |
|
| 882 |
-- IteratorExpCS[A.1] is parsed as OperationCallExpCS[B] |
| 883 |
IteratorExpCS ::= -- [A.2] |
| 884 |
primaryExpCS '->' simpleNameCS |
| 885 |
'(' uninitializedVariableCS '|' OclExpressionCS ')' |
| 886 |
/.$BeginCode |
| 887 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 888 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 889 |
IteratorExpCS result = createIteratorExpCS( |
| 890 |
source, |
| 891 |
simpleNameCS, |
| 892 |
(VariableCS)$getSym(5), |
| 893 |
null, |
| 894 |
(OCLExpressionCS)$getSym(7) |
| 895 |
); |
| 896 |
setOffsets(result, source, getIToken($getToken(8))); |
| 897 |
$setResult(result); |
| 898 |
$EndCode |
| 899 |
./ |
| 900 |
IteratorExpCS ::= -- [A.3.1] |
| 901 |
primaryExpCS '->' simpleNameCS |
| 902 |
'(' simpleNameCS ',' uninitializedVariableCS '|' OclExpressionCS ')' |
| 903 |
/.$BeginCode |
| 904 |
SimpleNameCS name = (SimpleNameCS)$getSym(5); |
| 905 |
VariableCS variableCS = createVariableCS(name, null, null); |
| 906 |
setOffsets(variableCS, name); |
| 907 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 908 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 909 |
IteratorExpCS result = createIteratorExpCS( |
| 910 |
source, |
| 911 |
simpleNameCS, |
| 912 |
variableCS, |
| 913 |
(VariableCS)$getSym(7), |
| 914 |
(OCLExpressionCS)$getSym(9) |
| 915 |
); |
| 916 |
setOffsets(result, source, getIToken($getToken(10))); |
| 917 |
$setResult(result); |
| 918 |
$EndCode |
| 919 |
./ |
| 920 |
IteratorExpCS ::= -- [A.3.2] |
| 921 |
primaryExpCS '->' simpleNameCS '(' typedUninitializedVariableCS ',' |
| 922 |
uninitializedVariableCS '|' OclExpressionCS ')' |
| 923 |
/.$BeginCode |
| 924 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 925 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 926 |
IteratorExpCS result = createIteratorExpCS( |
| 927 |
source, |
| 928 |
simpleNameCS, |
| 929 |
(VariableCS)$getSym(5), |
| 930 |
(VariableCS)$getSym(7), |
| 931 |
(OCLExpressionCS)$getSym(9) |
| 932 |
); |
| 933 |
setOffsets(result, source, getIToken($getToken(10))); |
| 934 |
$setResult(result); |
| 935 |
$EndCode |
| 936 |
./ |
| 937 |
-- IteratorExpCS[B] is parsed as OperationCallExpCS[C] |
| 938 |
-- IteratorExpCS[C] is parsed as AssociationClassCallExpCS[A.1] |
| 939 |
-- IteratorExpCS[D] is parsed as AssociationClassCallExpCS[A] |
| 940 |
-- IteratorExpCS[E] is parsed as AssociationClassCallExpCS[A] |
| 941 |
|
| 942 |
IterateExpCS ::= primaryExpCS '->' simpleNameCS |
| 943 |
'(' typedInitializedVariableCS '|' OclExpressionCS ')' |
| 944 |
/.$BeginCode |
| 945 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 946 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 947 |
IterateExpCS result = createIterateExpCS( |
| 948 |
source, |
| 949 |
simpleNameCS, |
| 950 |
(VariableCS)$getSym(5), |
| 951 |
null, |
| 952 |
(OCLExpressionCS)$getSym(7) |
| 953 |
); |
| 954 |
setOffsets(result, source, getIToken($getToken(8))); |
| 955 |
$setResult(result); |
| 956 |
$EndCode |
| 957 |
./ |
| 958 |
IterateExpCS ::= primaryExpCS '->' simpleNameCS |
| 959 |
'(' uninitializedVariableCS ';' typedInitializedVariableCS '|' OclExpressionCS ')' |
| 960 |
/.$BeginCode |
| 961 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 962 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 963 |
IterateExpCS result = createIterateExpCS( |
| 964 |
source, |
| 965 |
simpleNameCS, |
| 966 |
(VariableCS)$getSym(5), |
| 967 |
(VariableCS)$getSym(7), |
| 968 |
(OCLExpressionCS)$getSym(9) |
| 969 |
); |
| 970 |
setOffsets(result, source, getIToken($getToken(10))); |
| 971 |
$setResult(result); |
| 972 |
$EndCode |
| 973 |
./ |
| 974 |
|
| 975 |
FeatureCallExpCS -> OperationCallExpCS |
| 976 |
FeatureCallExpCS -> PropertyCallExpCS |
| 977 |
FeatureCallExpCS -> NavigationCallExpCS |
| 978 |
|
| 979 |
-- OperationCallExpCS[A] is realized by the infix OclExpressionCS productions |
| 980 |
OperationCallExpCS ::= -- [B.1] |
| 981 |
primaryExpCS '->' simpleNameCS '(' ')' |
| 982 |
/.$BeginCode |
| 983 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 984 |
OperationCallExpCS result = createArrowOperationCallExpCS( |
| 985 |
source, |
| 986 |
(SimpleNameCS)$getSym(3), |
| 987 |
null, |
| 988 |
new BasicEList<OCLExpressionCS>() |
| 989 |
); |
| 990 |
setOffsets(result, source, getIToken($getToken(5))); |
| 991 |
$setResult(result); |
| 992 |
$EndCode |
| 993 |
./ |
| 994 |
OperationCallExpCS ::= -- [B.2],IteratorExpCS[A.1] |
| 995 |
primaryExpCS '->' simpleNameCS '(' OclExpressionCS ')' |
| 996 |
/.$BeginCode |
| 997 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 998 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 999 |
OCLExpressionCS arg = (OCLExpressionCS)$getSym(5); |
| 1000 |
OCLExpressionCS result; |
| 1001 |
if (isIterator(simpleNameCS.getValue())) { |
| 1002 |
result = createIteratorExpCS( |
| 1003 |
source, |
| 1004 |
simpleNameCS, |
| 1005 |
null, |
| 1006 |
null, |
| 1007 |
arg |
| 1008 |
); |
| 1009 |
} |
| 1010 |
else { |
| 1011 |
EList<OCLExpressionCS> args = new BasicEList<OCLExpressionCS>(); |
| 1012 |
args.add(arg); |
| 1013 |
result = createArrowOperationCallExpCS( |
| 1014 |
source, |
| 1015 |
simpleNameCS, |
| 1016 |
null, |
| 1017 |
args |
| 1018 |
); |
| 1019 |
} |
| 1020 |
setOffsets(result, source, getIToken($getToken(6))); |
| 1021 |
$setResult(result); |
| 1022 |
$EndCode |
| 1023 |
./ |
| 1024 |
OperationCallExpCS ::= -- [B.3.1] |
| 1025 |
primaryExpCS '->' simpleNameCS '(' notNameExpressionCS ',' argumentsCS ')' |
| 1026 |
/.$BeginCode |
| 1027 |
EList<OCLExpressionCS> args = (EList<OCLExpressionCS>)$getSym(7); |
| 1028 |
args.add(0, (OCLExpressionCS)$getSym(5)); |
| 1029 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1030 |
OperationCallExpCS result = createArrowOperationCallExpCS( |
| 1031 |
source, |
| 1032 |
(SimpleNameCS)$getSym(3), |
| 1033 |
null, |
| 1034 |
args |
| 1035 |
); |
| 1036 |
setOffsets(result, source, getIToken($getToken(8))); |
| 1037 |
$setResult(result); |
| 1038 |
$EndCode |
| 1039 |
./ |
| 1040 |
OperationCallExpCS ::= -- [B.3.2] |
| 1041 |
primaryExpCS '->' simpleNameCS '(' simpleNameCS ',' argumentsCS ')' |
| 1042 |
/.$BeginCode |
| 1043 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(5); |
| 1044 |
OCLExpressionCS variableExpCS = createVariableExpCS( |
| 1045 |
simpleNameCS, |
| 1046 |
new BasicEList<OCLExpressionCS>(), |
| 1047 |
null |
| 1048 |
); |
| 1049 |
setOffsets(variableExpCS, simpleNameCS); |
| 1050 |
EList<OCLExpressionCS> args = (EList<OCLExpressionCS>)$getSym(7); |
| 1051 |
args.add(0, variableExpCS); |
| 1052 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1053 |
OperationCallExpCS result = createArrowOperationCallExpCS( |
| 1054 |
source, |
| 1055 |
(SimpleNameCS)$getSym(3), |
| 1056 |
null, |
| 1057 |
args |
| 1058 |
); |
| 1059 |
setOffsets(result, source, getIToken($getToken(8))); |
| 1060 |
$setResult(result); |
| 1061 |
$EndCode |
| 1062 |
./ |
| 1063 |
OperationCallExpCS ::= |
| 1064 |
primaryExpCS '.' conceptualOperationNameCS isMarkedPreCSopt '(' argumentsCSopt ')' |
| 1065 |
/.$NewCase./ |
| 1066 |
OperationCallExpCS ::= -- [C],[E],IteratorExpCS[B] |
| 1067 |
primaryExpCS '.' simpleNameCS isMarkedPreCSopt '(' argumentsCSopt ')' |
| 1068 |
/.$BeginCode |
| 1069 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 1070 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1071 |
CallExpCS result = createDotOperationCallExpCS( |
| 1072 |
source, |
| 1073 |
null, |
| 1074 |
simpleNameCS, |
| 1075 |
(IsMarkedPreCS)$getSym(4), |
| 1076 |
(EList<OCLExpressionCS>)$getSym(6) |
| 1077 |
); |
| 1078 |
setOffsets(result, source, getIToken($getToken(7))); |
| 1079 |
$setResult(result); |
| 1080 |
$EndCode |
| 1081 |
./ |
| 1082 |
OperationCallExpCS ::= -- [D],[F],[G.1] |
| 1083 |
simpleNameCS isMarkedPreCSopt '(' argumentsCSopt ')' |
| 1084 |
/.$BeginCode |
| 1085 |
OperationCallExpCS result = createDotOperationCallExpCS( |
| 1086 |
null, |
| 1087 |
null, |
| 1088 |
(SimpleNameCS)$getSym(1), |
| 1089 |
(IsMarkedPreCS)$getSym(2), |
| 1090 |
(EList<OCLExpressionCS>)$getSym(4) |
| 1091 |
); |
| 1092 |
setOffsets(result, getIToken($getToken(1)), getIToken($getToken(5))); |
| 1093 |
$setResult(result); |
| 1094 |
$EndCode |
| 1095 |
./ |
| 1096 |
OperationCallExpCS ::= -- [G.2] |
| 1097 |
pathNameCS '::' unreservedSimpleNameCS '(' argumentsCSopt ')' |
| 1098 |
/.$BeginCode |
| 1099 |
PathNameCS pathNameCS = (PathNameCS)$getSym(1); |
| 1100 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 1101 |
OperationCallExpCS result = createDotOperationCallExpCS( |
| 1102 |
null, |
| 1103 |
pathNameCS, |
| 1104 |
simpleNameCS, |
| 1105 |
null, |
| 1106 |
(EList<OCLExpressionCS>)$getSym(5) |
| 1107 |
); |
| 1108 |
setOffsets(result, pathNameCS, getIToken($getToken(6))); |
| 1109 |
$setResult(result); |
| 1110 |
$EndCode |
| 1111 |
./ |
| 1112 |
-- OperationCallExpCS[H] is realized by the prefix OclExpressionCS productions |
| 1113 |
OperationCallExpCS ::= -- [I],[J] |
| 1114 |
primaryExpCS '.' pathNameCS '::' unreservedSimpleNameCS isMarkedPreCSopt |
| 1115 |
'(' argumentsCSopt ')' |
| 1116 |
/.$BeginCode |
| 1117 |
PathNameCS pathNameCS = (PathNameCS)$getSym(3); |
| 1118 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(5); |
| 1119 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1120 |
CallExpCS result = createDotOperationCallExpCS( |
| 1121 |
source, |
| 1122 |
pathNameCS, |
| 1123 |
simpleNameCS, |
| 1124 |
(IsMarkedPreCS)$getSym(6), |
| 1125 |
(EList<OCLExpressionCS>)$getSym(8) |
| 1126 |
); |
| 1127 |
setOffsets(result, source, getIToken($getToken(9))); |
| 1128 |
$setResult(result); |
| 1129 |
$EndCode |
| 1130 |
./ |
| 1131 |
|
| 1132 |
-- NavigationCallExpCS -> PropertyCallExpCS -- parsed as FeatureCallExpCS |
| 1133 |
NavigationCallExpCS -> AssociationClassCallExpCS |
| 1134 |
|
| 1135 |
-- PropertyCallExpCS[A] is parsed as AssociationClassCallExpCS[A.1] |
| 1136 |
-- PropertyCallExpCS[B.1] is parsed as a SimpleNameExpCS |
| 1137 |
-- PropertyCallExpCS[B.2] is parsed as a AssociationClassCallExpCS[B.1] |
| 1138 |
PropertyCallExpCS ::= -- [C] excluding [B] |
| 1139 |
pathNameCS '::' unreservedSimpleNameCS isMarkedPreCSopt |
| 1140 |
/.$BeginCode |
| 1141 |
PathNameCS pathNameCS = (PathNameCS)$getSym(1); |
| 1142 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 1143 |
IsMarkedPreCS isMarkedPreCS = (IsMarkedPreCS)$getSym(4); |
| 1144 |
FeatureCallExpCS result = createFeatureCallExpCS( |
| 1145 |
null, |
| 1146 |
pathNameCS, |
| 1147 |
simpleNameCS, |
| 1148 |
new BasicEList<OCLExpressionCS>(), |
| 1149 |
isMarkedPreCS |
| 1150 |
); |
| 1151 |
if (isMarkedPreCS != null) { |
| 1152 |
setOffsets(result, pathNameCS, isMarkedPreCS); |
| 1153 |
} else { |
| 1154 |
setOffsets(result, pathNameCS, simpleNameCS); |
| 1155 |
} |
| 1156 |
$setResult(result); |
| 1157 |
$EndCode |
| 1158 |
./ |
| 1159 |
PropertyCallExpCS ::= -- [D] |
| 1160 |
primaryExpCS '.' pathNameCS '::' unreservedSimpleNameCS isMarkedPreCSopt |
| 1161 |
/.$BeginCode |
| 1162 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1163 |
PathNameCS pathNameCS = (PathNameCS)$getSym(3); |
| 1164 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(5); |
| 1165 |
IsMarkedPreCS isMarkedPreCS = (IsMarkedPreCS)$getSym(6); |
| 1166 |
FeatureCallExpCS result = createFeatureCallExpCS( |
| 1167 |
source, |
| 1168 |
pathNameCS, |
| 1169 |
simpleNameCS, |
| 1170 |
new BasicEList<OCLExpressionCS>(), |
| 1171 |
isMarkedPreCS |
| 1172 |
); |
| 1173 |
if (isMarkedPreCS != null) { |
| 1174 |
setOffsets(result, source, isMarkedPreCS); |
| 1175 |
} else { |
| 1176 |
setOffsets(result, source, simpleNameCS); |
| 1177 |
} |
| 1178 |
$setResult(result); |
| 1179 |
$EndCode |
| 1180 |
./ |
| 1181 |
|
| 1182 |
AssociationClassCallExpCS ::= -- [A.1],PropertyCallExpCS[A],IteratorExpCS[C,D,E] |
| 1183 |
primaryExpCS '.' simpleNameCS isMarkedPreCSopt |
| 1184 |
/.$BeginCode |
| 1185 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1186 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 1187 |
IsMarkedPreCS isMarkedPreCS = (IsMarkedPreCS)$getSym(4); |
| 1188 |
FeatureCallExpCS result = createFeatureCallExpCS( |
| 1189 |
source, |
| 1190 |
null, |
| 1191 |
simpleNameCS, |
| 1192 |
new BasicEList<OCLExpressionCS>(), |
| 1193 |
isMarkedPreCS |
| 1194 |
); |
| 1195 |
if (isMarkedPreCS != null) { |
| 1196 |
setOffsets(result, source, isMarkedPreCS); |
| 1197 |
} else { |
| 1198 |
setOffsets(result, source, simpleNameCS); |
| 1199 |
} |
| 1200 |
$setResult(result); |
| 1201 |
$EndCode |
| 1202 |
./ |
| 1203 |
AssociationClassCallExpCS ::= -- [A.2],IteratorExpCS[D,E] |
| 1204 |
primaryExpCS '.' simpleNameCS '[' argumentsCS ']' isMarkedPreCSopt |
| 1205 |
/.$BeginCode |
| 1206 |
OCLExpressionCS source = (OCLExpressionCS)$getSym(1); |
| 1207 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(3); |
| 1208 |
IsMarkedPreCS isMarkedPreCS = (IsMarkedPreCS)$getSym(7); |
| 1209 |
FeatureCallExpCS result = createFeatureCallExpCS( |
| 1210 |
source, |
| 1211 |
null, |
| 1212 |
simpleNameCS, |
| 1213 |
(EList<OCLExpressionCS>)$getSym(5), |
| 1214 |
isMarkedPreCS |
| 1215 |
); |
| 1216 |
if (isMarkedPreCS != null) { |
| 1217 |
setOffsets(result, source, isMarkedPreCS); |
| 1218 |
} else { |
| 1219 |
setOffsets(result, source, getIToken($getToken(6))); |
| 1220 |
} |
| 1221 |
$setResult(result); |
| 1222 |
$EndCode |
| 1223 |
./ |
| 1224 |
-- AssociationClassCallExpCS[B.1.1] parsed as SimpleNameExpCS |
| 1225 |
-- AssociationClassCallExpCS[B.1.2] is added by Complete OCL |
| 1226 |
AssociationClassCallExpCS ::= -- [B.2] |
| 1227 |
simpleNameCS '[' argumentsCS ']' isMarkedPreCSopt |
| 1228 |
/.$BeginCode |
| 1229 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(1); |
| 1230 |
IsMarkedPreCS isMarkedPreCS = (IsMarkedPreCS)$getSym(5); |
| 1231 |
VariableExpCS result = createVariableExpCS( |
| 1232 |
simpleNameCS, |
| 1233 |
(EList<OCLExpressionCS>)$getSym(3), |
| 1234 |
isMarkedPreCS |
| 1235 |
); |
| 1236 |
if (isMarkedPreCS != null) { |
| 1237 |
setOffsets(result, simpleNameCS, isMarkedPreCS); |
| 1238 |
} else { |
| 1239 |
setOffsets(result, simpleNameCS, getIToken($getToken(4))); |
| 1240 |
} |
| 1241 |
$setResult(result); |
| 1242 |
$EndCode |
| 1243 |
./ |
| 1244 |
|
| 1245 |
isMarkedPreCSopt ::= %empty |
| 1246 |
/.$BeginCode |
| 1247 |
$setResult(null); |
| 1248 |
$EndCode |
| 1249 |
./ |
| 1250 |
|
| 1251 |
argumentsCSopt ::= %empty |
| 1252 |
/.$BeginCode |
| 1253 |
$setResult(new BasicEList<OCLExpressionCS>()); |
| 1254 |
$EndCode |
| 1255 |
./ |
| 1256 |
argumentsCSopt -> argumentsCS |
| 1257 |
|
| 1258 |
argumentsCS ::= OclExpressionCS |
| 1259 |
/.$BeginCode |
| 1260 |
EList<OCLExpressionCS> result = new BasicEList<OCLExpressionCS>(); |
| 1261 |
result.add((OCLExpressionCS)$getSym(1)); |
| 1262 |
$setResult(result); |
| 1263 |
$EndCode |
| 1264 |
./ |
| 1265 |
argumentsCS ::= argumentsCS ',' OclExpressionCS |
| 1266 |
/.$BeginCode |
| 1267 |
EList<OCLExpressionCS> result = (EList<OCLExpressionCS>)$getSym(1); |
| 1268 |
result.add((OCLExpressionCS)$getSym(3)); |
| 1269 |
$setResult(result); |
| 1270 |
$EndCode |
| 1271 |
./ |
| 1272 |
|
| 1273 |
----------------------------------------------------------------------- |
| 1274 |
-- Expressions |
| 1275 |
----------------------------------------------------------------------- |
| 1276 |
-- An OclExpressionCS comprising just a SimpleNameCS is kept separate as |
| 1277 |
-- SimpleNameExpCS to avoid ambiguity when parsing "a->b(c,d" until the next |
| 1278 |
-- letter resolves the usage as a two iterator or as a two or more argument |
| 1279 |
-- OperationCallExpCS. |
| 1280 |
-- An OclExpressionCS comprising one or more LetExpCS is kept separate to ensure |
| 1281 |
-- that let is right associative, whereas infix operators are left associative. |
| 1282 |
-- a = 64 / 16 / let b : Integer in 8 / let c : Integer in 4 |
| 1283 |
-- is |
| 1284 |
-- a = (64 / 16) / (let b : Integer in 8 / (let c : Integer in 4 )) |
| 1285 |
OclExpressionCS -> notNameExpressionCS |
| 1286 |
OclExpressionCS -> SimpleNameExpCS |
| 1287 |
|
| 1288 |
-- VariableExpCS[.1] simpleNameCS parsed as SimpleNameExpCS |
| 1289 |
VariableExpCS ::= -- [.2] |
| 1290 |
selfKeywordCS |
| 1291 |
/.$BeginCode |
| 1292 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(1); |
| 1293 |
VariableExpCS result = createVariableExpCS( |
| 1294 |
simpleNameCS, |
| 1295 |
new BasicEList<OCLExpressionCS>(), |
| 1296 |
null |
| 1297 |
); |
| 1298 |
setOffsets(result, simpleNameCS); |
| 1299 |
$setResult(result); |
| 1300 |
$EndCode |
| 1301 |
./ |
| 1302 |
|
| 1303 |
SimpleNameExpCS ::= -- AssociationClassCallExpCS[B.1.1], |
| 1304 |
-- PropertyCallExpCS[B],VariableExpCS[.1] |
| 1305 |
simpleNameCS |
| 1306 |
/.$BeginCode |
| 1307 |
SimpleNameCS simpleNameCS = (SimpleNameCS)$getSym(1); |
| 1308 |
VariableExpCS result = createVariableExpCS( |
| 1309 |
simpleNameCS, |
| 1310 |
new BasicEList<OCLExpressionCS>(), |
| 1311 |
null |
| 1312 |
); |
| 1313 |
setOffsets(result, simpleNameCS); |
| 1314 |
$setResult(result); |
| 1315 |
$EndCode |
| 1316 |
./ |
| 1317 |
|
| 1318 |
notNameExpressionCS -> impliesNotNameNotLetCS |
| 1319 |
notNameExpressionCS -> impliesWithLetCS |
| 1320 |
|
| 1321 |
impliesNotLetCS -> impliesNotNameNotLetCS |
| 1322 |
impliesNotLetCS -> SimpleNameExpCS |
| 1323 |
impliesNotNameNotLetCS -> xorNotNameNotLetCS |
| 1324 |
impliesNotNameNotLetCS ::= impliesNotLetCS implies xorNotLetCS |
| 1325 |
/.$NewCase./ |
| 1326 |
impliesWithLetCS -> xorWithLetCS |
| 1327 |
impliesWithLetCS ::= impliesNotLetCS implies xorWithLetCS |
| 1328 |
/.$NewCase./ |
| 1329 |
|
| 1330 |
xorNotLetCS -> xorNotNameNotLetCS |
| 1331 |
xorNotLetCS -> SimpleNameExpCS |
| 1332 |
xorNotNameNotLetCS -> orNotNameNotLetCS |
| 1333 |
xorNotNameNotLetCS ::= xorNotLetCS xor orNotLetCS |
| 1334 |
/.$NewCase./ |
| 1335 |
xorWithLetCS -> orWithLetCS |
| 1336 |
xorWithLetCS ::= xorNotLetCS xor orWithLetCS |
| 1337 |
/.$NewCase./ |
| 1338 |
|
| 1339 |
orNotLetCS -> orNotNameNotLetCS |
| 1340 |
orNotLetCS -> SimpleNameExpCS |
| 1341 |
orNotNameNotLetCS -> andNotNameNotLetCS |
| 1342 |
orNotNameNotLetCS ::= orNotLetCS or andNotLetCS |
| 1343 |
/.$NewCase./ |
| 1344 |
orWithLetCS -> andWithLetCS |
| 1345 |
orWithLetCS ::= orNotLetCS or andWithLetCS |
| 1346 |
/.$NewCase./ |
| 1347 |
|
| 1348 |
andNotLetCS -> andNotNameNotLetCS |
| 1349 |
andNotLetCS -> SimpleNameExpCS |
| 1350 |
andNotNameNotLetCS -> equalityNotNameNotLetCS |
| 1351 |
andNotNameNotLetCS ::= andNotLetCS and equalityNotLetCS |
| 1352 |
/.$NewCase./ |
| 1353 |
andWithLetCS -> equalityWithLetCS |
| 1354 |
andWithLetCS ::= andNotLetCS and equalityWithLetCS |
| 1355 |
/.$NewCase./ |
| 1356 |
|
| 1357 |
equalityNotLetCS -> equalityNotNameNotLetCS |
| 1358 |
equalityNotLetCS -> SimpleNameExpCS |
| 1359 |
equalityNotNameNotLetCS -> relationalNotNameNotLetCS |
| 1360 |
equalityNotNameNotLetCS ::= equalityNotLetCS '=' relationalNotLetCS |
| 1361 |
/.$NewCase./ |
| 1362 |
equalityNotNameNotLetCS ::= equalityNotLetCS '<>' relationalNotLetCS |
| 1363 |
/.$NewCase./ |
| 1364 |
equalityWithLetCS -> relationalWithLetCS |
| 1365 |
equalityWithLetCS ::= equalityNotLetCS '=' relationalWithLetCS |
| 1366 |
/.$NewCase./ |
| 1367 |
equalityWithLetCS ::= equalityNotLetCS '<>' relationalWithLetCS |
| 1368 |
/.$NewCase./ |
| 1369 |
|
| 1370 |
relationalNotLetCS -> relationalNotNameNotLetCS |
| 1371 |
relationalNotLetCS -> SimpleNameExpCS |
| 1372 |
relationalNotNameNotLetCS -> additiveNotNameNotLetCS |
| 1373 |
relationalNotNameNotLetCS ::= relationalNotLetCS '>' additiveNotLetCS |
| 1374 |
/.$NewCase./ |
| 1375 |
relationalNotNameNotLetCS ::= relationalNotLetCS '<' additiveNotLetCS |
| 1376 |
/.$NewCase./ |
| 1377 |
relationalNotNameNotLetCS ::= relationalNotLetCS '>=' additiveNotLetCS |
| 1378 |
/.$NewCase./ |
| 1379 |
relationalNotNameNotLetCS ::= relationalNotLetCS '<=' additiveNotLetCS |
| 1380 |
/.$NewCase./ |
| 1381 |
relationalWithLetCS -> additiveWithLetCS |
| 1382 |
relationalWithLetCS ::= relationalNotLetCS '>' additiveWithLetCS |
| 1383 |
/.$NewCase./ |
| 1384 |
relationalWithLetCS ::= relationalNotLetCS '<' additiveWithLetCS |
| 1385 |
/.$NewCase./ |
| 1386 |
relationalWithLetCS ::= relationalNotLetCS '>=' additiveWithLetCS |
| 1387 |
/.$NewCase./ |
| 1388 |
relationalWithLetCS ::= relationalNotLetCS '<=' additiveWithLetCS |
| 1389 |
/.$NewCase./ |
| 1390 |
|
| 1391 |
additiveNotLetCS -> additiveNotNameNotLetCS |
| 1392 |
additiveNotLetCS -> SimpleNameExpCS |
| 1393 |
additiveNotNameNotLetCS -> multiplicativeNotNameNotLetCS |
| 1394 |
additiveNotNameNotLetCS ::= additiveNotLetCS '+' multiplicativeNotLetCS |
| 1395 |
/.$NewCase./ |
| 1396 |
additiveNotNameNotLetCS ::= additiveNotLetCS '-' multiplicativeNotLetCS |
| 1397 |
/.$NewCase./ |
| 1398 |
additiveWithLetCS -> multiplicativeWithLetCS |
| 1399 |
additiveWithLetCS ::= additiveNotLetCS '+' multiplicativeWithLetCS |
| 1400 |
/.$NewCase./ |
| 1401 |
additiveWithLetCS ::= additiveNotLetCS '-' multiplicativeWithLetCS |
| 1402 |
/.$NewCase./ |
| 1403 |
|
| 1404 |
multiplicativeNotLetCS -> multiplicativeNotNameNotLetCS |
| 1405 |
multiplicativeNotLetCS -> SimpleNameExpCS |
| 1406 |
multiplicativeNotNameNotLetCS -> unaryNotNameNotLetCS |
| 1407 |
multiplicativeNotNameNotLetCS ::= multiplicativeNotLetCS '*' unaryNotLetCS |
| 1408 |
/.$NewCase./ |
| 1409 |
multiplicativeNotNameNotLetCS ::= multiplicativeNotLetCS '/' unaryNotLetCS |
| 1410 |
/.$NewCase./ |
| 1411 |
multiplicativeWithLetCS -> unaryWithLetCS |
| 1412 |
multiplicativeWithLetCS ::= multiplicativeNotLetCS '*' unaryWithLetCS |
| 1413 |
/.$NewCase./ |
| 1414 |
multiplicativeWithLetCS ::= multiplicativeNotLetCS '/' unaryWithLetCS |
| 1415 |
/.$BeginCode |
| 1416 |
SimpleNameCS simpleNameCS = createSimpleNameCS( |
| 1417 |
SimpleTypeEnum.KEYWORD_LITERAL, |
| 1418 |
getIToken($getToken(2)) |
| 1419 |
); |
| 1420 |
setOffsets(simpleNameCS, getIToken($getToken(2))); |
| 1421 |
OCLExpressionCS left = (OCLExpressionCS)$getSym(1); |
| 1422 |
OCLExpressionCS right = (OCLExpressionCS)$getSym(3); |
| 1423 |
EList<OCLExpressionCS> args = new BasicEList<OCLExpressionCS>(); |
| 1424 |
args.add(right); |
| 1425 |
OperationCallExpCS result = createOperationCallExpCS( |
| 1426 |
left, |
| 1427 |
simpleNameCS, |
| 1428 |
args |
| 1429 |
); |
| 1430 |
setOffsets(result, left, right); |
| 1431 |
$setResult(result); |
| 1432 |
$EndCode |
| 1433 |
./ |
| 1434 |
|
| 1435 |
unaryNotLetCS -> unaryNotNameNotLetCS |
| 1436 |
unaryNotLetCS -> SimpleNameExpCS |
| 1437 |
unaryNotNameNotLetCS -> primaryNotNameCS |
| 1438 |
unaryNotNameNotLetCS ::= '-' unaryNotLetCS |
| 1439 |
/.$NewCase./ |
| 1440 |
unaryNotNameNotLetCS ::= not unaryNotLetCS |
| 1441 |
/.$NewCase./ |
| 1442 |
unaryWithLetCS -> LetExpCS -- OclExpressionCS[D] |
| 1443 |
unaryWithLetCS ::= '-' unaryWithLetCS |
| 1444 |
/.$NewCase./ |
| 1445 |
unaryWithLetCS ::= not unaryWithLetCS |
| 1446 |
/.$BeginCode |
| 1447 |
SimpleNameCS simpleNameCS = createSimpleNameCS( |
| 1448 |
SimpleTypeEnum.KEYWORD_LITERAL, |
| 1449 |
getIToken($getToken(1)) |
| 1450 |
); |
| 1451 |
setOffsets(simpleNameCS, getIToken($getToken(1))); |
| 1452 |
OCLExpressionCS expr = (OCLExpressionCS)$getSym(2); |
| 1453 |
OperationCallExpCS result = createOperationCallExpCS( |
| 1454 |
expr, |
| 1455 |
simpleNameCS, |
| 1456 |
new BasicEList<OCLExpressionCS>() |
| 1457 |
); |
| 1458 |
setOffsets(result, simpleNameCS, expr); |
| 1459 |
$setResult(result); |
| 1460 |
$EndCode |
| 1461 |
./ |
| 1462 |
|
| 1463 |
primaryExpCS -> primaryNotNameCS |
| 1464 |
primaryExpCS -> SimpleNameExpCS |
| 1465 |
|
| 1466 |
primaryNotNameCS -> CallExpCS -- OclExpressionCS[A] |
| 1467 |
primaryNotNameCS -> VariableExpCS -- OclExpressionCS[B] |
| 1468 |
primaryNotNameCS -> LiteralExpCS -- OclExpressionCS[C] |
| 1469 |
-- primaryNotNameCS -> OclMessageExpCS -- OclExpressionCS[E] is added by Complete OCL |
| 1470 |
primaryNotNameCS -> IfExpCS -- OclExpressionCS[F] |
| 1471 |
primaryNotNameCS ::= '(' OclExpressionCS ')' |
| 1472 |
/.$BeginCode |
| 1473 |
OCLExpressionCS result = (OCLExpressionCS)$getSym(2); |
| 1474 |
if (result instanceof OperationCallExpCS) { |
| 1475 |
((OperationCallExpCS)result).setIsAtomic(true); |
| 1476 |
} |
| 1477 |
setOffsets(result, getIToken($getToken(1)), getIToken($getToken(3))); |
| 1478 |
$setResult(result); |
| 1479 |
$EndCode |
| 1480 |
./ |
| 1481 |
|
| 1482 |
IfExpCS ::= if OclExpressionCS then OclExpressionCS else OclExpressionCS endif |
| 1483 |
/.$BeginCode |
| 1484 |
IfExpCS result = createIfExpCS( |
| 1485 |
(OCLExpressionCS)$getSym(2), |
| 1486 |
(OCLExpressionCS)$getSym(4), |
| 1487 |
(OCLExpressionCS)$getSym(6) |
| 1488 |
); |
| 1489 |
setOffsets(result, getIToken($getToken(1)), getIToken($getToken(7))); |
| 1490 |
$setResult(result); |
| 1491 |
$EndCode |
| 1492 |
./ |
| 1493 |
|
| 1494 |
LetExpCS ::= let letVariablesCS in OclExpressionCS |
| 1495 |
/.$BeginCode |
| 1496 |
OCLExpressionCS expr = (OCLExpressionCS)$getSym(4); |
| 1497 |
LetExpCS result = createLetExpCS( |
| 1498 |
(EList<VariableCS>)$getSym(2), |
| 1499 |
expr |
| 1500 |
); |
| 1501 |
setOffsets(result, getIToken($getToken(1)), expr); |
| 1502 |
$setResult(result); |
| 1503 |
$EndCode |
| 1504 |
./ |
| 1505 |
|
| 1506 |
letVariablesCS ::= typedInitializedVariableCS |
| 1507 |
/.$BeginCode |
| 1508 |
EList<VariableCS> result = new BasicEList<VariableCS>(); |
| 1509 |
result.add((VariableCS)$getSym(1)); |
| 1510 |
$setResult(result); |
| 1511 |
$EndCode |
| 1512 |
./ |
| 1513 |
letVariablesCS ::= letVariablesCS ',' typedInitializedVariableCS |
| 1514 |
/.$BeginCode |
| 1515 |
EList<VariableCS> result = (EList<VariableCS>)$getSym(1); |
| 1516 |
result.add((VariableCS)$getSym(3)); |
| 1517 |
$setResult(result); |
| 1518 |
$EndCode |
| 1519 |
./ |
| 1520 |
%End |
| 1521 |
|
| 1522 |
%Trailers |
| 1523 |
/. |
| 1524 |
$EndActions |
| 1525 |
} |
| 1526 |
./ |
| 1527 |
%End |