Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars')
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.g535
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.tokens53
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.g854
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.tokens67
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.g998
-rw-r--r--extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.tokens67
6 files changed, 0 insertions, 2574 deletions
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.g b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.g
deleted file mode 100644
index ff681e74e42..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.g
+++ /dev/null
@@ -1,535 +0,0 @@
-grammar CollaborationUseLabel;
-
-options {
- language = Java;
-}
-
-@header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.papyrus.parsers.texteditor.collaborationuselabel.IContext;
-import org.eclipse.papyrus.parsers.util.IErrorReporter;
-import org.eclipse.papyrus.parsers.util.NameException;
-import org.eclipse.papyrus.parsers.util.MultiplicityException;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-import org.eclipse.papyrus.parsers.util.Messages;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Collaboration;
-import org.eclipse.uml2.uml.CollaborationUse;
-import org.eclipse.uml2.uml.VisibilityKind;
-}
-
-@lexer::header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import org.eclipse.uml2.uml.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Vector;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-
-import org.eclipse.papyrus.parsers.texteditor.collaborationuselabel.IContext;
-}
-
-@members{
- public CollaborationUseLabelParser(TokenStream lexer, CollaborationUse element, IErrorReporter reporter) {
- this(lexer);
- setCollaborationUse(element);
- setErrorReporter(reporter);
- }
-
- /**
- * Validation state (true = validation : does not modify the CollaborationUse)
- */
- private boolean isValidation = false;
-
-
- private static final boolean DEBUG = false;
- /**
- * @return the isValidation boolean
- */
- public boolean isValidation() {
- return isValidation;
- }
-
- /**
- * @param isValidation the isValidation to set (true -> do not modify the CollaborationUse)
- */
- public void setValidation(boolean isValidation) {
- this.isValidation = isValidation;
- }
-
- private Package nearestPackage;
-
- /**
- * Modified CollaborationUse
- */
- private CollaborationUse element;
-
- /**
- * @return the CollaborationUse
- */
- public CollaborationUse getCollaborationUse() {
- return element;
- }
-
- /**
- * @param element the CollaborationUse to set
- */
- public void setCollaborationUse(CollaborationUse element) {
- this.element = element;
- this.nearestPackage = element.getNearestPackage();
- }
-
- /** debug mode */
- protected final boolean debugMode = false;
-
- /**
- * Debug method (~System.out.println)
- */
- private void debug(Object debug) {
- if(debugMode) {
- System.out.println(debug);
- }
- }
-
- /**
- * Error method (~System.err.println)
- */
- private void error(Object debug) {
- if(debugMode) {
- System.err.println(debug);
- }
- }
-
- /**
- * Context (for completion processor)
- */
- private int context = IContext.DEFAULT;
-
- /**
- * @return the context
- */
- public int getContext() {
- return context;
- }
-
- /**
- * @param context the context to set
- */
- public void setContext(int context) {
- this.context = context;
- }
-
- // all possible modified elements on CollaborationUse
- String name;
- VisibilityKind visibility = VisibilityKind.PUBLIC_LITERAL;
- Collaboration type=null;
-
-
- /**
- * Apply values to the CollaborationUse. <BR>
- * Modifications can not be applied directly. The parser must wait the end,
- * until it reaches the end of the label. If the end is reached without any error,
- * new values can be applied to the target CollaborationUse.
- */
- private void applyValues() {
- if(!isValidation){
- debug("\nvalues applied :");
- debug("+ name: "+name);
- debug("+ visibility: "+visibility);
- debug("+ type: "+type);
-
- element.setName(name);
- element.setVisibility(visibility);
- element.setType(type);
- }
- }
-
-
- /** reporting errors */
- private IErrorReporter errorReporter = null;
-
- public void setErrorReporter(IErrorReporter errorReporter) {
- this.errorReporter = errorReporter;
- }
-
- public IErrorReporter getErrorReporter() {
- return errorReporter;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getErrorMessage(RecognitionException exception, String[] arg1) {
- if (exception instanceof NameException) {
- return "Please enter a correct name for the property";
- }
- return super.getErrorMessage(exception, arg1);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void emitErrorMessage(String msg) {
- errorReporter.reportError(msg);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recover(IntStream arg0, RecognitionException arg1) {
- // do nothing
- }
-}
-
-label :
- (visibility {context = IContext.VISIBILITY; })?
- name
- COLON
- {
- context = IContext.AFTER_COLON;
- }
- collaboration_use_type { context = IContext.COLLABORATION_USE_TYPE; }
- {
- applyValues();
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- String index = Integer.toString(mte.index);
- String description = mte.getLocalizedMessage().substring(mte.getLocalizedMessage().indexOf('('),
- mte.getLocalizedMessage().length());
- String tokenText = mte.token.getText();
- String text = Messages.bind(Messages.MismatchedToken, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- } catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
-
- } catch [RecognitionException re] {
-
- reportError(re);
- throw (re);
-
- }
-
-
-visibility
- :
- (
- ( PLUS { visibility = VisibilityKind.PUBLIC_LITERAL; } )
- | ( MINUS { visibility = VisibilityKind.PRIVATE_LITERAL;} )
- | ( SHARP { visibility = VisibilityKind.PROTECTED_LITERAL;} )
- | ( TILDE { visibility = VisibilityKind.PACKAGE_LITERAL;} )
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("VisibilityRule"));
- }
-
-
-name
- :
- id=IDENTIFIER
- {
- name = id.getText();
- context = IContext.NAME;
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException(Messages.NameMissing));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-collaboration_use_type
- :
- (WS)*
- ( type |
- '<Undefined>'
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("CollaborationUseTypeRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- throw new RuntimeException("Waiting for a valid type (Collaboration) or <Undefined>");
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-type
- :
- id=IDENTIFIER
- {
- String typeName = id.getText() ;
- Collaboration utilType = PackageUtil.findCollaborationByName(nearestPackage, typeName);
-
- if (utilType != null) {
- type = utilType;
- } else {
- // the type actually does not exist
- throw new TypeRecognitionException("Collaboration "+typeName+" not found for CollaborationUse "+element.getName(),typeName);
- }
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("TypeRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-NL
- : ( '\r' '\n'
- | '\n' '\r' //Improbable
- | '\r'
- | '\n'
- )
- { $channel=HIDDEN;}
- ;
-
-
-WS
- : (' ' | '\t' | '\f')+ {$channel=HIDDEN;}
- ;
-
-QUESTION_MARK
- : '?'
- ;
-
-LNOT
- : '!'
- ;
-
-DOUBLE_QUOTE
- : '\"'
- ;
-
-SINGLE_QUOTE
- : '\''
- ;
-
-LPAREN
- : '('
- ;
-
-RPAREN
- : ')'
- ;
-
-LSQUARE
- : '['
- ;
-
-RSQUARE
- : ']'
- ;
-
-LCURLY
- : '{'
- ;
-
-DOUBLE_LCURLY
- : '{{' ;
-
-RCURLY
- : '}'
- ;
-
-DOUBLE_RCURLY
- : '}}'
- ;
-
-LOGICAL_AND
- : '&'
- ;
-
-DOUBLE_LOGICAL_AND
- : '&&'
- ;
-
-PIPE
- : '|'
- ;
-
-DOUBLE_PIPE
- : '||'
- ;
-
-POINT
- : '.'
- ;
-
-RANGE
- : '..'
- ;
-
-COMMA
- : ','
- ;
-
-SEMI
- : ';'
- ;
-
-SHARP
- : '#'
- ;
-
-TILDE
- : '~'
- ;
-
-COLON
- : ':'
- ;
-
-FOUR_POINTS
- : '::'
- ;
-
-RULE_ASSIGN
- : '::=' ;
-
-ARROW
- : '->'
- ;
-
-STAR
- : '*'
- ;
-
-DIV
- : '/'
- ;
-
-PLUS
- : '+'
- ;
-
-MINUS
- : '-'
- ;
-
-EQ
- : '='
- ;
-
-
-ISEQ
- : '=='
- ;
-
-ISNE
- : '!='
- ;
-
-LT : '<';
-
-DOUBLE_LT
- : '<<'
- ;
-
-LE
- : '<='
- ;
-
-GT
- : '>'
- ;
-
-DOUBLE_GT
- : '>>'
- ;
-
-GE
- : '>='
- ;
-
-
-INCR
- : '++'
- ;
-
-DECR
- : '--'
- ;
-
-CALLOPERATION
- : ':='
- ;
-
-fragment
-ALPHA
- : 'a'..'z'
- | 'A'..'Z'
- ;
-
-
-UNDERSCORE
- : '_'
- ;
-
-RANGE_VALUE
- : c1=INTEGER {setText("");} '..'
- ( c2=INTEGER { setText($c2.text);}
- | c2=STAR { setText("-1");})
- {
- setText($text + ","+ $c1.text);
- }
- ;
-
-REAL
- : INTEGER '.' INTEGER
- ;
-
-fragment
-INTEGER_OR_REAL_OR_RANGE !
- :
- (INTEGER RANGE) => RANGE_VALUE
- | (INTEGER POINT) => REAL
- | (INTEGER) => INTEGER
- ;
-
-INTEGER
- : '0'..'9'+;
-
-IDENTIFIER
- : (ALPHA|'0'..'9'|UNDERSCORE)+
- ;
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.tokens b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.tokens
deleted file mode 100644
index 68002a66641..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/CollaborationUseLabel.tokens
+++ /dev/null
@@ -1,53 +0,0 @@
-COMMA=30
-DOUBLE_LT=41
-ISEQ=38
-MINUS=6
-INCR=46
-SHARP=7
-DOUBLE_RCURLY=23
-DECR=47
-ARROW=34
-DOUBLE_GT=44
-RULE_ASSIGN=33
-TILDE=8
-PIPE=26
-DOUBLE_PIPE=27
-INTEGER=51
-QUESTION_MARK=12
-RCURLY=22
-NL=11
-LCURLY=20
-LE=42
-RPAREN=17
-LPAREN=16
-SINGLE_QUOTE=15
-PLUS=5
-REAL=53
-LSQUARE=18
-RANGE=29
-FOUR_POINTS=32
-DOUBLE_LCURLY=21
-POINT=28
-WS=10
-ALPHA=49
-EQ=37
-LT=40
-GT=43
-DOUBLE_QUOTE=14
-RSQUARE=19
-DOUBLE_LOGICAL_AND=25
-RANGE_VALUE=52
-T__55=55
-SEMI=31
-GE=45
-LNOT=13
-LOGICAL_AND=24
-ISNE=39
-COLON=4
-INTEGER_OR_REAL_OR_RANGE=54
-DIV=36
-IDENTIFIER=9
-STAR=35
-UNDERSCORE=50
-CALLOPERATION=48
-'<Undefined>'=55
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.g b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.g
deleted file mode 100644
index 96559bb2235..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.g
+++ /dev/null
@@ -1,854 +0,0 @@
-grammar ParameterLabel;
-
-options {
- language = Java;
-}
-
-@header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.papyrus.parsers.texteditor.parameterlabel.IContext;
-import org.eclipse.papyrus.parsers.util.IErrorReporter;
-import org.eclipse.papyrus.parsers.util.NameException;
-import org.eclipse.papyrus.parsers.util.MultiplicityException;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-import org.eclipse.papyrus.parsers.util.Messages;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.papyrus.uml.tools.utils.ParameterUtil;
-import org.eclipse.papyrus.uml.tools.utils.TemplateSignatureUtil;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.TemplateableElement;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.VisibilityKind;
-}
-
-@lexer::header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import org.eclipse.uml2.uml.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Vector;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-
-import org.eclipse.papyrus.parsers.texteditor.parameterlabel.IContext;
-}
-
-@members{
- public ParameterLabelParser(TokenStream lexer, Parameter parameter, IErrorReporter reporter) {
- this(lexer);
- setParameter(parameter);
- setErrorReporter(reporter);
- this.modifiersUsed = new HashMap<String, Boolean>();
- modifiersUsed.put("ordered", false);
- modifiersUsed.put("unique", false);
- modifiersUsed.put("nonunique", false);
- modifiersUsed.put("stream", false);
- modifiersUsed.put("exception", false);
-
- }
-
- /**
- * Validation state (true = validation : does not modify the parameter
- */
- private boolean isValidation = false;
-
-
- private static final boolean DEBUG = false;
- /**
- * @return the isValidation boolean
- */
- public boolean isValidation() {
- return isValidation;
- }
-
- /**
- * @param isValidation the isValidation to set (true -> do not modify the parameter)
- */
- public void setValidation(boolean isValidation) {
- this.isValidation = isValidation;
- }
-
- private Package nearestPackage;
-
- /**
- * Modified Parameter
- */
- private Parameter parameter;
-
- /**
- * @return the parameter
- */
- public Parameter getParameter() {
- return parameter;
- }
-
- /**
- * @param parameter the parameter to set
- */
- public void setParameter(Parameter parameter) {
- this.parameter = parameter;
- this.nearestPackage = parameter.getNearestPackage();
- }
-
- /** debug mode */
- protected final boolean debugMode = false;
-
- /**
- * Debug method (~System.out.println)
- */
- private void debug(Object debug) {
- if(debugMode) {
- System.out.println(debug);
- }
- }
-
- /**
- * Error method (~System.err.println)
- */
- private void error(Object debug) {
- if(debugMode) {
- System.err.println(debug);
- }
- }
-
- /**
- * Context (for completion processor)
- */
- private int context = IContext.DEFAULT;
-
- /**
- * @return the context
- */
- public int getContext() {
- return context;
- }
-
- /**
- * @param context the context to set
- */
- public void setContext(int context) {
- this.context = context;
- }
-
- // all possible modified elements on parameter (with default values : necessary ?!)
- String name;
- VisibilityKind visibility = VisibilityKind.PUBLIC_LITERAL;
- ParameterDirectionKind direction = ParameterDirectionKind.IN_LITERAL;
- Type type=null;
- int lowerMultiplicity = 1; // default multiplicity = [1..1]
- int upperMultiplicity = 1; // default multiplicity = [1..1]
- String defaultValue=null;
- // parameter modifiers
- boolean isUnique = false; // default value = true but easier to use default = nonunique
- boolean isOrdered = false; // default value = false
- boolean isException = false; // default value = false
- boolean isStream = false; // default value = false
-
-
- /**
- * Apply values to the parameter. <BR>
- * Modifications can not be applied directly. The parser must wait the end,
- * until it reaches the end of the label. If the end is reached without any error,
- * new values can be applied to the target parameter.
- */
- private void applyValues() {
- if(!isValidation){
- debug("\nvalues applied :");
- debug("+ name: "+name);
- debug("+ visibility: "+visibility);
- debug("+ direction: "+direction);
- debug("+ type: "+type);
- debug("+ lower Multiplicity: "+lowerMultiplicity);
- debug("+ upper Multiplicity: "+upperMultiplicity);
- debug("+ default Value: "+defaultValue);
- debug("+ Parameter modifiers");
- debug("+ isUnique: "+isUnique);
- debug("+ isOrdered: "+isOrdered);
- debug("+ isException: "+isException);
- debug("+ isStream: "+isStream);
-
- parameter.setName(name);
- parameter.setVisibility(visibility);
- parameter.setDirection(direction);
- parameter.setType(type);
- parameter.setLower(lowerMultiplicity);
- parameter.setUpper(upperMultiplicity);
- parameter.setDefault(defaultValue);
- parameter.setIsUnique(isUnique);
- parameter.setIsOrdered(isOrdered);
- parameter.setIsException(isException);
- parameter.setIsStream(isStream);
- }
- }
-
- // vector that keeps modifiers already used (used for completion)
- public Map<String, Boolean> modifiersUsed;
-
- /**
- * @return the modifiersUsed
- */
- public Map<String, Boolean> getModifiersUsed() {
- return modifiersUsed;
- }
-
- /**
- * @param modifiersUsed the modifiersUsed to set
- */
- public void setModifiersUsed(Map<String, Boolean> modifiersUsed) {
- this.modifiersUsed = modifiersUsed;
- }
-
- /** reporting errors */
- private IErrorReporter errorReporter = null;
-
- public void setErrorReporter(IErrorReporter errorReporter) {
- this.errorReporter = errorReporter;
- }
-
- public IErrorReporter getErrorReporter() {
- return errorReporter;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getErrorMessage(RecognitionException exception, String[] arg1) {
- if (exception instanceof NameException) {
- return "Please enter a correct name for the parameter";
- }
- return super.getErrorMessage(exception, arg1);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void emitErrorMessage(String msg) {
- errorReporter.reportError(msg);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recover(IntStream arg0, RecognitionException arg1) {
- throw new RuntimeException("no recover", arg1);
- // do nothing
- }
-
-}
-
-label :
- (WS)*
- (visibility (WS)* {context = IContext.VISIBILITY; } )?
- (direction (WS)* {context = IContext.DIRECTION; } )?
- name (WS)*
- COLON {context = IContext.AFTER_COLON;}
- parameter_type { context = IContext.MULTIPLICITY; }
- (fullMultiplicity { context = IContext.AFTER_MULTIPLICITY; } (WS)*)?
- (defaultValue { context = IContext.DEFAULT_VALUE; })?
- (parameterModifiers { context = IContext.PARAMETER_MODIFIERS; } (WS)*)?
- {
- applyValues();
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- String index = Integer.toString(mte.index);
- String description = mte.getLocalizedMessage().substring(mte.getLocalizedMessage().indexOf('('),
- mte.getLocalizedMessage().length());
- String tokenText = mte.token.getText();
- String text = Messages.bind(Messages.MismatchedToken, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- } catch [RecognitionException re] {
- reportError(re);
- throw (re);
-
- }
-
-
-visibility
- :
- (
- ( PLUS { visibility = VisibilityKind.PUBLIC_LITERAL; } )
- | ( MINUS { visibility = VisibilityKind.PRIVATE_LITERAL;} )
- | ( SHARP { visibility = VisibilityKind.PROTECTED_LITERAL;} )
- | ( TILDE { visibility = VisibilityKind.PACKAGE_LITERAL;} )
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("VisibilityRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
-
- }
-
-
-direction
- :
- (
- ( IN { direction = ParameterDirectionKind.IN_LITERAL; } )
- | ( OUT { direction = ParameterDirectionKind.OUT_LITERAL;} )
- | ( INOUT { direction = ParameterDirectionKind.INOUT_LITERAL;} )
- | ( RETURN { direction = ParameterDirectionKind.RETURN_LITERAL;} )
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("Direction"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
-
- }
-
-name
- :
- id=IDENTIFIER
- {
- name = id.getText();
- context = IContext.NAME;
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException(Messages.NameMissing));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-parameter_type
- :
- (WS)*
- ( type |
- '<Undefined>'
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("ParameterTypeRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- throw new RuntimeException("Waiting for a valid type or <Undefined>");
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-type
- @init{
- StringBuffer buffer = new StringBuffer();
- }
- :
- id=IDENTIFIER {buffer.append(id.getText());}
- (WS {//System.err.println("space added");
- buffer.append(" ");})*
- (
- id1=IDENTIFIER {buffer.append(id1.getText());}
- (WS {//System.err.println("space added");
- buffer.append(" ");})*
- )*
- {
- String typeName = buffer.toString().trim() ;
- //System.err.println("typeName: "+typeName);
- Type utilType = PackageUtil.findTypeByName(nearestPackage, typeName);
- // type = findTypeByName(typeName, parameter);
- // The type has not been found, but it may have been declared in the context of a template.
- if(utilType != null) {
- if (utilType instanceof TemplateableElement) {
- TemplateableElement template = (TemplateableElement)utilType;
- if (template.isTemplate()) {
- throw new UnboundTemplateRecognitionException("Parameters of template " + typeName + " are not bound.",
- template) ;
- } else {
- type = utilType;
- }
- }
- else {
- type = utilType;
- }
- } else {
- // The type has not been found, but it may have been declared in the context of a template.
- if (parameter.getOwner() instanceof TemplateableElement) {
- TemplateableElement template = (TemplateableElement)parameter.getOwner() ;
- if (template.isTemplate()) {
- utilType = TemplateSignatureUtil.findTypeByName(template.getOwnedTemplateSignature(), typeName) ;
- }
- }
- if (utilType == null) // the type actually does not exist
- throw new TypeRecognitionException("Type "+typeName+" not found for parameter "+parameter.getName(),typeName);
- else if (utilType instanceof TemplateableElement && ((TemplateableElement)utilType).isTemplate()) {
- throw new UnboundTemplateRecognitionException("Parameters of template " + typeName + " are not bound.",
- (TemplateableElement)utilType) ;
- }
- else {
- type = utilType;
- }
- }
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("TypeRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-fullMultiplicity
- :
- LSQUARE
- { context = IContext.IN_MULTIPLICITY; }
- /*(
- ( lowerMultiplicity POINT_POINT upperMultiplicity {
- if(lowerMultiplicity > upperMultiplicity && upperMultiplicity != -1) {
- throw new MultiplicityException("Lower bound ("+lowerMultiplicity+") is greater than upper bound ("+upperMultiplicity+")");
- }
- }
- )
- | upperMultiplicity {
- if(upperMultiplicity == -1) {
- lowerMultiplicity = 0;
- } else {
- lowerMultiplicity = upperMultiplicity;
- }
- }
- )*/
- (
- ra=RANGE_VALUE {
- // retrieving values. text = upper ',' lower
- String value = $ra.text;
- upperMultiplicity = Integer.parseInt(value.substring(0, value.lastIndexOf(',')));
- lowerMultiplicity = Integer.parseInt(value.substring(value.lastIndexOf(',') + 1, value.length()));
-
- if (lowerMultiplicity > upperMultiplicity && upperMultiplicity != -1) {
- throw new MultiplicityException("Lower bound (" + lowerMultiplicity
- + ") is greater than upper bound (" + upperMultiplicity + ")");
- }
-
- }
- | up=INTEGER {
- upperMultiplicity = Integer.parseInt($up.text);
- lowerMultiplicity = upperMultiplicity;
- }
- )
- RSQUARE
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("FullMultiplicityRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-
-lowerMultiplicity
- :
- in=INTEGER
- {
- lowerMultiplicity = Integer.parseInt(in.getText());
- }
- ;
-
-upperMultiplicity
- :
- um=unlimitedNatural
- {
- upperMultiplicity = um.value;
- }
- ;
-
-unlimitedNatural returns [int value = 0 ]
- :
- ( STAR { retval.value = -1; }
- | in=INTEGER { retval.value = Integer.parseInt(in.getText()); }
- )
- ;
-
-defaultValue
- :
- EQ dv = expression
- {
- // remove spaces at the begining
- defaultValue = dv.value.trim();
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("DefaultValueRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-expression returns [String value = ""]
- @init{
- StringBuffer buffer = new StringBuffer();
- }
- :
- (
- options { greedy=false; }
- :
-
- id=~(LCURLY)
- {
- buffer.append(id.getText());
- }
- )+
- {
- retval.value = buffer.toString();
- }
- ;
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-parameterModifiers
- :
- LCURLY (WS)*
- { context = IContext.PARAMETER_MODIFIER; }
- parameterModifier (WS)*
- (
- { context = IContext.PARAMETER_MODIFIER; }
- COMMA (WS)* parameterModifier (WS)*
- )*
- RCURLY
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("DefaultValueRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-parameterModifier
- :
- (
- 'ordered' { isOrdered = true; modifiersUsed.put("ordered", true); }
- | 'unique' { isUnique = true; modifiersUsed.put("unique", true); modifiersUsed.put("nonunique", true);}
- | 'nonunique' { isUnique = false; modifiersUsed.put("unique", true); modifiersUsed.put("nonunique", true);}
- | 'exception' { isException = true; modifiersUsed.put("exception", true);}
- | 'stream' { isStream = true; modifiersUsed.put("stream", true);}
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("ParameterModifierRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-NL
- : ( '\r' '\n'
- | '\n' '\r' //Improbable
- | '\r'
- | '\n'
- )
- { $channel=HIDDEN;}
- ;
-
-
-WS
- : (' ' | '\t' | '\f')+ // {$channel=HIDDEN;}
- ;
-
-QUESTION_MARK
- : '?'
- ;
-
-LNOT
- : '!'
- ;
-
-DOUBLE_QUOTE
- : '\"'
- ;
-
-SINGLE_QUOTE
- : '\''
- ;
-
-LPAREN
- : '('
- ;
-
-RPAREN
- : ')'
- ;
-
-LSQUARE
- : '['
- ;
-
-RSQUARE
- : ']'
- ;
-
-LCURLY
- : '{'
- ;
-
-DOUBLE_LCURLY
- : '{{' ;
-
-RCURLY
- : '}'
- ;
-
-DOUBLE_RCURLY
- : '}}'
- ;
-
-LOGICAL_AND
- : '&'
- ;
-
-DOUBLE_LOGICAL_AND
- : '&&'
- ;
-
-PIPE
- : '|'
- ;
-
-DOUBLE_PIPE
- : '||'
- ;
-
-POINT
- : '.'
- ;
-
-RANGE
- : '..'
- ;
-
-COMMA
- : ','
- ;
-
-SEMI
- : ';'
- ;
-
-SHARP
- : '#'
- ;
-
-TILDE
- : '~'
- ;
-
-COLON
- : ':'
- ;
-
-FOUR_POINTS
- : '::'
- ;
-
-RULE_ASSIGN
- : '::=' ;
-
-ARROW
- : '->'
- ;
-
-STAR
- : '*'
- ;
-
-DIV
- : '/'
- ;
-
-PLUS
- : '+'
- ;
-
-MINUS
- : '-'
- ;
-
-EQ
- : '='
- ;
-
-
-ISEQ
- : '=='
- ;
-
-ISNE
- : '!='
- ;
-
-LT : '<';
-
-DOUBLE_LT
- : '<<'
- ;
-
-LE
- : '<='
- ;
-
-GT
- : '>'
- ;
-
-DOUBLE_GT
- : '>>'
- ;
-
-GE
- : '>='
- ;
-
-
-INCR
- : '++'
- ;
-
-DECR
- : '--'
- ;
-
-CALLOPERATION
- : ':='
- ;
-
-IN
- : 'in'
- ;
-
-OUT
- : 'out'
- ;
-
-INOUT
- : 'inout'
- ;
-
-RETURN
- : 'return'
- ;
-
-fragment
-ALPHA
- : 'a'..'z'
- | 'A'..'Z'
- ;
-
-
-UNDERSCORE
- : '_'
- ;
-
-RANGE_VALUE
- : c1=INTEGER {setText("");} '..'
- ( c2=INTEGER { setText($c2.text);}
- | c2=STAR { setText("-1");})
- {
- setText($text + ","+ $c1.text);
- }
- ;
-
-REAL
- : INTEGER '.' INTEGER
- ;
-
-fragment
-INTEGER_OR_REAL_OR_RANGE !
- :
- (INTEGER RANGE) => RANGE_VALUE
- | (INTEGER POINT) => REAL
- | (INTEGER) => INTEGER
- ;
-
-INTEGER
- : '0'..'9'+;
-
-IDENTIFIER
- : (ALPHA|'0'..'9'|UNDERSCORE)+
- ;
-
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.tokens b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.tokens
deleted file mode 100644
index 07057d276b3..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/ParameterLabel.tokens
+++ /dev/null
@@ -1,67 +0,0 @@
-DOUBLE_LT=47
-COMMA=22
-ISEQ=44
-MINUS=7
-INCR=52
-SHARP=8
-DOUBLE_RCURLY=32
-DECR=53
-ARROW=42
-DOUBLE_GT=50
-OUT=11
-RULE_ASSIGN=41
-TILDE=9
-PIPE=35
-DOUBLE_PIPE=36
-INTEGER=17
-RCURLY=23
-QUESTION_MARK=25
-NL=24
-LCURLY=21
-T__62=62
-LE=48
-RPAREN=30
-T__61=61
-LPAREN=29
-T__59=59
-PLUS=6
-SINGLE_QUOTE=28
-REAL=57
-RANGE=38
-LSQUARE=15
-FOUR_POINTS=40
-DOUBLE_LCURLY=31
-POINT=37
-WS=4
-ALPHA=55
-EQ=20
-T__64=64
-LT=46
-GT=49
-DOUBLE_QUOTE=27
-RSQUARE=18
-DOUBLE_LOGICAL_AND=34
-RANGE_VALUE=16
-IN=10
-SEMI=39
-GE=51
-LNOT=26
-T__63=63
-ISNE=45
-RETURN=13
-LOGICAL_AND=33
-INOUT=12
-COLON=5
-INTEGER_OR_REAL_OR_RANGE=58
-DIV=43
-IDENTIFIER=14
-STAR=19
-T__60=60
-UNDERSCORE=56
-CALLOPERATION=54
-'unique'=61
-'nonunique'=62
-'ordered'=60
-'stream'=64
-'exception'=63
-'<Undefined>'=59
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.g b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.g
deleted file mode 100644
index 79773d25b5b..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.g
+++ /dev/null
@@ -1,998 +0,0 @@
-grammar PropertyLabel;
-
-options {
- language = Java;
-}
-
-@header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.papyrus.parsers.texteditor.propertylabel.IContext;
-import org.eclipse.papyrus.parsers.util.IErrorReporter;
-import org.eclipse.papyrus.parsers.util.NameException;
-import org.eclipse.papyrus.parsers.util.MultiplicityException;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-import org.eclipse.papyrus.parsers.util.Messages;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.papyrus.uml.tools.utils.PropertyUtil;
-import org.eclipse.papyrus.uml.tools.utils.TemplateSignatureUtil;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.TemplateableElement;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.VisibilityKind;
-}
-
-@lexer::header {
-package org.eclipse.papyrus.parsers.antlr;
-
-import org.eclipse.uml2.uml.*;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Vector;
-import org.eclipse.papyrus.parsers.util.TypeRecognitionException;
-import org.eclipse.papyrus.parsers.util.UnboundTemplateRecognitionException;
-
-import org.eclipse.papyrus.parsers.texteditor.propertylabel.IContext;
-}
-
-@members{
- public PropertyLabelParser(TokenStream lexer, Property property, IErrorReporter reporter) {
- this(lexer);
- setProperty(property);
- setErrorReporter(reporter);
- this.modifiersUsed = new HashMap<String, Boolean>();
- modifiersUsed.put("readOnly", false);
- modifiersUsed.put("union", false);
- modifiersUsed.put("ordered", false);
- modifiersUsed.put("unique", false);
- modifiersUsed.put("nonunique", false);
- modifiersUsed.put("subsets ", false);
- modifiersUsed.put("redefines ", false);
-
- }
-
- /**
- * Validation state (true = validation : does not modify the property
- */
- private boolean isValidation = false;
-
-
- private static final boolean DEBUG = false;
- /**
- * @return the isValidation boolean
- */
- public boolean isValidation() {
- return isValidation;
- }
-
- /**
- * @param isValidation the isValidation to set (true -> do not modify the property)
- */
- public void setValidation(boolean isValidation) {
- this.isValidation = isValidation;
- }
-
- private Package nearestPackage;
-
- /**
- * Modified Property
- */
- private Property property;
-
- /**
- * @return the property
- */
- public Property getProperty() {
- return property;
- }
-
- /**
- * @param property the property to set
- */
- public void setProperty(Property property) {
- this.property = property;
- this.nearestPackage = property.getNearestPackage();
- }
-
- /** debug mode */
- protected final boolean debugMode = false;
-
- /**
- * Debug method (~System.out.println)
- */
- private void debug(Object debug) {
- if(debugMode) {
- System.out.println(debug);
- }
- }
-
- /**
- * Error method (~System.err.println)
- */
- private void error(Object debug) {
- if(debugMode) {
- System.err.println(debug);
- }
- }
-
- /**
- * Context (for completion processor)
- */
- private int context = IContext.DEFAULT;
-
- /**
- * @return the context
- */
- public int getContext() {
- return context;
- }
-
- /**
- * @param context the context to set
- */
- public void setContext(int context) {
- this.context = context;
- }
-
- // all possible modified elements on property (with default values : necessary ?!)
- String name;
- VisibilityKind visibility = VisibilityKind.PUBLIC_LITERAL;
- boolean isDerived = false;
- Type type=null;
- int lowerMultiplicity = 1; // default multiplicity = [1..1]
- int upperMultiplicity = 1; // default multiplicity = [1..1]
- String defaultValue=null;
- // property modifiers
- boolean isReadOnly = false; // default value = false
- boolean isUnique = false; // default value = true but easier to use default = nonunique
- boolean isOrdered = false; // default value = false
- boolean isDerivedUnion = false; // default value = false
- Collection subsettedProperties = new Vector();
- Collection redefinedProperties = new Vector();
-
-
- /**
- * Apply values to the property. <BR>
- * Modifications can not be applied directly. The parser must wait the end,
- * until it reaches the end of the label. If the end is reached without any error,
- * new values can be applied to the target property.
- */
- private void applyValues() {
- if(!isValidation){
- debug("\nvalues applied :");
- debug("+ name: "+name);
- debug("+ visibility: "+visibility);
- debug("+ isDerived: "+isDerived);
- debug("+ type: "+type);
- debug("+ lower Multiplicity: "+lowerMultiplicity);
- debug("+ upper Multiplicity: "+upperMultiplicity);
- debug("+ default Value: "+defaultValue);
- debug("+ Property modifiers");
- debug("+ isReadOnly: "+isReadOnly);
- debug("+ isUnique: "+isUnique);
- debug("+ isOrdered: "+isOrdered);
- debug("+ isDerivedUnion: "+isDerivedUnion);
- debug("+ SubsettedProperties: "+subsettedProperties);
- debug("+ RedefinedProperties: "+redefinedProperties);
-
- property.setName(name);
- property.setVisibility(visibility);
- property.setIsDerived(isDerived);
- property.setType(type);
- property.setLower(lowerMultiplicity);
- property.setUpper(upperMultiplicity);
- property.setDefault(defaultValue);
- property.setIsReadOnly(isReadOnly);
- property.setIsUnique(isUnique);
- property.setIsOrdered(isOrdered);
- property.setIsDerivedUnion(isDerivedUnion);
- property.getSubsettedProperties().clear();
- property.getSubsettedProperties().addAll(subsettedProperties);
- property.getRedefinedProperties().clear();
- property.getRedefinedProperties().addAll(redefinedProperties);
- }
- }
-
- /**
- * Find a type given its name and a context to find it.
- * @param name the name of the type
- * @return the type found or <code>null</code> if the element was not found.
- */
- /*
- private Type findTypeByName(String name, org.eclipse.uml2.uml.Element context) throws RecognitionException {
- Type type = null;
- int numTypes = 0;
- org.eclipse.uml2.uml.Package contextPackage = context.getNearestPackage();
-
- // seek the package in which the element should be found...
- Iterator it = contextPackage.getMembers().iterator();
- while( it.hasNext() ) {
- Object tmp = it.next();
- if( tmp instanceof Type ) {
- Type element = ( Type )tmp;
- if( element.getName().equals(name) ) {
- numTypes++;
- type = element;
- }
- }
- }
- if(type == null) {// type not found in default package. search in imports.
- it = contextPackage.getImportedMembers().iterator();
- while( it.hasNext() ) {
- Object tmp = it.next();
- if( tmp instanceof Type ) {
- Type element = ( Type )tmp;
- if( element.getName().equals(name) ) {
- type = element;
- numTypes++;
- }
- }
- }
- }
-
- if(numTypes == 0) {
- throw new RecognitionException("Type "+name+" not found for property "+property.getName());
- } else if(numTypes > 1) {
- debug("There are "+numTypes+" types with the same name....");
- }
-
- return type;
- }
- */
-
- /**
- * Find a subsetted property given its name and a context to find it.
- * @param name the name of the property
- * @return the property found or <code>null</code> if the element was not found.
- */
- private Property findSubsettedPropertyByName(String propertyName, Property property) throws TypeRecognitionException {
- Property subsettedProperty = null;
- Iterator<Property> it = PropertyUtil.getSubsettablesProperties(property, true).iterator();
- while (it.hasNext()) {
- Property tmpProperty = it.next();
- if(propertyName.equals(tmpProperty.getName())) {
- subsettedProperty = tmpProperty;
- }
- }
-
- if(subsettedProperty == null) {
- throw new TypeRecognitionException("Property "+propertyName+" has not been found or can not be subset", property.getName());
- } else {
- // a property has been found. check multiplicity
- checkProperty(property, subsettedProperty);
- }
- return subsettedProperty;
- }
-
- private void checkProperty(Property property, Property subsettedProperty) throws RuntimeException {
- int propertyLowerBound = lowerMultiplicity; // check the new one!!
- int subsettedPropertyLowerBound = subsettedProperty.getLower();
- int propertyUpperBound = upperMultiplicity; // check the new one!!
- int subsettedPropertyUpperBound = subsettedProperty.getUpper();
-
- Type propertyType = property.getType();
- Type subsettedPropertyType = subsettedProperty.getType();
-
- String propertyName = property.getName();
-
- /*
- * rule : property multiplicity is a subset of subsetted property multiplicity
- * 1. property Lower Bound must be greater (or equal) than subsetted property Lower Bound
- * 2. property Upper Bound must be lower (or equal) than subsetted property Upper Bound (if subsetted property Upper Bound is not '*')
- */
- if( propertyLowerBound < subsettedPropertyLowerBound) {
- throw new MultiplicityException(propertyName+" Lower Bound ("+lowerMultiplicity+") can not be lower than subsetted property Lower Bound ("+subsettedPropertyLowerBound+")");
- } else if(subsettedPropertyUpperBound != -1 && propertyUpperBound > subsettedPropertyUpperBound) {
- throw new MultiplicityException(propertyName+" Upper Bound ("+upperMultiplicity+") can not be greater than subsetted property Upper Bound ("+subsettedPropertyUpperBound+")");
- }
- if(!propertyType.conformsTo(subsettedPropertyType)) {
- throw new TypeRecognitionException(propertyName+" Type ("+propertyType.getName()+") does not conform to subsetted property type", subsettedPropertyType.getName());
- }
- }
-
- /**
- * Find a redefined property given its name and a context to find it.
- * @param name the name of the property
- * @return the property found or <code>null</code> if the element was not found.
- */
- private Property findRedefinedPropertyByName(String propertyName, Property property) throws TypeRecognitionException {
- Property redefinedProperty = PropertyUtil.findRedefinedPropertyByName(propertyName, property);
- if(redefinedProperty == null) {
- throw new TypeRecognitionException("Property "+propertyName+" has not been found or can not be redefined", property.getName());
- }
- return redefinedProperty;
- }
-
- // vector that keeps modifiers already used (used for completion)
- public Map<String, Boolean> modifiersUsed;
-
- /**
- * @return the modifiersUsed
- */
- public Map<String, Boolean> getModifiersUsed() {
- return modifiersUsed;
- }
-
- /**
- * @param modifiersUsed the modifiersUsed to set
- */
- public void setModifiersUsed(Map<String, Boolean> modifiersUsed) {
- this.modifiersUsed = modifiersUsed;
- }
-
- /** reporting errors */
- private IErrorReporter errorReporter = null;
-
- public void setErrorReporter(IErrorReporter errorReporter) {
- this.errorReporter = errorReporter;
- }
-
- public IErrorReporter getErrorReporter() {
- return errorReporter;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getErrorMessage(RecognitionException exception, String[] arg1) {
- if (exception instanceof NameException) {
- return "Please enter a correct name for the property";
- }
- return super.getErrorMessage(exception, arg1);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void emitErrorMessage(String msg) {
- errorReporter.reportError(msg);
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recover(IntStream arg0, RecognitionException arg1) {
- throw new RuntimeException("no recover", arg1);
- // do nothing
- }
-
-
-}
-
-label :
- (WS)*
- (visibility (WS)*{context = IContext.VISIBILITY; } )?
- (isDerived (WS)* { context = IContext.IS_DERIVED; } )?
- name (WS)*
- COLON
- {
- context = IContext.AFTER_COLON;
- }
- property_type { context = IContext.MULTIPLICITY; }
- (fullMultiplicity { context = IContext.AFTER_MULTIPLICITY; } (WS)*)?
- (defaultValue { context = IContext.DEFAULT_VALUE; })?
- (propertyModifiers { context = IContext.PROPERTY_MODIFIERS; } (WS)*)?
- {
- applyValues();
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- String index = Integer.toString(mte.index);
- String description = mte.getLocalizedMessage().substring(mte.getLocalizedMessage().indexOf('('),
- mte.getLocalizedMessage().length());
- String tokenText = mte.token.getText();
- String text = Messages.bind(Messages.MismatchedToken, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- } catch [RecognitionException re] {
- reportError(re);
- throw (re);
-
- }
-
-
-visibility
- :
- (
- ( PLUS { visibility = VisibilityKind.PUBLIC_LITERAL; } )
- | ( MINUS { visibility = VisibilityKind.PRIVATE_LITERAL;} )
- | ( SHARP { visibility = VisibilityKind.PROTECTED_LITERAL;} )
- | ( TILDE { visibility = VisibilityKind.PACKAGE_LITERAL;} )
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("VisibilityRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
-
- }
-
-
-isDerived
- :
- DIV { isDerived = true; }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("IsDerivedRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
-
- }
-
-name
- :
- id=IDENTIFIER
- {
- name = id.getText();
- context = IContext.NAME;
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException(Messages.NameMissing));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-property_type
- :
- (WS)*
- ( type |
- '<Undefined>'
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("PropertyTypeRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- throw new RuntimeException("Waiting for a valid type or <Undefined>");
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-type
- @init{
- StringBuffer buffer = new StringBuffer();
- }
- :
- id=IDENTIFIER {buffer.append(id.getText());}
- (WS {//System.err.println("space added");
- buffer.append(" ");})*
- (
- id1=IDENTIFIER {buffer.append(id1.getText());}
- (WS {//System.err.println("space added");
- buffer.append(" ");})*
- )*
- {
- String typeName = buffer.toString().trim() ;
- //System.err.println("typeName: "+typeName);
- Type utilType = PackageUtil.findTypeByName(nearestPackage, typeName);
- // type = findTypeByName(typeName, property);
- // The type has not been found, but it may have been declared in the context of a template.
- if(utilType != null) {
- if (utilType instanceof TemplateableElement) {
- TemplateableElement template = (TemplateableElement)utilType;
- if (template.isTemplate()) {
- throw new UnboundTemplateRecognitionException("Parameters of template " + typeName + " are not bound.",
- template) ;
- } else {
- type = utilType;
- }
- }
- else {
- type = utilType;
- }
- } else {
- // The type has not been found, but it may have been declared in the context of a template.
- if (property.getOwner() instanceof TemplateableElement) {
- TemplateableElement template = (TemplateableElement)property.getOwner() ;
- if (template.isTemplate()) {
- utilType = TemplateSignatureUtil.findTypeByName(template.getOwnedTemplateSignature(), typeName) ;
- }
- }
- if (utilType == null) // the type actually does not exist
- throw new TypeRecognitionException("Type "+typeName+" not found for property "+property.getName(),typeName);
- else if (utilType instanceof TemplateableElement && ((TemplateableElement)utilType).isTemplate()) {
- throw new UnboundTemplateRecognitionException("Parameters of template " + typeName + " are not bound.",
- (TemplateableElement)utilType) ;
- }
- else {
- type = utilType;
- }
- }
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("TypeRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-fullMultiplicity
- :
- LSQUARE
- { context = IContext.IN_MULTIPLICITY; }
- /*(
- ( lowerMultiplicity POINT_POINT upperMultiplicity {
- if(lowerMultiplicity > upperMultiplicity && upperMultiplicity != -1) {
- throw new MultiplicityException("Lower bound ("+lowerMultiplicity+") is greater than upper bound ("+upperMultiplicity+")");
- }
- }
- )
- | upperMultiplicity {
- if(upperMultiplicity == -1) {
- lowerMultiplicity = 0;
- } else {
- lowerMultiplicity = upperMultiplicity;
- }
- }
- )*/
- (
- ra=RANGE_VALUE {
- // retrieving values. text = upper ',' lower
- String value = $ra.text;
- upperMultiplicity = Integer.parseInt(value.substring(0, value.lastIndexOf(',')));
- lowerMultiplicity = Integer.parseInt(value.substring(value.lastIndexOf(',') + 1, value.length()));
-
- if (lowerMultiplicity > upperMultiplicity && upperMultiplicity != -1) {
- throw new MultiplicityException("Lower bound (" + lowerMultiplicity
- + ") is greater than upper bound (" + upperMultiplicity + ")");
- }
-
- }
- | up=INTEGER {
- upperMultiplicity = Integer.parseInt($up.text);
- lowerMultiplicity = upperMultiplicity;
- }
- )
- RSQUARE
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("FullMultiplicityRule"));
- }
- catch [NoViableAltException noViableAltException] {
- reportError(noViableAltException);
- String index = Integer.toString(noViableAltException.index);
- String description = noViableAltException.grammarDecisionDescription.substring(
- noViableAltException.grammarDecisionDescription.indexOf('('),
- noViableAltException.grammarDecisionDescription.length());
- String tokenText = noViableAltException.token.getText();
- String text = Messages.bind(Messages.NoViableAltException, new String[] { index, description, tokenText });
- throw new RuntimeException(text);
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-
-lowerMultiplicity
- :
- in=INTEGER
- {
- lowerMultiplicity = Integer.parseInt(in.getText());
- }
- ;
-
-upperMultiplicity
- :
- um=unlimitedNatural
- {
- upperMultiplicity = um.value;
- }
- ;
-
-unlimitedNatural returns [int value = 0 ]
- :
- ( STAR { retval.value = -1; }
- | in=INTEGER { retval.value = Integer.parseInt(in.getText()); }
- )
- ;
-
-defaultValue
- :
- EQ dv = expression
- {
- // remove spaces at the begining
- defaultValue = dv.value.trim();
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("DefaultValueRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-expression returns [String value = ""]
- @init{
- StringBuffer buffer = new StringBuffer();
- }
- :
- (
- options { greedy=false; }
- :
-
- id=~(LCURLY)
- {
- buffer.append(id.getText());
- }
- )+
- {
- retval.value = buffer.toString();
- }
- ;
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-propertyModifiers
- :
- LCURLY (WS)*
- { context = IContext.PROPERTY_MODIFIER; }
- propertyModifier (WS)*
- (
- { context = IContext.PROPERTY_MODIFIER; }
- COMMA (WS)* propertyModifier (WS)*
- )*
- RCURLY
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("DefaultValueRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-propertyModifier
- :
- (
- 'readOnly' { isReadOnly = true; modifiersUsed.put("readOnly", true);}
- | 'union' { isDerivedUnion = true; modifiersUsed.put("union", true); }
- | 'ordered' { isOrdered = true; modifiersUsed.put("ordered", true); }
- | 'unique' { isUnique = true; modifiersUsed.put("unique", true); modifiersUsed.put("nonunique", true);}
- | 'nonunique' { isUnique = false; modifiersUsed.put("unique", true); modifiersUsed.put("nonunique", true);}
- | 'subsets' { context = IContext.SUBSET_PROPERTY ; } subsetsProperty
- | redefinesProperty
- )
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("PropertyModifierRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-
-subsetsProperty
- :
- id=IDENTIFIER
- {
- // find property by name
- String propertyName = id.getText();
- Property tmpProperty = findSubsettedPropertyByName(propertyName, property);
- subsettedProperties.add(tmpProperty);
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("subsetsPropertyRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-redefinesProperty
- :
- { context = IContext.REDEFINE_PROPERTY ; } 'redefines' { context = IContext.REDEFINE_PROPERTY ; } id=IDENTIFIER
- {
- // find property by name
- String propertyName = id.getText();
- Property tmpProperty = findRedefinedPropertyByName(propertyName, property);
- redefinedProperties.add(tmpProperty);
- }
- ;
- catch [MismatchedTokenException mte] {
- reportError(mte);
- throw (new RuntimeException("redefinesPropertyRule"));
- }
- catch [RecognitionException re] {
- reportError(re);
- throw(re);
- }
-
-NL
- : ( '\r' '\n'
- | '\n' '\r' //Improbable
- | '\r'
- | '\n'
- )
- { $channel=HIDDEN;}
- ;
-
-
-WS
- : (' ' | '\t' | '\f')+ // {$channel=HIDDEN;}
- ;
-
-QUESTION_MARK
- : '?'
- ;
-
-LNOT
- : '!'
- ;
-
-DOUBLE_QUOTE
- : '\"'
- ;
-
-SINGLE_QUOTE
- : '\''
- ;
-
-LPAREN
- : '('
- ;
-
-RPAREN
- : ')'
- ;
-
-LSQUARE
- : '['
- ;
-
-RSQUARE
- : ']'
- ;
-
-LCURLY
- : '{'
- ;
-
-DOUBLE_LCURLY
- : '{{' ;
-
-RCURLY
- : '}'
- ;
-
-DOUBLE_RCURLY
- : '}}'
- ;
-
-LOGICAL_AND
- : '&'
- ;
-
-DOUBLE_LOGICAL_AND
- : '&&'
- ;
-
-PIPE
- : '|'
- ;
-
-DOUBLE_PIPE
- : '||'
- ;
-
-POINT
- : '.'
- ;
-
-RANGE
- : '..'
- ;
-
-COMMA
- : ','
- ;
-
-SEMI
- : ';'
- ;
-
-SHARP
- : '#'
- ;
-
-TILDE
- : '~'
- ;
-
-COLON
- : ':'
- ;
-
-FOUR_POINTS
- : '::'
- ;
-
-RULE_ASSIGN
- : '::=' ;
-
-ARROW
- : '->'
- ;
-
-STAR
- : '*'
- ;
-
-DIV
- : '/'
- ;
-
-PLUS
- : '+'
- ;
-
-MINUS
- : '-'
- ;
-
-EQ
- : '='
- ;
-
-
-ISEQ
- : '=='
- ;
-
-ISNE
- : '!='
- ;
-
-LT : '<';
-
-DOUBLE_LT
- : '<<'
- ;
-
-LE
- : '<='
- ;
-
-GT
- : '>'
- ;
-
-DOUBLE_GT
- : '>>'
- ;
-
-GE
- : '>='
- ;
-
-
-INCR
- : '++'
- ;
-
-DECR
- : '--'
- ;
-
-CALLOPERATION
- : ':='
- ;
-
-fragment
-ALPHA
- : 'a'..'z'
- | 'A'..'Z'
- ;
-
-
-UNDERSCORE
- : '_'
- ;
-
-RANGE_VALUE
- : c1=INTEGER {setText("");} '..'
- ( c2=INTEGER { setText($c2.text);}
- | c2=STAR { setText("-1");})
- {
- setText($text + ","+ $c1.text);
- }
- ;
-
-REAL
- : INTEGER '.' INTEGER
- ;
-
-fragment
-INTEGER_OR_REAL_OR_RANGE !
- :
- (INTEGER RANGE) => RANGE_VALUE
- | (INTEGER POINT) => REAL
- | (INTEGER) => INTEGER
- ;
-
-INTEGER
- : '0'..'9'+;
-
-IDENTIFIER
- : (ALPHA|'0'..'9'|UNDERSCORE)+
- ;
-
diff --git a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.tokens b/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.tokens
deleted file mode 100644
index e34b4351239..00000000000
--- a/extraplugins/marte/org.eclipse.papyrus.parsers/resources/grammars/PropertyLabel.tokens
+++ /dev/null
@@ -1,67 +0,0 @@
-T__55=55
-T__56=56
-T__57=57
-T__58=58
-T__59=59
-T__60=60
-T__61=61
-T__62=62
-WS=4
-COLON=5
-PLUS=6
-MINUS=7
-SHARP=8
-TILDE=9
-DIV=10
-IDENTIFIER=11
-LSQUARE=12
-RANGE_VALUE=13
-INTEGER=14
-RSQUARE=15
-STAR=16
-EQ=17
-LCURLY=18
-COMMA=19
-RCURLY=20
-NL=21
-QUESTION_MARK=22
-LNOT=23
-DOUBLE_QUOTE=24
-SINGLE_QUOTE=25
-LPAREN=26
-RPAREN=27
-DOUBLE_LCURLY=28
-DOUBLE_RCURLY=29
-LOGICAL_AND=30
-DOUBLE_LOGICAL_AND=31
-PIPE=32
-DOUBLE_PIPE=33
-POINT=34
-RANGE=35
-SEMI=36
-FOUR_POINTS=37
-RULE_ASSIGN=38
-ARROW=39
-ISEQ=40
-ISNE=41
-LT=42
-DOUBLE_LT=43
-LE=44
-GT=45
-DOUBLE_GT=46
-GE=47
-INCR=48
-DECR=49
-CALLOPERATION=50
-ALPHA=51
-UNDERSCORE=52
-REAL=53
-INTEGER_OR_REAL_OR_RANGE=54
-'<Undefined>'=55
-'readOnly'=56
-'union'=57
-'ordered'=58
-'unique'=59
-'nonunique'=60
-'subsets'=61
-'redefines'=62

Back to the top