Skip to content

Commit

Permalink
derived source nodes in LCF; showing derived sources and automated ac…
Browse files Browse the repository at this point in the history
…tions on the diagrams; correct rendering of unknown values on diagrams for multi-source targets

git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@651 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Jun 3, 2009
1 parent 64c3118 commit cea9cfb
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 21 deletions.
42 changes: 29 additions & 13 deletions shared/python/lci.py
Expand Up @@ -96,6 +96,7 @@ def ChainFromArray(a):
# extension, correction, relaxation
ttype = {}
orderedsrc = []
derived = {}
shortcuts = {}
actions = []
autoactions = {}
Expand Down Expand Up @@ -144,7 +145,9 @@ def readConfiguration (cfg):
testsets[xmlnode.findtext('name')]=expandxml(xmlnode.findall('command')[0],{})
# sources
for xmlnode in config.findall('//source'):
orderedsrc.append(xmlnode.findtext('name'));
orderedsrc.append(xmlnode.findtext('name'))
if xmlnode.findall('derived'):
derived[xmlnode.findtext('name')]=(xmlnode.findtext('derived/from'),xmlnode.findtext('derived/using'))
extractor[xmlnode.findtext('name')]=expandxml(xmlnode.findall('grammar/extraction')[0],{})
if xmlnode.findall('grammar/parsing'):
parser[xmlnode.findtext('name')]=expandxml(xmlnode.findall('grammar/parsing')[0],{})
Expand Down Expand Up @@ -230,28 +233,32 @@ def expandxml(mixed,rep):
def quote(a):
return '"'+a+'"'

def addarc(fromnode,tonode,q,labelnode):
if [fromnode,tonode,q,labelnode] not in graphBig:
graphBig.append([fromnode,tonode,q,labelnode])

def makeGraph():
# first we generate a complete picture
for x in targets.keys():
for branch in targets[x]:
graphSmall.append((branch[0],x))
if len(branch)==1:
graphBig.append((branch,Chain(x),'',x))
graphBig.append((branch,Chain(x),'',x,''))
else:
for i in range(1,len(branch)-1):
graphBig.append((branch[:i],branch[:(i+1)],stripSpecifics(branch[i]),x))
graphBig.append((branch[:-1],Chain(x),stripSpecifics(branch[-1]),x))
if branch[i] in autoactions.keys():
gen = autoactions[branch[i]]
else:
gen = ''
graphBig.append((branch[:i],branch[:(i+1)],stripSpecifics(branch[i]),x,gen))
if branch[-1] in autoactions.keys():
gen = autoactions[branch[-1]]
else:
gen = ''
graphBig.append((branch[:-1],Chain(x),stripSpecifics(branch[-1]),x,gen))

def distanceBetween(node,tgt):
if node()==tgt:
return '?'
if len(targets[tgt])!=2:
print '[WARN] Only binary branches supported for now.'
return '?'
return '??'
if targets[tgt][0]().find(node())==0:
return compareGrammars(node,targets[tgt][1])
elif targets[tgt][1]().find(node())==0:
Expand Down Expand Up @@ -347,6 +354,8 @@ def dumpGraph(df):
par += 'label="'+arc[2]+'" '
if arc[1] in failed:
par += 'color=red '
if arc[4]:
par += 'taillabel="'+arc[4]+'" labelfontname="Times-Italic" style=bold '
if arc[1]() in targets.keys():
pseudo = arc[0][:]
pseudo.append(arc[2])
Expand Down Expand Up @@ -380,7 +389,9 @@ def dumpGraph(df):
cx = distanceBetween(node,goal)
#print '[----]',node,'(->',goal,') =',cx,'['+tmp+']'
dot.write(' [color='+colour)
if cx != '?':
if cx == '??':
dot.write(', label="?"')
elif cx != '?':
dot.write(', label="'+cx+'"')
#currentFile.write(node.lastAction()+','+`eval(cx)`+'\n')
if node.dotNodeName(goal) in dablNodezz:
Expand All @@ -390,7 +401,7 @@ def dumpGraph(df):
#currentFile.close()
dot.write('}')
dot.close()
run = 'dot -Tpdf '+dot.name+' -o '+df+'_large.pdf'
run = 'dot -Tpdf '+dot.name+' -o '+df+'_large.pdf 2>/dev/null'
writeLog(run)
if os.system(run):
print '[WARN] Detailed diagram not generated'
Expand All @@ -403,13 +414,18 @@ def dumpGraph(df):
dot.write(' [color=red]')
elif x in almostFailed:
dot.write(' [color=blue]')
if x in derived.keys():
dot.write(' [shape=egg]')
dot.write(';')
for x in orderedsrc:
dot.write(quote(x))
if x==orderedsrc[-1]:
dot.write(';')
else:
dot.write('->')
# "xsd"->"jaxb" [style=solid,label="xjc",color=grey,labelfloat,fontname="Times-Italic"];
for x in derived.keys():
dot.write('"'+derived[x][0]+'"->"'+x+'" [style=solid,label="'+derived[x][1]+'",color=grey,labelfloat,fontname="Times-Italic"];')
dot.write('}')
dot.write('node [shape=octagon]\n')
for x in targets.keys():
Expand All @@ -426,7 +442,7 @@ def dumpGraph(df):
dot.write(';\n')
dot.write('}')
dot.close()
run = 'dot -Tpdf '+dot.name+' -o '+df+'_small.pdf'
run = 'dot -Tpdf '+dot.name+' -o '+df+'_small.pdf 2>/dev/null'
writeLog(run)
if os.system(run):
print '[WARN] Abstract diagram not generated.'
Expand Down Expand Up @@ -760,7 +776,7 @@ def checkConsistency():
sysexit(18)

if __name__ == "__main__":
print 'Language Covergence Infrastructure v1.16'
print 'Language Covergence Infrastructure v1.17'
if len(sys.argv) == 3:
log = open(sys.argv[1].split('.')[0]+'.log','w')
readConfiguration(sys.argv[1])
Expand Down
4 changes: 2 additions & 2 deletions shared/python/xbgf_overview.py
Expand Up @@ -84,8 +84,8 @@ def report(keys,key,note):
sorted.sort()
if sorted == ['read12','read123','jls1','jls12','jls123','jls2','jls3']:
sorted = ['jls1','jls2','jls3','jls12','jls123','read12','read123']
elif sorted == ['abstract','concrete','java','limit','topdown']:
sorted = ['topdown','concrete','java','abstract','limit']
elif sorted == ['abstract','concrete','java','limit','model','topdown']:
sorted = ['topdown','concrete','model','java','abstract','limit']
print '\\begin{tabular}{l|'+('c|'*len(targets))+'|c}'
for x in sorted:
print '&\\textbf{'+x+'}',
Expand Down
1 change: 0 additions & 1 deletion shared/tools/lci
Expand Up @@ -14,6 +14,5 @@ elif [ ! -r $1 ]; then
echo "Oops: $1 not found or not readable."
exit 1
else
sh ${SLPS}/shared/tools/checkxml lcf $1
python ${SLPS}/shared/python/lci.py $1 $2
fi
14 changes: 11 additions & 3 deletions shared/xsd/lcf.xsd
Expand Up @@ -98,7 +98,15 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="name" type="xsd:ID" />
<xsd:element name="derived" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="from" type="xsd:IDREF"/>
<xsd:element name="using" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="grammar">
<xsd:complexType>
<xsd:annotation>
Expand Down Expand Up @@ -164,11 +172,11 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="name" type="xsd:string" />
<xsd:element name="name" type="xsd:ID" />
<xsd:element maxOccurs="unbounded" name="branch">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="input" type="xsd:string" />
<xsd:element name="input" type="xsd:IDREF" />
<xsd:element name="preparation" type="lcf:phase" minOccurs="0"/>
<xsd:element name="nominal-matching" type="lcf:phase" minOccurs="0"/>
<xsd:element name="normalizing" type="lcf:phase" minOccurs="0"/>
Expand Down
12 changes: 10 additions & 2 deletions topics/fl/lci/fl.lcf
Expand Up @@ -154,7 +154,11 @@
</source>

<source>
<name>emf</name>
<name>ecore2</name>
<derived>
<from>xsd</from>
<using>xsd2ecore</using>
</derived>
<grammar>
<extraction>
<expand>tools</expand>/ecore2bgf <expand>fl</expand>/emf2/model/fl.ecore
Expand Down Expand Up @@ -196,6 +200,10 @@

<source>
<name>jaxb</name>
<derived>
<from>xsd</from>
<using>xjc</using>
</derived>
<grammar>
<extraction>
<expand>tools</expand>/java2bgf <expand>fl</expand>/java3 fl
Expand Down Expand Up @@ -264,7 +272,7 @@
</relaxation>
</branch>
<branch>
<input>emf</input>
<input>ecore2</input>
<nominal-matching>
<perform>rename-emf</perform>
</nominal-matching>
Expand Down
Binary file modified topics/fl/lci/snapshot/architecture_large.pdf
Binary file not shown.
Binary file modified topics/fl/lci/snapshot/architecture_small.pdf
Binary file not shown.

0 comments on commit cea9cfb

Please sign in to comment.