Open suweining opened 9 years ago
Analysis: It is clear that the ambiguity comes from "syntax ModalPpeValue ::= PpeValue InModes " and "syntax SubCmpAssocDef ::= SubCmpAssocDefElem SubCmpAssocDefElem" .So,the first step is to find out which non-terminal cases the ambiguity. Firstly,we unfold the PpeValue :
syntax PpeValue ::= Id | BooleanTerm | RealTerm | IntegerTerm | StringTerm | EnumerationTerm | UnitTerm | RealRangeTerm | IntegerRangeTerm | PpeTerm | CmpClassifierTerm | RefTerm | RecordTerm | ComputedTerm | MBracketLeft MBracketRight // 和ArrayDimension中有相同的定义 | MBracketLeft PpeListValue MBracketRight | MBracketLeft PpeListValue MComma PpeListValueMidSymbol MBracketRight | MBracketLeft PpeExpression MComma PpeListValueMidSymbol MBracketRight | MBracketLeft PpeExpressionWithoutBooleanTerm MBracketRight | AmbBracketLeftBooleanTermBracketRight
and we find that the products,"MBracketLeft MBracketRight" are same with a product in ArrayDimension.
What's more, syntax CmpInModes ::= InModes // 和SubCmpAssocDefElem重复 | Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight | Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight it is obvious that "InModes" is the repeated.
Then ,we will alter the ambiguity.
We rewrite the SubCmpAssocDef :
syntax SubCmpAssocDef ::= SubCmpAssocDefElem // 1 SubCmpAssocDefElem
| SubCmpAssocDefElem SubCmpAssocDefElem // 2 SubCmpAssocDefElems
| SubCmpAssocDefElem SubCmpAssocDefElem SubCmpAssocDef // multy SubCmpAssocDefElems
We plan to redefine the product : SubCmpAssocDefElem SubCmpAssocDefElem
step 1) syntax DoubleSubCmpAssocDefElemAdjust ::= UniCmpClassifierRef | UniCmpClassifierRef ProtoTypeBindings
| ArrayDimension // need partition
| ArrayDimensions ArrayElementImplList
| CmpInModes // need partition
| AmbBracketLeftIdBracketRight
Infer from Analysis,ArrayDimension and CmpInModes need split.
syntax ArrayDimension ::= MLeftBracket ArrayDimensionSize MRightBracket | MLeftBracket MRightBracket
just delete repeating part: MLeftBracket MRightBracket.
syntax DoubleSubCmpAssocDefElemAdjust ::= UniCmpClassifierRef | UniCmpClassifierRef ProtoTypeBindings
| MLeftBracket ArrayDimensionSize MRightBracket
| ArrayDimensions ArrayElementImplList
| CmpInModes // need partition
| AmbBracketLeftIdBracketRight
step 2) And CmpInModes should be altered at second SubCmpAssocDefElem .
syntax CmpInModes ::= InModes | Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight | Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
just delete repeating part : InModes
At last we get here:
syntax DoubleSubCmpAssocDefElemAdjust ::= UniCmpClassifierRef Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight | UniCmpClassifierRef ProtoTypeBindings Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight
| MLeftBracket ArrayDimensionSize MRightBracket Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight
| ArrayDimensions ArrayElementImplList Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight
| CmpInModes Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight
| AmbBracketLeftIdBracketRight Min Mmodes MBracketLeft Id MRoughArrow Id MBracketRight
| UniCmpClassifierRef Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
| UniCmpClassifierRef ProtoTypeBindings Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
| MLeftBracket ArrayDimensionSize MRightBracket Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
| ArrayDimensions ArrayElementImplList Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
| CmpInModes Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
| AmbBracketLeftIdBracketRight Min Mmodes MBracketLeft ModeName MComma ModeNameList MBracketRight
SubCmpAssocDef, ModalPpeValue
in ModesAndModeTransitions.aadl //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// syntax SubCmpAssocDef ::= SubCmpAssocDefElem | SubCmpAssocDefElem SubCmpAssocDef
syntax SubCmpAssocDefElem ::= UniCmpClassifierRef | UniCmpClassifierRef ProtoTypeBindings | Id | ArrayDimension | ArrayDimensions ArrayElementImplList | CmpInModes | MBraceLeft ContainedPpeAssoc MBraceRight | MBraceLeft PpeAssoc PpeContainedPpeAssocList MBraceRight | MBraceLeft ContainedPpeAssoc PpeContainedPpeAssocList MBraceRight | AmbBraceLeftPpeAssocBraceRight | AmbBracketLeftIdBracketRight
syntax ModalPpeValue ::= PpeValue InModes | PpeValue InModes MComma ModalPpeValue syntax PpeValue ::= SinglePpeValue | PpeListValue
syntax SinglePpeValue ::= PpeExpression syntax PpeExpression ::= BooleanTerm | RealTerm | IntegerTerm | StringTerm | EnumerationTerm | UnitTerm | RealRangeTerm | IntegerRangeTerm | PpeTerm | CmpClassifierTerm | RefTerm | RecordTerm | ComputedTerm
syntax PpeListValue ::= MBracketLeft MBracketRight | MBracketLeft PpeListValue MBracketRight | MBracketLeft PpeListValue MComma PpeListValueMidSymbol MBracketRight | MBracketLeft PpeExpression MComma PpeListValueMidSymbol MBracketRight | MBracketLeft PpeExpressionWithoutBooleanTerm MBracketRight | AmbBracketLeftBooleanTermBracketRight