Cross References are working only in a specific parts of the model - why? [message #894841] |
Tue, 10 July 2012 17:44 |
Hannes Müller Messages: 24 Registered: June 2012 |
Junior Member |
|
|
Hi everyone,
I have a language posted below. My problem is the following: I "declare" formulas in a specific parameter for example:
parameter BeginPos{
recalculates
{
Mta & init ==> formula myFormula2 : BeginPos + 2;
}
}
If I know want to reuse my formula I work with cross references.
Recalculate:
... '==>' (recalculateFormula = RecalculateFormula | 'reuse' resusedRecalculateFormula = [RecalculateFormula]) ';'
;
The DSL would look like this ...
knownParameter BeginPos {
recalculates {
Customer & init ==> reuse myFormula2;
}
}
But because of some unknown reason xtext can not resolve the reference to myFormula2???
If I do declare a formula in the scope of a "reused" Parameter (a cross reference to a known parameter - see the example DSL below) -> than xtext CAN RESOLVE the formulas!?
knownParameter BeginPos {
recalculates {
Customer & inProgress ==> formula myFormula2 : 2 + 3 4;
}
}
knownParameter BeginPos {
recalculates {
Customer & init ==> reuse myFormula2;
}
}
Does anyone has a clue why this behaves this way? I would be grateful for any hint.
Thx in advance
Hannes
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl // here is the DSL URI - but I am still not allowed to add URIs in the forum ...
DomainModel:
{DomainModel}
supportedUsers = SupportedUserStates
supportedProgressStates = SupportedProgressStates
supportedActions = SupportedStateChangingActions
measurementsWithParmeters += MeasurementsWithParametersAndStateTransitions+
;
SupportedUserStates:
'users' '{' supportedUserStates += SupportedUserState (',' supportedUserStates += SupportedUserState)*'}'
;
SupportedUserState:
name = ID
;
SupportedProgressStates:
'progresses' '{'supportedProgressStates += SupportedProgressState (',' supportedProgressStates += SupportedProgressState)*'}'
;
SupportedProgressState:
name = ID
;
SupportedStateChangingActions:
'actions' '{'supportedStateChangingActions += StateChangingAction (',' supportedStateChangingActions += StateChangingAction)*'}'
;
StateChangingAction:
name = ID
;
MeasurementsWithParametersAndStateTransitions:
'measurements' '{'measurementsWithParametersAndStateTransitions += MeasurementWithParametersAndTransition 'end measurement;' (measurementsWithParametersAndStateTransitions += MeasurementWithParametersAndTransition 'end measurement;')* '}'
;
MeasurementWithParametersAndTransition:
measurement = Measurement '{' (parametersWithRecalulate += ParameterWithRecalculate)+ stateTransitions = StateTransitions '}'
;
Measurement:
'measurement' name = ID
;
ParameterWithRecalculate:
// new parameter should be declared or know parameter which already has some formulas
('parameter' name = ID (immutable = "immutable")?| 'knownParameter' paramWithRecal = [ParameterWithRecalculate])
'{' 'recalculates' '{' (recalculates += Recalculate)+ '}''}'
;
Recalculate:
userStates += [SupportedUserState] '&' progressStates += [SupportedProgressState]
('&&' userStates += [SupportedUserState] '&' progressStates += [SupportedProgressState])* '==>' (recalculateFormula = RecalculateFormula | 'reuse' resusedRecalculateFormula = [RecalculateFormula]) ';'
// the keyword reused (could be an other name) is mandatory necessary because else the parser cannot decide what to chose (ambiguity)
;
RecalculateFormula:
('formula 'name = ID':')? (complexFormula = Expression | specialFormula = SpecialFormula)
;
enum SpecialFormula:
NOP="NOP" // signals null object pattern
;
Expression:
Addition
;
Addition returns Expression:
Multiplication (({Plus.left=current} '+' | {Minus.left=current} '-') right=Multiplication)*
;
Multiplication returns Expression:
PrimaryExpression (({Multi.left=current} '*' | {Div.left=current} '/') right=PrimaryExpression)*
;
PrimaryExpression returns Expression:
leftBracktet = '(' expression = Expression rightBracket =')' | parameter = [ParameterWithRecalculate] | number = Number // the features left and right brackets are a "trick" to be able to recognize if the current formula is or is not surrounded with brackets while code generation
;
Number:
integer = INT | double = Double
;
Double:
predecimalNumber = INT '.' decimalNumber = INT
;
enum FormulaOperator:
PLUS = '+' | MINUS = '-' | MULTIPLIKATION = '*' | DIVISION = '/'
;
StateTransitions:
'state transitions {' (stateTransitions += StateTransition ';')+'}'
;
StateTransition:
stateTransitionConditions += StateTransitionContition ('&&' stateTransitionConditions += StateTransitionContition)* '==>' userStateNEW = [SupportedUserState] '&' progressStateNEW = [SupportedProgressState]
;
StateTransitionContition:
userStateOLD = [SupportedUserState] '&' progressStateOLD = [SupportedProgressState] '&' stateChangingAction = [StateChangingAction]
;
[Updated on: Tue, 10 July 2012 17:48] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03043 seconds