Skip to content

Commit

Permalink
chain done
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@1178 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Mar 5, 2012
1 parent 736728e commit 115fc58
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 170 deletions.
57 changes: 56 additions & 1 deletion shared/xsl/exbgf2xbgf.xslt
Expand Up @@ -37,7 +37,7 @@
<!--
An atomic transformation sequence, shielding an entity with a temporarily introduced nonterminal that disappears during transformation.
-->
<xsl:message>[EXBGF] shieldedD ::= extract + ...</xsl:message>
<xsl:message>[EXBGF] shieldedD ::= extract + ... + eliminate</xsl:message>
<xbgf:extract>
<bgf:production>
<nonterminal>SHIELDED-ENTITY</nonterminal>
Expand All @@ -51,6 +51,22 @@
<nonterminal>SHIELDED-ENTITY</nonterminal>
</xbgf:eliminate>
</xsl:template>
<xsl:template match="exbgf:shieldedU">
<!--
An atomic transformation sequence, shielding an entity that does not exist by the beginning of transformation.
-->
<xsl:message>[EXBGF] shieldedU ::= introduce + ... + inline</xsl:message>
<xbgf:introduce>
<bgf:production>
<nonterminal>SHIELDED-ENTITY</nonterminal>
<bgf:expression>
<xsl:copy-of select="entity/*"/>
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xsl:apply-templates select="*[local-name()!='entity']"/>
<xbgf:inline>SHIELDED-ENTITY</xbgf:inline>
</xsl:template>
<xsl:template match="exbgf:tempunfold">
<!--
An atomic transformation sequence, temporarily unfolding a nonterminal.
Expand Down Expand Up @@ -920,6 +936,45 @@
</nonterminal>
</xbgf:vertical>
</xsl:template>
<xsl:template match="exbgf:chainX">
<!--
Chains a nonterminal and adds another vertical production to it.
In other words, goes from A: XYZ to A: B; B: XYZ; A: CD
Conceptually, an injection in the nonterminal call graph.
= chain + addV
-->
<xsl:message>[EXBGF] chainX ::= chain + add</xsl:message>
<xbgf:chain>
<bgf:production>
<nonterminal>
<xsl:value-of select="from"/>
</nonterminal>
<bgf:expression>
<nonterminal>
<xsl:value-of select="to[1]"/>
</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<xsl:for-each select="to[position()&gt;1]">
<xbgf:add>
<vertical>
<bgf:production>
<nonterminal>
<xsl:value-of select="../from"/>
</nonterminal>
<bgf:expression>
<nonterminal>
<xsl:value-of select="."/>
</nonterminal>
</bgf:expression>
</bgf:production>
</vertical>
</xbgf:add>
</xsl:for-each>
</xsl:template>
<xsl:template match="exbgf:introduceH">
<!--
Introduce a nonterminal horizontally for simplicity, wanting to see vertical production rules in the grammar.
Expand Down
31 changes: 13 additions & 18 deletions topics/convergence/java/exbgf/correct-impl2.exbgf
Expand Up @@ -104,14 +104,12 @@
-->
<!-- GENERALITY -->
<!-- INITCORR -->
<xbgf:replace>
<bgf:expression>
<nonterminal>Expr</nonterminal>
</bgf:expression>
<bgf:expression>
<nonterminal>Expression</nonterminal>
</bgf:expression>
</xbgf:replace>
<exbgf:renameN>
<from>Expr</from>
<to>Expression</to>
<in>Expression3</in>
</exbgf:renameN>

<!-- ISSUE CORRECT INCOMPATIBILITY
- Fail: VoidInterfaceMethodDeclaratorRest.
- [], ,([n(FormalParameters), ?(,([t(throws), n(QualifiedIdentifierList)])), t((;))])
Expand Down Expand Up @@ -191,18 +189,15 @@
</bgf:expression>
</bgf:production>
</xbgf:define>
<!-- ISSUE CORRECT SPECERROR unused non-terminal -->
<xbgf:eliminate>
<!-- unused non-terminals -->
<exbgf:eliminate-many>
<!-- ISSUE CORRECT SPECERROR -->
<nonterminal>ArgumentsOpt</nonterminal>
</xbgf:eliminate>
<!-- ISSUE CORRECT SPECERROR unused non-terminal -->
<xbgf:eliminate>
<!-- ISSUE CORRECT SPECERROR -->
<nonterminal>VoidMethodDeclaratorRest</nonterminal>
</xbgf:eliminate>
<!-- ISSUE CORRECT SPECERROR unused non-terminal -->
<xbgf:eliminate>
<!-- ISSUE CORRECT SPECERROR -->
<nonterminal>VariableDeclaratorsRest</nonterminal>
</xbgf:eliminate>
</exbgf:eliminate-many>
<!-- undefine lexical term -->
<!-- GENERALITY -->
<!-- RELAXATION -->
Expand All @@ -215,7 +210,7 @@
- [], ;([,([t(instanceof), n(Type)]), *(,([n(InfixOp), n(Expression3)]))])
vs.
- [], ;([*(,([n(InfixOp), n(Expression3)])), ,([n(Expression3), t(instanceof), n(Type)])])
-->
-->
<!-- KNOWNBUG -->
<xbgf:project>
<bgf:production>
Expand Down
1 change: 1 addition & 0 deletions topics/convergence/java/exbgf/correct-read1.exbgf
Expand Up @@ -12,6 +12,7 @@
vs.
- [], ;([n(ConstantModifier), ,([n(ConstantModifiers), n(ConstantModifer)])])
-->
<!-- cannot combine the following two since VariableModifier must be fresh for chaining -->
<exbgf:chainV>
<from>ConstantModifiers</from>
<to>ConstantModifier</to>
Expand Down
68 changes: 17 additions & 51 deletions topics/convergence/java/exbgf/extend-read12.exbgf
Expand Up @@ -419,18 +419,10 @@
vs.
- [], ;([n(NormalClassDeclaration), n(EnumDeclaration)])
-->
<xbgf:chain>
<bgf:production>
<nonterminal>ClassDeclaration</nonterminal>
<bgf:expression>
<nonterminal>NormalClassDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<!-- EXTENSION -->
<xbgf:appear>
<bgf:production>
<nonterminal>NormalClassDeclaration</nonterminal>
<nonterminal>ClassDeclaration</nonterminal>
<bgf:expression>
<sequence>
<bgf:expression>
Expand Down Expand Up @@ -639,14 +631,11 @@
</bgf:production>
</xbgf:introduce>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
<nonterminal>ClassDeclaration</nonterminal>
<bgf:expression>
<nonterminal>EnumDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</exbgf:addV>
<exbgf:chainX>
<from>ClassDeclaration</from>
<to>NormalClassDeclaration</to>
<to>EnumDeclaration</to>
</exbgf:chainX>
<!-- ISSUE EXTEND
- Fail: InterfaceDeclaration.
- [], ,([?(n(InterfaceModifiers)), t(interface), n(Identifier), ?(n(ExtendsInterfaces)), n(InterfaceBody)])
Expand Down Expand Up @@ -812,23 +801,11 @@
</bgf:expression>
</bgf:production>
</xbgf:import>
<xbgf:chain>
<bgf:production>
<nonterminal>InterfaceDeclaration</nonterminal>
<bgf:expression>
<nonterminal>NormalInterfaceDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
<nonterminal>InterfaceDeclaration</nonterminal>
<bgf:expression>
<nonterminal>AnnotationTypeDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</exbgf:addV>
<exbgf:chainX>
<from>InterfaceDeclaration</from>
<to>NormalInterfaceDeclaration</to>
<to>AnnotationTypeDeclaration</to>
</exbgf:chainX>
<!-- ISSUE EXTEND
- Fail: ForStatement.
- [], ,([t(for), t((), ?(n(ForInit)), t((;)), ?(n(Expression)), t((;)), ?(n(ForUpdate)), t()), n(Statement)])
Expand Down Expand Up @@ -875,23 +852,12 @@
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xbgf:chain>
<bgf:production>
<nonterminal>ForStatement</nonterminal>
<bgf:expression>
<nonterminal>BasicForStatement</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
<nonterminal>ForStatement</nonterminal>
<bgf:expression>
<nonterminal>EnhancedForStatement</nonterminal>
</bgf:expression>
</bgf:production>
</exbgf:addV>
<exbgf:chainX>
<from>ForStatement</from>
<to>BasicForStatement</to>
<to>EnhancedForStatement</to>
</exbgf:chainX>

<!-- ISSUE EXTEND GENERALIZE
- Fail: AbstractMethodDeclaration.
- [], ,([?(n(AbstractMethodModifiers)), n(ResultType), n(MethodDeclarator), ?(n(Throws)), t((;))])
Expand Down
21 changes: 5 additions & 16 deletions topics/convergence/java/exbgf/extendClassDeclarations.exbgf
Expand Up @@ -140,23 +140,12 @@
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xbgf:chain>
<bgf:production>
<nonterminal>ClassDeclaration</nonterminal>
<bgf:expression>
<nonterminal>NormalClassDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
<nonterminal>ClassDeclaration</nonterminal>
<bgf:expression>
<nonterminal>EnumDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</exbgf:addV>
<exbgf:chainX>
<from>ClassDeclaration</from>
<to>NormalClassDeclaration</to>
<to>EnumDeclaration</to>
</exbgf:chainX>
<xbgf:introduce>
<bgf:production>
<nonterminal>EnumConstantName</nonterminal>
Expand Down
23 changes: 7 additions & 16 deletions topics/convergence/java/exbgf/extendInterfaceDeclarations.exbgf
Expand Up @@ -2,14 +2,6 @@
<exbgf:sequence xmlns:bgf="http://planet-sl.org/bgf" xmlns:xbgf="http://planet-sl.org/xbgf" xmlns:exbgf="http://planet-sl.org/exbgf">
<!-- ISSUE EXTEND
annotated declarations -->
<xbgf:chain>
<bgf:production>
<nonterminal>InterfaceDeclaration</nonterminal>
<bgf:expression>
<nonterminal>NormalInterfaceDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<xbgf:introduce>
<bgf:production>
<nonterminal>DefaultValue</nonterminal>
Expand Down Expand Up @@ -190,14 +182,13 @@
</bgf:production>
</xbgf:introduce>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
<nonterminal>InterfaceDeclaration</nonterminal>
<bgf:expression>
<nonterminal>AnnotationTypeDeclaration</nonterminal>
</bgf:expression>
</bgf:production>
</exbgf:addV>
<exbgf:chainX>
<from>InterfaceDeclaration</from>
<to>NormalInterfaceDeclaration</to>
<to>AnnotationTypeDeclaration</to>
</exbgf:chainX>


<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
Expand Down
13 changes: 5 additions & 8 deletions topics/convergence/java/exbgf/extendModifiers.exbgf
Expand Up @@ -348,14 +348,11 @@
<nonterminal>LocalVariableDeclaration</nonterminal>
</in>
</xbgf:fold>
<xbgf:chain>
<bgf:production>
<nonterminal>VariableModifiers</nonterminal>
<bgf:expression>
<nonterminal>VariableModifier</nonterminal>
</bgf:expression>
</bgf:production>
</xbgf:chain>
<!-- cannot combine the following two since VariableModifier must be fresh for chaining -->
<exbgf:chainX>
<from>VariableModifiers</from>
<to>VariableModifier</to>
</exbgf:chainX>
<!-- EXTENSION -->
<exbgf:addV>
<bgf:production>
Expand Down

0 comments on commit 115fc58

Please sign in to comment.