Permalink
Browse files

another test set for BGF

git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@836 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information...
grammarware committed Sep 29, 2010
1 parent d39328a commit d6c69294374669245bf1d57999a52bdb85bedd85
Showing 345 changed files with 375 additions and 22 deletions.
@@ -2,14 +2,18 @@
import sys
basic_elements = ['e','o','i','s','a','t','n']
unary_modifiers = ['z','m','q','p','k']
#basic_elements = ['e','o','i','s','a','t','n']
#unary_modifiers = ['z','m','q','p','k']
binary_modifiers = ['f','c']
names_subsets = ([],['foo'],['foo','bar'])
counter = 0
label = True
def main(dir):
global counter
def main(dir,basic_elements='eoisatn',unary_modifiers='zmqpk',options=''):
global counter, label
if options == '--nolabel':
print 'No labels will be generated.'
label = False
# solitary basic elements
for x in basic_elements:
dump_file(generate_expression(x),dir+'/'+x+'.bgf')
@@ -57,26 +61,35 @@ def main(dir):
for x in names_subsets:
for y in names_subsets:
dump_specific_file(x,y,dir+'/r'+str(len(x))+'l'+str(len(y))+'.bgf')
print counter,'test cases with multiple labelled productions generated successfully'
if label:
print counter,'test cases with multiple labelled productions generated successfully'
else:
print counter,'test cases with multiple productions generated successfully'
return
def dump_file(expr,fname):
global counter
global counter, label
f = open(fname,'w')
f.write('<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><label>foo</label><nonterminal>bar</nonterminal>')
f.write('<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production>')
if label:
f.write('<label>foo</label>')
f.write('<nonterminal>bar</nonterminal>')
f.write(expr)
f.write('</bgf:production></bgf:grammar>')
f.close()
counter += 1
def dump_specific_file(roots,labels,fname):
global counter
global counter, label
f = open(fname,'w')
f.write('<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf">')
for r in roots:
f.write('<root>'+r+'</root>')
for l in labels:
f.write('<bgf:production><label>l'+l+'</label><nonterminal>'+l+'</nonterminal>'+generate_expression('e')+'</bgf:production>')
f.write('<bgf:production>')
if label:
f.write('<label>l'+l+'</label> ')
f.write('<nonterminal>'+l+'</nonterminal>'+generate_expression('e')+'</bgf:production>')
f.write('</bgf:grammar>')
f.close()
counter += 1
@@ -118,11 +131,11 @@ def wrap_expression(code,expr):
return '<bgf:expression>'+expr+'</bgf:expression>'
if __name__ == "__main__":
if len(sys.argv) == 2:
main(sys.argv[1])
if len(sys.argv) >= 2:
apply(main,sys.argv[1:])
else:
print '''BGF Test Set Generator
Usage:'''
print ' ',sys.argv[0],'<input xldf file>','<input ldf file>','<output ldf file>'
print ' ',sys.argv[0],'<output directory>','[<basic elements>]','[<unary modifiers>]','[--nolabel]'
sys.exit(1)
@@ -32,12 +32,12 @@ function main match [</xsl:text>
<xsl:value-of select="./nonterminal"/>
<xsl:text>
</xsl:text>
<!-- what to do with labels? TODO -->
<!-- what to do with labels? TODO
<xsl:if test="./label">
<xsl:text>[</xsl:text>
<xsl:value-of select="./label"/>
<xsl:text>] </xsl:text>
</xsl:if>
</xsl:if>-->
<xsl:choose>
<xsl:when test="./bgf:expression/choice">
<xsl:for-each select="./bgf:expression/choice/bgf:expression">
@@ -1,8 +1,12 @@
generate:
python ../../../shared/python/generateBGF.py tests
@echo 'Generating the big test set...'
@python ../../../shared/python/generateBGF.py tests
@echo 'Generating the small test set...'
@python ../../../shared/python/generateBGF.py tests.small etn qpk --nolabel
@echo 'Both test cases generated.'
test:
/usr/local/bin/xmllint --noout --schema ../../../shared/xsd/bgf.xsd tests/*
clean:
rm -f tests/*
rm -f tests/* tests.small/*
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><nonterminal>x</nonterminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><nonterminal>x</nonterminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><choice><bgf:expression><terminal>x</terminal></bgf:expression><bgf:expression><terminal>x</terminal></bgf:expression></choice></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
@@ -0,0 +1 @@
<?xml version="1.0"?><bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"><bgf:production><nonterminal>bar</nonterminal><bgf:expression><choice><bgf:expression><epsilon/></bgf:expression><bgf:expression><epsilon/></bgf:expression></choice></bgf:expression></bgf:production></bgf:grammar>
Oops, something went wrong.

0 comments on commit d6c6929

Please sign in to comment.