Permalink
Browse files

running differential tests with a bigger set

git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@896 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information...
grammarware committed Dec 9, 2010
1 parent c394592 commit 1e9178243ff5d02adfa82a258718a78306549040
Showing with 33 additions and 9 deletions.
  1. +10 −3 shared/python/BGF.py
  2. +1 −1 topics/export/ebnf/Makefile
  3. +22 −5 topics/extraction/rascal/extract.py
View
@@ -182,7 +182,14 @@ def getXml(self):
self.xml.append(self.expr.getXml())
return self.ex
def __str__(self):
return self.sel+'::'+str(self.expr)
name = self.expr.__class__.__name__
if name == 'Expression':
name = self.expr.wrapped.__class__.__name__
#print name
if name in ('Plus','Star','Optional'):
return self.sel+'::('+str(self.expr)+')'
else:
return self.sel+'::'+str(self.expr)
# epsilon::EPSILON
class Epsilon:
@@ -258,7 +265,7 @@ def add(self,expr):
def getXml(self):
#print 'Getting the XML of sequence...'
if len(self.data) == 0:
return None
return Epsilon().getXml()
elif len(self.data) == 1:
return self.data[0].getXml()
else:
@@ -289,7 +296,7 @@ def add(self,expr):
def getXml(self):
#print 'Getting the XML of choice...'
if len(self.data) == 0:
return None
return Empty().getXml()
elif len(self.data) == 1:
return self.data[0].getXml()
else:
@@ -1,5 +1,5 @@
test:
ls -1 ../../storage/bgf/tests.small/*.bgf | xargs -n1 ./testperform
ls -1 ../../storage/bgf/tests/*.bgf | xargs -n1 ./testperform
clean:
rm -f *.bnf
@@ -26,8 +26,9 @@
continue
if line[0] == '@':
continue
elif line[0] == '=' or line[0] == '|':
elif line[0] == '=' or line[0] == '|' or line[0] == '>':
# "all", treat as alternatives
# "first", treat as an alternative for now
if nt == '':
print '['+str(cx)+']','Found first line, but of what nonterminal?'
continue
@@ -40,9 +41,6 @@
elif line[0] == '-':
# "reject"
pass
elif line[0] == '>':
# "first"
pass
elif line[0:2] == '//':
# comment
continue
@@ -79,16 +77,33 @@
for alt in grammar[nt]:
prod = BGF.Production()
prod.setNT(nt)
if alt[0] in ('bracket','left','right','lex'):
print 'Skipped a modifier',alt[0],'at',nt
alt = alt[1:]
if alt[-1] == ';':
alt = alt[:-1]
if alt[0][-1] == ':':
prod.setLabel(alt[0][:-1])
alt = alt[1:]
if len(alt)>1 and alt[1] == ':':
# if there is whitespace between the label and the :
prod.setLabel(alt[0])
alt = alt[2:]
cx = 0
seq = BGF.Sequence()
sym = None
print '['+str(cx)+']',alt
while cx<len(alt):
# comments
if alt[cx][:2] == '/*':
if alt[cx].find('*/')>0:
alt[cx] = alt[cx][:alt[cx].index('/*')] + alt[cx][alt[cx].index('*/')+2:]
if alt[cx] == '':
cx += 1
continue
else:
print '['+str(cx)+']','TODO: a comment spanning several tokens'
# nonterminals
if alt[cx][0].isupper():
if sym:
seq.add(sym)
@@ -114,7 +129,7 @@
sym.setName(term)
cx +=1
continue
if alt[cx][0] == '[':
if alt[cx][0] == '[' or alt[cx][:2] == '![':
# not quite correct
if sym:
seq.add(sym)
@@ -162,7 +177,9 @@
if sym:
seq.add(sym)
prod.setExpr(seq)
#print str(prod)
bgf.addProd(prod)
print str(bgf)
ET.ElementTree(bgf.getXml()).write(sys.argv[2])
sys.exit(0)

0 comments on commit 1e91782

Please sign in to comment.