Allow multiple Annotations on ParserRules

This commit is contained in:
Holger Schill 2018-03-22 11:12:08 +01:00
parent a25e761971
commit 2bfe5fb64b
8 changed files with 238 additions and 221 deletions

View file

@ -3085,7 +3085,7 @@ rule__ParserRule__Group__0__Impl
:
(
{ before(grammarAccess.getParserRuleAccess().getAnnotationsAssignment_0()); }
(rule__ParserRule__AnnotationsAssignment_0)?
(rule__ParserRule__AnnotationsAssignment_0)*
{ after(grammarAccess.getParserRuleAccess().getAnnotationsAssignment_0()); }
)
;

View file

@ -591,7 +591,7 @@ ruleParserRule returns [EObject current=null]
afterParserOrEnumRuleCall();
}
)
)?
)*
(
(
(

View file

@ -790,6 +790,7 @@ public class InternalXtextParser extends AbstractInternalAntlrParser {
if ( (LA9_1==RULE_ID) ) {
switch ( input.LA(3) ) {
case RULE_ID:
case 21:
case 22:
case 39:
case 40:
@ -1541,7 +1542,7 @@ public class InternalXtextParser extends AbstractInternalAntlrParser {
// $ANTLR start "ruleParserRule"
// InternalXtext.g:568:1: ruleParserRule returns [EObject current=null] : ( ( (lv_annotations_0_0= ruleAnnotation ) )? ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' ) ;
// InternalXtext.g:568:1: ruleParserRule returns [EObject current=null] : ( ( (lv_annotations_0_0= ruleAnnotation ) )* ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' ) ;
public final EObject ruleParserRule() throws RecognitionException {
EObject current = null;
@ -1572,53 +1573,60 @@ public class InternalXtextParser extends AbstractInternalAntlrParser {
enterRule();
try {
// InternalXtext.g:574:2: ( ( ( (lv_annotations_0_0= ruleAnnotation ) )? ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' ) )
// InternalXtext.g:575:2: ( ( (lv_annotations_0_0= ruleAnnotation ) )? ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' )
// InternalXtext.g:574:2: ( ( ( (lv_annotations_0_0= ruleAnnotation ) )* ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' ) )
// InternalXtext.g:575:2: ( ( (lv_annotations_0_0= ruleAnnotation ) )* ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' )
{
// InternalXtext.g:575:2: ( ( (lv_annotations_0_0= ruleAnnotation ) )? ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' )
// InternalXtext.g:576:3: ( (lv_annotations_0_0= ruleAnnotation ) )? ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';'
// InternalXtext.g:575:2: ( ( (lv_annotations_0_0= ruleAnnotation ) )* ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';' )
// InternalXtext.g:576:3: ( (lv_annotations_0_0= ruleAnnotation ) )* ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) ) ( ( (lv_definesHiddenTokens_9_0= 'hidden' ) ) otherlv_10= '(' ( ( ( ruleRuleID ) ) (otherlv_12= ',' ( ( ruleRuleID ) ) )* )? otherlv_14= ')' )? otherlv_15= ':' ( (lv_alternatives_16_0= ruleAlternatives ) ) otherlv_17= ';'
{
// InternalXtext.g:576:3: ( (lv_annotations_0_0= ruleAnnotation ) )?
int alt13=2;
int LA13_0 = input.LA(1);
// InternalXtext.g:576:3: ( (lv_annotations_0_0= ruleAnnotation ) )*
loop13:
do {
int alt13=2;
int LA13_0 = input.LA(1);
if ( (LA13_0==21) ) {
alt13=1;
}
switch (alt13) {
case 1 :
// InternalXtext.g:577:4: (lv_annotations_0_0= ruleAnnotation )
{
// InternalXtext.g:577:4: (lv_annotations_0_0= ruleAnnotation )
// InternalXtext.g:578:5: lv_annotations_0_0= ruleAnnotation
{
newCompositeNode(grammarAccess.getParserRuleAccess().getAnnotationsAnnotationParserRuleCall_0_0());
pushFollow(FollowSets000.FOLLOW_14);
lv_annotations_0_0=ruleAnnotation();
state._fsp--;
if ( (LA13_0==21) ) {
alt13=1;
}
if (current==null) {
current = createModelElementForParent(grammarAccess.getParserRuleRule());
}
add(
current,
"annotations",
lv_annotations_0_0,
"org.eclipse.xtext.Xtext.Annotation");
afterParserOrEnumRuleCall();
switch (alt13) {
case 1 :
// InternalXtext.g:577:4: (lv_annotations_0_0= ruleAnnotation )
{
// InternalXtext.g:577:4: (lv_annotations_0_0= ruleAnnotation )
// InternalXtext.g:578:5: lv_annotations_0_0= ruleAnnotation
{
}
newCompositeNode(grammarAccess.getParserRuleAccess().getAnnotationsAnnotationParserRuleCall_0_0());
pushFollow(FollowSets000.FOLLOW_14);
lv_annotations_0_0=ruleAnnotation();
state._fsp--;
}
break;
if (current==null) {
current = createModelElementForParent(grammarAccess.getParserRuleRule());
}
add(
current,
"annotations",
lv_annotations_0_0,
"org.eclipse.xtext.Xtext.Annotation");
afterParserOrEnumRuleCall();
}
}
}
break;
default :
break loop13;
}
} while (true);
// InternalXtext.g:595:3: ( ( ( (lv_fragment_1_0= 'fragment' ) ) this_RuleNameAndParams_2= ruleRuleNameAndParams[$current] ( ( (lv_wildcard_3_0= '*' ) ) | (otherlv_4= 'returns' ( (lv_type_5_0= ruleTypeRef ) ) )? ) ) | (this_RuleNameAndParams_6= ruleRuleNameAndParams[$current] (otherlv_7= 'returns' ( (lv_type_8_0= ruleTypeRef ) ) )? ) )
int alt17=2;
@ -4008,6 +4016,11 @@ public class InternalXtextParser extends AbstractInternalAntlrParser {
case 43:
{
switch ( input.LA(2) ) {
case RULE_STRING:
{
alt39=4;
}
break;
case 15:
{
alt39=6;
@ -4020,11 +4033,6 @@ public class InternalXtextParser extends AbstractInternalAntlrParser {
alt39=5;
}
break;
case RULE_STRING:
{
alt39=4;
}
break;
default:
NoViableAltException nvae =
new NoViableAltException("", 39, 5, input);

View file

@ -1012,7 +1012,7 @@ public class XtextSemanticSequencer extends AbstractDelegatingSemanticSequencer
*
* Constraint:
* (
* annotations+=Annotation?
* annotations+=Annotation*
* fragment?='fragment'?
* name=ValidID
* (parameters+=Parameter parameters+=Parameter*)?

View file

@ -402,19 +402,19 @@ public class XtextGrammarAccess extends AbstractGrammarElementFinder {
private final Keyword cSemicolonKeyword_5 = (Keyword)cGroup.eContents().get(5);
//ParserRule:
// annotations+=Annotation? (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
// annotations+=Annotation* (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
// RuleNameAndParams ('returns' type=TypeRef)?) (definesHiddenTokens?='hidden' '(' (hiddenTokens+=[AbstractRule|RuleID]
// (',' hiddenTokens+=[AbstractRule|RuleID])*)? ')')? ':'
// alternatives=Alternatives
// ';';
@Override public ParserRule getRule() { return rule; }
//annotations+=Annotation? (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
//annotations+=Annotation* (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
//RuleNameAndParams ('returns' type=TypeRef)?) (definesHiddenTokens?='hidden' '(' (hiddenTokens+=[AbstractRule|RuleID]
//(',' hiddenTokens+=[AbstractRule|RuleID])*)? ')')? ':' alternatives=Alternatives ';'
public Group getGroup() { return cGroup; }
//annotations+=Annotation?
//annotations+=Annotation*
public Assignment getAnnotationsAssignment_0() { return cAnnotationsAssignment_0; }
//Annotation
@ -2544,7 +2544,7 @@ public class XtextGrammarAccess extends AbstractGrammarElementFinder {
}
//ParserRule:
// annotations+=Annotation? (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
// annotations+=Annotation* (^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?) |
// RuleNameAndParams ('returns' type=TypeRef)?) (definesHiddenTokens?='hidden' '(' (hiddenTokens+=[AbstractRule|RuleID]
// (',' hiddenTokens+=[AbstractRule|RuleID])*)? ')')? ':'
// alternatives=Alternatives

View file

@ -44,7 +44,7 @@ Annotation returns Annotation:
;
ParserRule :
(annotations += Annotation)?
(annotations += Annotation)*
(
^fragment?='fragment' RuleNameAndParams (wildcard?='*' | ('returns' type=TypeRef)?)
| RuleNameAndParams ('returns' type=TypeRef)?