this is my example to show you the problem I need to call two rules
generate umlDsl "http://www.xtext.org/example/umldsl/UmlDsl"
rul1 'and' rul2
FQN returns ecore::EString:
ID ("." ID)*
I have this error
Multiple markers at this line (rul1 'and' rul2)
- An unassigned rule call is not allowed, when the 'current' was already created.
- Cannot change type twice within a rule
I want to know why I have this error and how to fix it please
Best How To :
These errors occurs because of your rule implementation of rule
rul1 'and' rul2
As I understand
rule has two attributes,
rul2. But in your implementation
rule does not have any attributes. To define
rul2 as attribuites you have assign these elements to an attribute. This could look like this:
rul1=rul1 'and' rul2=rul2
Have you looked into the Xtext documentation  to learn about the grammar language syntax and semantics?
The things you need to know for understanding your error are the following:
An attribute of a parser rule needs a name. To this name you assign a value, which is an other parser rules name. It is similar to assing values to a field in Java:
int i = 42;
A field declaration consists of the fields type (int) and the fields name (i) this normally is followd by the assignment operator (=) and the value (42). The attribute definiton of a parser rule follows this scheme:
RuleA: 'some syntax' attributeName=OtherRule 'more syntax';
OtherRule: 'other syntax' attribute=NextRule ... ;
A parser rule in Xtexts grammar language is like a Java class.
RuleName corresponds to
class ClassName. Then you can define some static syntax with
'keyword'. If any other rule should occur within any other rule, it can be understood as a field declaration. This rule is an attribute which is implemented like this:
attributeName corresponds to the field name. But to an attribute the type of the value is assigned (AnyRule).
Btw. I strongly recommand that rule names should start with an Capital letter and attribute names should start with an lower case letter.