Skip to content

Commit

Permalink
running differential tests with a bigger set
Browse files Browse the repository at this point in the history
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 1e91782
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
13 changes: 10 additions & 3 deletions shared/python/BGF.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion topics/export/ebnf/Makefile
Original file line number Diff line number Diff line change
@@ -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
27 changes: 22 additions & 5 deletions topics/extraction/rascal/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,9 +41,6 @@
elif line[0] == '-':
# "reject"
pass
elif line[0] == '>':
# "first"
pass
elif line[0:2] == '//':
# comment
continue
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 1e91782

Please sign in to comment.