Skip to content

Commit

Permalink
A decisive change: now the output of the HTML->BGF extractor (for JLS…
Browse files Browse the repository at this point in the history
… test case)

is by default vertical, and the transformation sequences need to perform horizontal
explicitly when necessary.


git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@430 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Feb 2, 2009
1 parent b27697e commit 89353f6
Show file tree
Hide file tree
Showing 41 changed files with 849 additions and 676 deletions.
16 changes: 13 additions & 3 deletions topics/extraction/html2bgf/html2bgf.py
Expand Up @@ -9,8 +9,6 @@
pp_outer = pp_mode
verbose = False
totalerrors = 0
# pp_mode == MODE_ITALIC
# pp_mode == MODE_FIXED

pessimistic = [False,0,0]
prods = {}
Expand Down Expand Up @@ -111,6 +109,9 @@ def serialiseExpression(seq):
def serialiseX(name,choices):
return '<bgf:production><nonterminal>'+name+'</nonterminal>'+traverse(choices)+'</bgf:production>'

def serialiseY(name,choice):
return '<bgf:production><nonterminal>'+name+'</nonterminal>'+serialiseExpression(choice)+'</bgf:production>'

def traverse(c):
if len(c)==1:
return serialiseExpression(c[0])
Expand Down Expand Up @@ -460,6 +461,15 @@ def printGrammar(fn):
ext.write('</bgf:grammar>')
ext.close()

def printGrammarVertical(fn):
ext = open(fn,'w')
ext.write('<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">')
for nt in prods.keys():
for vertprod in prods[nt]:
ext.write(serialiseY(nt,vertprod))
ext.write('</bgf:grammar>')
ext.close()

def breakWords(nt,s):
# transforms terminals like "aaa.bbb" to "aaa" "." "bbb"
word = s[1:-1]
Expand Down Expand Up @@ -799,7 +809,7 @@ def fixBracketPair(nt,arr,left,right):
preprocessCorrect()
killDuplicates()
print 'Writing the extracted grammar...'
printGrammar(sys.argv[2])
printGrammarVertical(sys.argv[2])
if pessimistic[2]:
print 'Total of',pessimistic[2]+pessimistic[1],'problems encountered and coped with.'
else:
Expand Down
4 changes: 0 additions & 4 deletions topics/java/lci/xbgf/correct-app2.xbgf
Expand Up @@ -43,9 +43,6 @@

<!-- ISSUE CORRECT SPECERROR
let's complete some of the statements with a trailing semicolon-->
<xbgf:vertical>
<nonterminal>Statement</nonterminal>
</xbgf:vertical>
<xbgf:designate>
<bgf:production>
<label>ContinueStatement</label>
Expand Down Expand Up @@ -142,7 +139,6 @@
<xbgf:strip>
<label>BreakStatement</label>
</xbgf:strip>
<xbgf:horizontal>Statement</xbgf:horizontal>

<!-- ISSUE CORRECT SPECERROR
Expression is referenced as Expr:
Expand Down
10 changes: 9 additions & 1 deletion topics/java/lci/xbgf/correct-doc1.xbgf
Expand Up @@ -15,6 +15,7 @@
vs.
- [], ;([n(ConstantModifier), ,([n(ConstantModifiers), n(ConstantModifer)])])
-->
<xbgf:horizontal>ConstantModifiers</xbgf:horizontal>
<xbgf:chain>
<bgf:production>
<nonterminal>ConstantModifiers</nonterminal>
Expand All @@ -23,6 +24,9 @@
</bgf:expression>
</bgf:production>
</xbgf:chain>
<xbgf:vertical>
<nonterminal>ConstantModifier</nonterminal>
</xbgf:vertical>
<xbgf:add>
<bgf:production>
<nonterminal>ConstantModifiers</nonterminal>
Expand All @@ -38,7 +42,6 @@
</bgf:expression>
</bgf:production>
</xbgf:add>
<xbgf:horizontal>ConstantModifiers</xbgf:horizontal>

<!-- ISSUE CORRECT SPECERROR
The authors fix an old problem here. (fixed partially
Expand Down Expand Up @@ -93,6 +96,7 @@
,([t((), n(ReferenceType), t()), n(UnaryExpressionNotPlusMinus)]),
,([t((), n(PrimitiveType), ?(n(Dims)), t()), n(UnaryExpression)])])
-->
<xbgf:horizontal>CastExpression</xbgf:horizontal>
<xbgf:factor>
<bgf:expression>
<choice>
Expand Down Expand Up @@ -215,4 +219,8 @@
</optional>
</bgf:expression>
</xbgf:massage>
<xbgf:vertical>
<nonterminal>CastExpression</nonterminal>
</xbgf:vertical>

</xbgf:sequence>
7 changes: 7 additions & 0 deletions topics/java/lci/xbgf/correct-doc2.xbgf
Expand Up @@ -55,6 +55,9 @@
</bgf:expression>
</bgf:production>
</xbgf:define>
<xbgf:vertical>
<nonterminal>ClassName</nonterminal>
</xbgf:vertical>

<!-- ISSUE CORRECT SPECERROR
- Fail: ConstructorDeclarator.
Expand All @@ -77,6 +80,7 @@
','([t('('), n('ReferenceType'), t(')'), n('UnaryExpressionNotPlusMinus')]),
','([t('('), n('PrimitiveType'), ?(n('Dims')), t(')'), n('UnaryExpression')])])),
-->
<xbgf:horizontal>CastExpression</xbgf:horizontal>
<xbgf:factor>
<bgf:expression>
<choice>
Expand Down Expand Up @@ -199,5 +203,8 @@
</optional>
</bgf:expression>
</xbgf:massage>
<xbgf:vertical>
<nonterminal>CastExpression</nonterminal>
</xbgf:vertical>

</xbgf:sequence>
14 changes: 10 additions & 4 deletions topics/java/lci/xbgf/correct-doc3.xbgf
Expand Up @@ -74,6 +74,9 @@
</bgf:expression>
</bgf:production>
</xbgf:define>
<xbgf:vertical>
<nonterminal>TypeParameterList</nonterminal>
</xbgf:vertical>

<!--ISSUE CORRECT SPECERROR
- Fail: ConstructorDeclarator.
Expand Down Expand Up @@ -116,6 +119,9 @@
</bgf:expression>
</bgf:production>
</xbgf:define>
<xbgf:vertical>
<nonterminal>ClassName</nonterminal>
</xbgf:vertical>

<!-- ISSUE CORRECT SPECERROR
"Expression1" and "Expression2" define different "Expression"s in AssertStatement actually -->
Expand All @@ -136,6 +142,7 @@
','([t('('), n('ReferenceType'), t(')'), n('UnaryExpressionNotPlusMinus')]),
','([t('('), n('PrimitiveType'), ?(n('Dims')), t(')'), n('UnaryExpression')])])),
-->
<xbgf:horizontal>CastExpression</xbgf:horizontal>
<xbgf:factor>
<bgf:expression>
<choice>
Expand Down Expand Up @@ -258,6 +265,9 @@
</optional>
</bgf:expression>
</xbgf:massage>
<xbgf:vertical>
<nonterminal>CastExpression</nonterminal>
</xbgf:vertical>

<!-- ISSUE CORRECT SPECERROR
A mess due to duplicate definitions:
Expand All @@ -270,9 +280,6 @@
,([n(TypeName), t(.), n(Identifier)]),
,([n(PackageOrTypeName), t(.), n(Identifier)])])
-->
<xbgf:vertical>
<nonterminal>TypeName</nonterminal>
</xbgf:vertical>
<xbgf:remove>
<bgf:production>
<nonterminal>TypeName</nonterminal>
Expand All @@ -291,6 +298,5 @@
</bgf:expression>
</bgf:production>
</xbgf:remove>
<xbgf:horizontal>TypeName</xbgf:horizontal>

</xbgf:sequence>
5 changes: 4 additions & 1 deletion topics/java/lci/xbgf/deyaccify-doc2.xbgf
Expand Up @@ -8,6 +8,7 @@
vs.
- [], ;([n(SwitchBlockStatementGroup), ,([n(SwitchBlockStatementGroups), n(SwitchBlockStatementGroup)])])
-->
<xbgf:horizontal>SwitchBlockStatementGroups</xbgf:horizontal>
<xbgf:deyaccify>SwitchBlockStatementGroups</xbgf:deyaccify>
<xbgf:extract>
<bgf:production>
Expand Down Expand Up @@ -55,14 +56,16 @@
vs.
- [], ;([n(CatchClause), ,([n(Catches), n(CatchClause)])])
-->
<xbgf:horizontal>Catches</xbgf:horizontal>
<xbgf:deyaccify>Catches</xbgf:deyaccify>

<!--
<!--
- Fail: BlockStatements.
- [], *(n(BlockStatement))
vs.
- [], ;([n(BlockStatement), ,([n(BlockStatements), n(BlockStatement)])])
-->
<xbgf:horizontal>BlockStatements</xbgf:horizontal>
<xbgf:deyaccify>BlockStatements</xbgf:deyaccify>

</xbgf:sequence>
6 changes: 6 additions & 0 deletions topics/java/lci/xbgf/edit-doc1.xbgf
Expand Up @@ -28,6 +28,9 @@
</bgf:expression>
</bgf:production>
</xbgf:introduce>
<xbgf:vertical>
<nonterminal>PackageOrTypeName</nonterminal>
</xbgf:vertical>

<!--
Local substitution:
Expand Down Expand Up @@ -270,5 +273,8 @@
</optional>
</bgf:expression>
</xbgf:massage>
<xbgf:vertical>
<nonterminal>ClassInstanceCreationExpression</nonterminal>
</xbgf:vertical>

</xbgf:sequence>
2 changes: 0 additions & 2 deletions topics/java/lci/xbgf/edit-doc2.xbgf
Expand Up @@ -2,8 +2,6 @@
xmlns:bgf="http://planet-sl.org/bgf"
xmlns:xbgf="http://planet-sl.org/xbgf">

<xbgf:horizontal>Primary</xbgf:horizontal>

<!-- GENERALITY?
ConstructorBody is defined as:
{ [ ExplicitConstructorInvocation ] [ BlockStatements ] }
Expand Down

0 comments on commit 89353f6

Please sign in to comment.