FormalADL / kAADL

1 stars 1 forks source link

Ambiguity about " left-linear && right-linear grammar" #4

Closed suweining closed 9 years ago

suweining commented 9 years ago

According to the error log, we kown that the most ambiguities are caused by " left-linear && right-linear grammar" except the ambiguity about "Id . Id".The so-called "left-linear && right-linear grammar" means a term satisfies left-linear grammar and it also satisfies right-linear grammar. Here are the non-terminal whose definitions are ambiguities:

src\ComponentImplementation.k\CmpImplAssocDef src\ComponentImplementation.k\SubCmpList src\ComponentImplementation.k\SubPgmCallSeqList src\ComponentImplementation.k\ConnectionList src\ComponentImplementation.k\FlowImplList src\ComponentImplementation.k\CmpImplExtAssocDef src\ComponentImplementation.k\SubCmpRefinementList src\ComponentImplementation.k\ConnectionRefinementList src\ComponentImplementation.k\ProtoTypeRefinementList src\ComponentType.k\CmpAssocDef src\ComponentType.k\ProtoTypeList src\ComponentType.k\FeatureList src\ComponentType.k\FlowSpecList src\ComponentType.k\CmpTypePpeAssocList src\ComponentType.k\ContainedPpeAssocList src\ComponentType.k\PpeAssocList src\Connection.k\PpeAssocList src\EndToEndFlow.k\ConnectionIdFlowPathList src\FeatureGroupType.k\FetGroupTypeAssocDef src\FeatureGroupType.k\FetGroupContainedPpeAssocList src\FeatureGroupType.k\AnnexSubclauseList src\FeatureGroupType.k\FetGroupTypeExtAssocDef src\FeatureGroupType.k\FetRefinementList src\FeatureShareAccess.k\FeatrueContrainedPpeAssoc src\FlowImplementation.k\SubcompentConnectionAssocDef src\FlowImplementation.k\ConnectionSubcompenentFlowAssocDef src\FlowImplementation.k\ConnectIdSubcompenentFlowIdnetifierList src\Package.k\BasicPpeAssocList src\Package.k\PkgDeclations src\Package.k\ImportDeclPlus src\PropertySet.k\ImportDecls src\PropertySet.k\PpeTempDecls src\ProtoType.k\ProtoTypePpeAssocList src\ProtoType.k\ProtoTypePpeAssoc src\Subcomponent.k\SubCmpAssocDef src\Subcomponent.k\SubCmpPpeAssocList src\Subcomponent.k\ArrayDimensions src\SubprogramCall.k\SubPgmCallList src\SubprogramCall.k\CallSequencePpeAssocList src\SubprogramCall.k\SubPgmCallPpeAssocList

Here is the solution of this ambiguity :

          syntax A ::= a | b | c | A A
          (A is left-linear  && right-linear grammar)
         solutuin:
               syntax A ::= a | b | c
                                | a A | b A | c A
         (now A is just left-linear grammar)
suweining commented 9 years ago

A good news ,after altered the ambiguity about left-linear && right-linear grammar, the kAADL analyze the test file more correct.But still some error: Here is the warning :

[Warning] Inner Parser: Parsing ambiguity. Arbitrarily choosing the first. 1: PpeListValue ::= MBracketLeft PpeListValueMidSymbol MBracketRight ( One_To_One ) 2: BooleanTerm ::= MBracketLeft BooleanTerm MBracketRight ( One_To_One )

there must be more warning like above while analyze other test files.we will post them latter

suweining commented 9 years ago

here a discovery about the [Warning] above. I locate the error position : File: /home/swn/test/standard/pass/Ports.aad Location: (27,75,27,87) :

22 thread group implementation Redundant_Processing.basic 23 subcomponents 24 processing: thread Processing [3]; 25 voting: thread voter; 26 connections 27 voteconn: port processing.Result -> voting.Input {Connection_Pattern => (One_To_One);}; 28 procconn: port Input -> processing.Input; 29 recon: port voting.Output -> Result; 30 end Redundant_Processing.basic;

It's an ambiguity in connections of componet implementation.From syntax we have defined,I get the deducing path:

1 syntax CmpImpl ::= CmpCategory Mimplementation CmpImplName CmpImplAssocDef Mend CmpImplName MSemicolon

2 syntax CmpImplAssocDef ::= CmpImplAssocDefElem

3 syntax CmpImplAssocDefElem ::= Mconnections ConnectionList

4 syntax ConnectionList ::= Connection

5 syntax Connection ::= Id Mcolon SomeConnections MSemicolon

6 syntax SomeConnections ::= PortConnection PpeInMode

7 syntax PpeInMode ::= MBraceLeft PpeAssocList MBraceRight

8 syntax PpeAssocList ::= PpeAssoc

9 syntax PpeAssoc ::= UniPpeId MRoughArrow Assignment MSemicolon

10 syntax Assignment ::= PpeValue

11 syntax PpeValue ::= PpeListValue

12 syntax PpeListValue ::= MBracketLeft PpeListValueMidSymbol MBracketRight

13 syntax PpeListValueMidSymbol ::= PpeExpression

14 syntax PpeExpression ::= BooleanTerm

15 syntax BooleanTerm ::= BooleanPpeConstantTerm

16 syntax BooleanPpeConstantTerm ::= PpeConstantTerm

17 syntax PpeConstantTerm ::= Id

From 12,13,14, we get the term : MBracketLeft BooleanTerm MBracketRight so it is maybe a geneogenous ambiguty !

nwpuzhangfan commented 9 years ago

try to write automatic test script to speed up test process

suweining notifications@github.com编写:

A good news ,after altered the ambiguity about left-linear && right-linear grammar, the kAADL analyze the test file more correct.But still some error: Here is the warning :

[Warning] Inner Parser: Parsing ambiguity. Arbitrarily choosing the first. 1: PpeListValue ::= MBracketLeft PpeListValueMidSymbol MBracketRight ( One_To_One ) 2: BooleanTerm ::= MBracketLeft BooleanTerm MBracketRight ( One_To_One )

there must be more warning like above while analyze other test files.we will post them latter

— Reply to this email directly or view it on GitHub.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/FormalADL/kAADL/issues/4#issuecomment-60178809","name":"View Issue"}}

suweining commented 9 years ago

Have been down ! It's src/cmd.shell

nwpuzhangfan commented 9 years ago

please put into tests folder, plus the readme file to explain the usage of each script. also, I think you should name the file name with its porpuse, like "autofulltest.sh"

suweining notifications@github.com编写:

Have been down ! It's src/cmd.shell

— Reply to this email directly or view it on GitHub.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/FormalADL/kAADL/issues/4#issuecomment-60214540","name":"View Issue"}}

nwpuzhangfan commented 9 years ago

well done!

suweining notifications@github.com编写:

here some discoveries about the [Warning] above. I locate the error position : File: /home/swn/test/standard/pass/Ports.aad Location: (27,75,27,87) :

22 thread group implementation Redundant_Processing.basic 23 subcomponents 24 processing: thread Processing [3]; 25 voting: thread voter; 26 connections 27 voteconn: port processing.Result -> voting.Input {Connection_Pattern => (One_To_One);}; 28 procconn: port Input -> processing.Input; 29 recon: port voting.Output -> Result; 30 end Redundant_Processing.basic;

It's an ambiguity in connections of componet implementation.From syntax we have defined,I get the deducing path:

1 syntax CmpImpl ::= CmpCategory Mimplementation CmpImplName CmpImplAssocDef Mend CmpImplName MSemicolon

2 syntax CmpImplAssocDef ::= CmpImplAssocDefElem

3 syntax CmpImplAssocDefElem ::= Mconnections ConnectionList

4 syntax ConnectionList ::= Connection

5 syntax Connection ::= Id Mcolon SomeConnections MSemicolon

6 syntax SomeConnections ::= PortConnection PpeInMode

7 syntax PpeInMode ::= MBraceLeft PpeAssocList MBraceRight

8 syntax PpeAssocList ::= PpeAssoc

9 syntax PpeAssoc ::= UniPpeId MRoughArrow Assignment MSemicolon

10 syntax Assignment ::= PpeValue

11 syntax PpeValue ::= PpeListValue

12 syntax PpeListValue ::= MBracketLeft PpeListValueMidSymbol MBracketRight

13 syntax PpeListValueMidSymbol ::= PpeExpression

14 syntax PpeExpression ::= BooleanTerm

15 syntax BooleanTerm ::= BooleanPpeConstantTerm

16 syntax BooleanPpeConstantTerm ::= PpeConstantTerm

17 syntax PpeConstantTerm ::= Id

From 12,13,14, we get the term : MBracketLeft BooleanTerm MBracketRight so it is maybe a geneogenous ambiguty !

— Reply to this email directly or view it on GitHub.

{"@context":"http://schema.org","@type":"EmailMessage","description":"View this Issue on GitHub","action":{"@type":"ViewAction","url":"https://github.com/FormalADL/kAADL/issues/4#issuecomment-60190146","name":"View Issue"}}

suweining commented 9 years ago

The reason of conflict:

syntax PpeValue ::= PpeListValue syntax PpeListValue ::= MBracketLeft PpeListValueMidSymbol MBracketRight syntax PpeListValueMidSymbol ::= PpeExpression syntax PpeExpression ::= BooleanTerm

can get " MBracketLeft BooleanTerm MBracketRight ".

But

syntax PpeValue ::= SinglePpeValue syntax SinglePpeValue ::= PpeExpression syntax PpeExpression ::= BooleanTerm syntax BooleanTerm ::= MBracketLeft BooleanTerm MBracketRight

also get " MBracketLeft BooleanTerm MBracketRight "

Solution :

Firstly,review the syntax as follow:

syntax PpeListValue ::= MBracketLeft MBracketRight | MBracketLeft PpeListValueMidSymbol MBracketRight syntax PpeListValueMidSymbol ::= PpeListValue | PpeExpression | PpeListValueMidSymbol MComma PpeListValueMidSymbol syntax PpeExpression ::= BooleanTerm | RealTerm | IntegerTerm | StringTerm | EnumerationTerm | UnitTerm | RealRangeTerm | IntegerRangeTerm | PpeTerm | CmpClassifierTerm | RefTerm | RecordTerm | ComputedTerm syntax BooleanTerm ::= BooleanValue | BooleanPpeConstantTerm | Mnot BooleanTerm | BooleanTerm Mand BooleanTerm | BooleanTerm Mor BooleanTerm | MBracketLeft BooleanTerm MBracketRight (ps.the syntax is about property_list_value,property_expression and boolean_term in the syntax card.)

It is very clearly to get the syntax :

syntax PpeListValue ::= MBracketLeft BooleanTerm MBracketRight

Secondly,The unterminal symbol, BooleanTerm,only appears in the above syntax.This is very important massage!

So,We get the solution :just delete "MBracketLeft BooleanTerm MBracketRight" from syntax of BooleanTerm.

Because through PpeListValue can get "MBracketLeft BooleanTerm MBracketRight" and the range of action of BooleanTerm

is much less than the PpeListValue .

However, BooleanTerm is part of PpeExpression ,and we must update the defination where PpeExpression appeared beacuse we have change the define of BooleanTerm.

Such as :

syntax DefaultPpeExpression ::= PpeExpression

change to :

syntax DefaultPpeExpression ::= PpeExpression | MBracketLeft BooleanTerm MBracketRight