| /** |
| * <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$ |
| */ |
| grammar org.eclipse.ocl.examples.xtext.oclstdlib.OCLstdlib with org.eclipse.ocl.examples.xtext.essentialocl.EssentialOCL |
| |
| import "http://www.eclipse.org/emf/2002/Ecore" as ecore |
| import "platform:/resource/org.eclipse.ocl.examples.xtext.base/model/BaseCST.ecore" as base |
| import "platform:/resource/org.eclipse.ocl.examples.xtext.essentialocl/model/EssentialOCLCST.ecore" as essentialocl |
| import "platform:/resource/org.eclipse.ocl.examples.xtext.oclstdlib/model/OCLstdlibCST.ecore" |
| import "platform:/resource/org.eclipse.ocl.examples.pivot/model/Pivot.ecore" as pivot |
| import "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore" as types |
| //import "platform:/plugin/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore" as types |
| //import "http://www.eclipse.org/xtext/common/JavaVMTypes" as types |
| //generate OCLstdlib "http://www.eclipse.org/ocl/examples/xtext/oclstdlib/OCLstdlibCST" |
| |
| Library returns LibRootPackageCS: |
| (ownedLibrary+=LibraryCS ';')* |
| 'library' name=Name |
| (':' nsPrefix=Identifier '=' nsURI=URI)? |
| '{' (ownedNestedPackage+=PackageCS |
| | ('precedence' (ownedPrecedence+=PrecedenceCS)+ ';') |
| | ownedType+=ClassifierCS |
| | ownedAnnotation+=AnnotationElementCS)* |
| '}' |
| ; |
| |
| Identifier: |
| ID |
| | RestrictedKeywords |
| ; |
| |
| RestrictedKeywords: |
| 'annotation' |
| | 'conformsTo' |
| | 'documentation' |
| | 'extends' |
| | 'import' |
| | 'inv' |
| | 'iteration' |
| | 'left' |
| | 'library' |
| | 'operation' |
| | 'package' |
| | 'post' |
| | 'pre' |
| | 'precedence' |
| | 'property' |
| | 'right' |
| | 'static' |
| | 'super' |
| | 'type' |
| //| 'Lambda' |
| //| 'Tuple' |
| ; |
| |
| Name: |
| Identifier |
| | DOUBLE_QUOTED_STRING |
| | EssentialOCLReservedKeyword |
| | PrimitiveTypeIdentifier |
| | CollectionTypeIdentifier |
| ; |
| |
| AnyName: |
| Name |
| | 'Lambda' |
| | 'Tuple' |
| ; |
| |
| LibPathNameCS returns base::PathNameCS: |
| path+=LibPathElementCS ('::' path+=LibPathElementCS)*; |
| |
| LibPathElementCS returns base::PathElementCS: |
| element=[pivot::NamedElement|Name]; |
| |
| AccumulatorCS returns base::ParameterCS: |
| name=Identifier ':' ownedType=TypedRefCS |
| ; |
| |
| AnnotationCS returns base::AnnotationCS: |
| 'annotation' name=(Identifier|SINGLE_QUOTED_STRING) |
| ('(' ownedDetail+=DetailCS (',' ownedDetail+=DetailCS)* ')')? |
| (('{' ownedAnnotation+=AnnotationElementCS '}') |
| |';' |
| ) |
| ; |
| |
| AnnotationElementCS returns base::AnnotationElementCS: |
| AnnotationCS | DocumentationCS |
| ; |
| |
| ClassCS returns LibClassCS: |
| 'type' name=AnyName |
| (ownedTemplateSignature=TemplateSignatureCS)? |
| (':' metaTypeName=[MetaTypeName|AnyName])? |
| ('conformsTo' ownedSuperType+=TypedRefCS (',' ownedSuperType+=TypedRefCS)*)? |
| '{' (ownedOperation+=OperationCS |
| | ownedProperty+=LibPropertyCS |
| | ownedConstraint+=InvCS |
| | ownedAnnotation+=AnnotationElementCS)* '}' |
| ; |
| |
| ClassifierCS returns base::ClassifierCS: |
| ClassCS |
| ; |
| |
| DetailCS returns base::DetailCS: |
| name=(Name|SINGLE_QUOTED_STRING) '=' value+=(SINGLE_QUOTED_STRING|ML_SINGLE_QUOTED_STRING)* |
| ; |
| |
| DocumentationCS returns base::DocumentationCS: |
| {base::DocumentationCS} 'documentation' value=SINGLE_QUOTED_STRING? |
| ('(' ownedDetail+=DetailCS (',' ownedDetail+=DetailCS)* ')')? |
| ';' |
| ; |
| |
| InvCS returns LibConstraintCS: |
| stereotype='inv' (name=UnrestrictedName)? ':' specification=SpecificationCS ';' |
| ; |
| |
| LibIterationCS returns LibIterationCS: |
| 'iteration' name=Name |
| (ownedTemplateSignature=TemplateSignatureCS)? |
| '(' ownedIterator+=IteratorCS (',' ownedIterator+=IteratorCS)* |
| (';' ownedAccumulator+=AccumulatorCS (',' ownedAccumulator+=AccumulatorCS)*)? |
| ('|' ownedParameter+=ParameterCS (',' ownedParameter+=ParameterCS)*)? |
| ')' |
| ':' ownedType=TypedRefCS |
| ('=>' implementation=[types::JvmType|SINGLE_QUOTED_STRING])? |
| (('{' (ownedAnnotation+=AnnotationElementCS |
| | ownedConstraint+=PostCS |
| | ownedConstraint+=PreCS)* '}') |
| |';' |
| ) |
| ; |
| |
| IteratorCS returns base::ParameterCS: |
| name=Identifier ':' ownedType=TypedRefCS |
| ; |
| |
| LambdaTypeCS returns base::LambdaTypeCS: |
| name='Lambda' (ownedTemplateSignature=TemplateSignatureCS)? ownedContextType=LambdaContextTypeRefCS |
| '(' (ownedParameterType+=TypedRefCS (',' ownedParameterType+=TypedRefCS)*)? ')' |
| ':' ownedResultType=TypedRefCS |
| ; |
| |
| LambdaContextTypeRefCS returns base::TypedTypeRefCS: |
| pathName=LibPathNameCS |
| ; |
| |
| LibraryCS returns base::LibraryCS : |
| 'import' package=[pivot::Package|URI] |
| ; |
| |
| OperationCS returns base::OperationCS: |
| LibIterationCS|LibOperationCS |
| ; |
| |
| LibOperationCS returns LibOperationCS: |
| (static?='static')? 'operation' name=Name |
| (ownedTemplateSignature=TemplateSignatureCS)? |
| '(' (ownedParameter+=ParameterCS (',' ownedParameter+=ParameterCS)*)? ')' |
| ':' ownedType=TypedRefCS |
| ('precedence' '=' precedence=[pivot::Precedence|Name])? |
| ('=>' implementation=[types::JvmType|SINGLE_QUOTED_STRING])? |
| (('{' (ownedAnnotation+=AnnotationElementCS |
| | ownedConstraint+=PostCS |
| | ownedConstraint+=PreCS)* '}') |
| |';' |
| ) |
| ; |
| |
| PackageCS returns base::PackageCS: |
| 'package' name=Name |
| (':' nsPrefix=Identifier '=' nsURI=URI)? |
| '{' |
| (ownedNestedPackage+=PackageCS |
| | ownedType+=ClassifierCS |
| | ownedAnnotation+=AnnotationElementCS)* |
| '}' |
| ; |
| |
| ParameterCS returns base::ParameterCS: |
| name=Identifier ':' ownedType=TypedMultiplicityRefCS |
| ; |
| |
| LibPropertyCS returns LibPropertyCS: |
| (static?='static')? 'property' name=Name |
| ':' ownedType=TypedRefCS |
| ('=>' implementation=[types::JvmType|SINGLE_QUOTED_STRING])? |
| ( ('{' (ownedAnnotation+=AnnotationElementCS)* '}') |
| | ';' |
| ) |
| ; |
| |
| PostCS returns LibConstraintCS: |
| stereotype='post' (name=UnrestrictedName)? ':' specification=SpecificationCS ';' |
| ; |
| |
| PreCS returns LibConstraintCS: |
| stereotype='pre' (name=UnrestrictedName)? ':' specification=SpecificationCS ';' |
| ; |
| |
| PrecedenceCS returns PrecedenceCS: |
| ('left'|rightAssociative?='right') ':' name=Name |
| ; |
| |
| SpecificationCS returns essentialocl::ExpSpecificationCS: |
| ownedExpression=ExpCS; |
| |
| TemplateBindingCS returns base::TemplateBindingCS: |
| '(' ownedParameterSubstitution+=TemplateParameterSubstitutionCS (',' ownedParameterSubstitution+=TemplateParameterSubstitutionCS)* ')' |
| ; |
| |
| TemplateParameterSubstitutionCS returns base::TemplateParameterSubstitutionCS: |
| ownedActualParameter=TypeRefCS |
| ; |
| |
| TemplateSignatureCS returns base::TemplateSignatureCS: |
| '(' ownedTemplateParameter+=TypeParameterCS (',' ownedTemplateParameter+=TypeParameterCS)* ')' |
| ; |
| |
| LibTupleCS returns base::TupleTypeCS: |
| name='Tuple' '(' (ownedParts+=LibTuplePartCS (',' ownedParts+=LibTuplePartCS)*)? ')' |
| ; |
| |
| LibTuplePartCS returns base::TuplePartCS: |
| name=Identifier ':' ownedType=TypedRefCS |
| ; |
| |
| TypeParameterCS returns base::TypeParameterCS: |
| name=Identifier |
| ( ('extends' ownedExtends+=TypedRefCS ('&&' ownedExtends+=TypedRefCS)*) |
| | ('super' ownedSuper=TypedRefCS) |
| )? |
| ; |
| |
| TypeRefCS returns base::TypeRefCS: |
| TypedRefCS | WildcardTypeRefCS |
| ; |
| |
| TypedRefCS returns base::TypedRefCS: |
| LibTupleCS | TypedTypeRefCS | LambdaTypeCS |
| ; |
| |
| TypedMultiplicityRefCS returns base::TypedRefCS: |
| (LibTupleCS | TypedTypeRefCS | LambdaTypeCS) (multiplicity=MultiplicityCS)? |
| ; |
| |
| TypedTypeRefCS returns base::TypedTypeRefCS: |
| pathName=LibPathNameCS (ownedTemplateBinding=TemplateBindingCS)? |
| ; |
| |
| WildcardTypeRefCS returns base::WildcardTypeRefCS: |
| {base::WildcardTypeRefCS} '?' |
| ( ('extends' extends=TypedRefCS) |
| | ('super' super=TypedRefCS) |
| )? |
| ; |