| /** |
| * <copyright> |
| * |
| * Copyright (c) 2010 E.D.Willink and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * E.D.Willink - initial API and implementation |
| * |
| * </copyright> |
| * |
| * $Id: CompleteOCL.xtext,v 1.13 2011/05/21 14:55:54 ewillink Exp $ |
| */ |
| grammar org.eclipse.ocl.examples.xtext.completeocl.CompleteOCL |
| with org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL |
| |
| import "http://www.eclipse.org/emf/2002/Ecore" as ecore |
| import "http://www.eclipse.org/ocl/3.1.0/BaseCST" as base |
| import "http://www.eclipse.org/ocl/3.1.0/EssentialOCLCST" as essentialocl |
| import "http://www.eclipse.org/ocl/3.1.0/Pivot" as pivot |
| import "http://www.eclipse.org/ocl/3.1.0/CompleteOCLCST" |
| //generate completeOCL "http://www.eclipse.org/ocl/examples/xtext/completeocl/CompleteOCL" |
| CompleteOCLDocumentCS returns CompleteOCLDocumentCS: |
| (ownedImport+=ImportCS | ownedInclude+=IncludeCS | ownedLibrary+=LibraryCS)* |
| (packages+=PackageDeclarationCS | contexts+=ContextDeclCS)*; |
| |
| terminal UNQUOTED_STRING: // Never forward parsed; just provides a placeholder |
| '£$%^£$%^' // for reverse serialisation of embedded OCL |
| ; |
| |
| CompleteOCLNavigationOperatorCS returns essentialocl::NavigationOperatorCS: |
| name=('^' | '^^'); |
| |
| NavigationOperatorCS returns essentialocl::NavigationOperatorCS: |
| EssentialOCLNavigationOperatorCS | CompleteOCLNavigationOperatorCS; |
| |
| UnrestrictedName returns ecore::EString: |
| EssentialOCLUnrestrictedName |
| //| 'body' |
| //| 'context' |
| //| 'def' |
| | 'derive' |
| //| 'endpackage' |
| | 'import' |
| | 'include' |
| | 'init' |
| //| 'inv' |
| | 'library' |
| //| 'package' |
| //| 'post' |
| //| 'pre' |
| //| 'static' |
| ; |
| |
| PrimitiveTypeIdentifier: |
| 'Boolean' |
| | 'Integer' |
| | 'Real' |
| | 'String' |
| | 'UnlimitedNatural' |
| | 'OclAny' |
| | 'OclInvalid' |
| | 'OclMessage' |
| | 'OclState' |
| | 'OclVoid'; |
| |
| ClassifierContextDeclCS returns ClassifierContextDeclCS: |
| 'context' (selfName=UnrestrictedName)? |
| pathName=PathNameCS |
| (('inv' invariants+=ConstraintCS) |
| | definitions+=DefCS |
| )+; |
| |
| ConstraintCS returns base::ConstraintCS: |
| (name=UnrestrictedName ('(' messageSpecification=SpecificationCS ')')?)? ':' specification=SpecificationCS; |
| |
| ContextDeclCS returns ContextDeclCS: |
| PropertyContextDeclCS |
| | ClassifierContextDeclCS |
| | OperationContextDeclCS; |
| |
| DefCS returns DefCS: |
| DefOperationCS|DefPropertyCS; |
| |
| DefOperationCS returns DefOperationCS: |
| (static?='static')? 'def' UnrestrictedName? ':' |
| name=UnrestrictedName '(' (parameters+=DefParameterCS (',' parameters+=DefParameterCS)*)? ')' ':' (ownedType=TypeExpCS)? |
| '=' specification=SpecificationCS; |
| |
| DefParameterCS returns base::ParameterCS: |
| name=UnrestrictedName ':' ownedType=TypeExpCS; |
| |
| DefPropertyCS returns DefPropertyCS: |
| (static?='static')? 'def' UnrestrictedName? ':' name=UnrestrictedName ':' ownedType=TypeExpCS |
| '=' specification=SpecificationCS; |
| |
| ImportCS returns base::ImportCS: |
| 'import' (name=Identifier ':')? pathName=URIPathNameCS (all?='::' '*')?; |
| |
| IncludeCS returns IncludeCS: |
| 'include' namespace=[pivot::Namespace|URI]; |
| |
| LibraryCS returns base::LibraryCS: |
| 'library' package=[pivot::Package|URI]; |
| |
| OperationContextDeclCS returns OperationContextDeclCS: |
| 'context' pathName=PathNameCS '(' |
| (parameters+=ParameterCS (',' parameters+=ParameterCS)*)? |
| ')' ':' (ownedType=TypeExpCS)? |
| (('pre' preconditions+=ConstraintCS) |
| | ('post' postconditions+=ConstraintCS) |
| | ('body' UnrestrictedName? ':' bodies+=SpecificationCS) |
| )*; |
| |
| PackageDeclarationCS returns PackageDeclarationCS: |
| 'package' pathName=PathNameCS (contexts+=ContextDeclCS)* 'endpackage'; |
| |
| ParameterCS returns base::ParameterCS: |
| (name=UnrestrictedName ':')? ownedType=TypeExpCS; |
| |
| PropertyContextDeclCS returns PropertyContextDeclCS: |
| 'context' pathName=PathNameCS ':' (ownedType=TypeExpCS)? |
| (('derive' derivedInvariants+=ConstraintCS) |
| | ('init' ':' defaultExpressions+=SpecificationCS) |
| )*; |
| |
| SpecificationCS returns essentialocl::ExpSpecificationCS: |
| ownedExpression=ExpCS | exprString=UNQUOTED_STRING; |
| |
| //--------------------------------------------------------------------------------- |
| // EssentialOCL overrides |
| //--------------------------------------------------------------------------------- |
| NavigatingArgExpCS returns essentialocl::ExpCS: |
| ({OCLMessageArgCS} '?') |
| | ExpCS |
| ; |