Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guided convergence in Rascal: first steps
- Loading branch information
1 parent
062817c
commit 0f5ef68
Showing
18 changed files
with
1,441 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module analyse::Metrics | ||
|
||
import syntax::BGF; | ||
|
||
public set[str] allNs(list[BGFProduction] ps) = definedNs(ps) + usedNs(ps); | ||
public set[str] allNs(BGFGrammar g) = allNs(g.prods); | ||
|
||
public set[str] topNs(list[BGFProduction] ps) = definedNs(ps) - usedNs(ps); | ||
public set[str] topNs(BGFGrammar g) = topNs(g.prods); | ||
|
||
public set[str] allTs(list[BGFProduction] ps) = {s | /terminal(str s) := ps}; | ||
public set[str] allTs(BGFGrammar g) = allTs(g.prods); | ||
public set[str] usedNs(list[BGFProduction] ps) = {s | /nonterminal(str s) := ps}; | ||
public set[str] usedNs(BGFGrammar g) = usedNs(g.prods); | ||
|
||
public set[str] definedNs(list[BGFProduction] ps) = {s | production(_,str s,_) <- ps}; | ||
public set[str] definedNs(BGFGrammar g) = definedNs(g.prods); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module converge::Guided | ||
|
||
import IO; | ||
import Set; | ||
import Map; | ||
import List; | ||
import io::ReadBGF; | ||
import syntax::BGF; | ||
import analyse::Metrics; | ||
|
||
list[str] sources = | ||
["antlr","dcg","ecore","emf","jaxb","om","python","rascal-a","rascal-c","sdf","txl","xsd"]; | ||
|
||
public void main() | ||
{ | ||
map[str,BGFGrammar] bgfs = (); | ||
println("Reading the grammars..."); | ||
for (src <- sources) | ||
bgfs[src] = readBGF(|home:///projects/slps/topics/convergence/guided/bgf/<src>.bgf|); | ||
println("Parsing the grammarbase with <size(bgfs)> grammars is done."); | ||
println("Starting with the root."); | ||
for (src <- sources) | ||
{ | ||
println(" * Roots in <src>: <bgfs[src].roots>"); | ||
if (isEmpty(bgfs[src].roots)) | ||
{ | ||
bgfs[src].roots = toList(topNs(bgfs[src])); | ||
println(" * Roots in <src> changed to tops: <bgfs[src].roots>"); | ||
} | ||
} | ||
println("Done."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
build: | ||
../../../../shared/tools/antlr2bgf ../../../fl/java1/FL.g antlr.bgf | ||
../../../../shared/tools/dcg2bgf ../../../fl/prolog1/Parser.pro dcg.bgf | ||
../../../../shared/tools/sdf2bgf ../../../fl/asfsdf/Syntax.sdf sdf.bgf | ||
../../../../shared/tools/xsd2bgf ../../../fl/xsd/fl.xsd xsd.bgf | ||
../../../../shared/tools/java2bgf ../../../fl/java1 types om.bgf | ||
../../../../shared/tools/java2bgf ../../../fl/java3 fl jaxb.bgf | ||
../../../../shared/tools/ecore2bgf ../../../fl/emf1/fl.ecore ecore.bgf | ||
../../../../shared/tools/ecore2bgf ../../../fl/emf2/model/fl.ecore emf.bgf | ||
../../../../shared/tools/py2bgf ../../../fl/python/parser2.py python.bgf | ||
../../../../shared/tools/rscs2bgf ../../../fl/rascal/src/Concrete.rsc rascal-c.bgf | ||
../../../../shared/tools/rscd2bgf ../../../fl/rascal/src/Abstract.rsc rascal-a.bgf | ||
../../../../shared/tools/txl2bgf ../../../fl/txl/FL.Txl txl.bgf | ||
|
||
test: | ||
ls -1 *.bgf | xargs -n1 ../../../../shared/tools/validate bgf | ||
|
||
clean: | ||
rm -rf *.bgf | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,247 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<bgf:grammar xmlns:bgf="http://planet-sl.org/bgf"> | ||
<bgf:production> | ||
<nonterminal>program</nonterminal> | ||
<bgf:expression> | ||
<plus> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>f</selector> | ||
<bgf:expression> | ||
<nonterminal>function</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</plus> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>function</nonterminal> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>n</selector> | ||
<bgf:expression> | ||
<nonterminal>ID</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<plus> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>a</selector> | ||
<bgf:expression> | ||
<nonterminal>ID</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</plus> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>=</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>e</selector> | ||
<bgf:expression> | ||
<nonterminal>expr</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<plus> | ||
<bgf:expression> | ||
<nonterminal>NEWLINE</nonterminal> | ||
</bgf:expression> | ||
</plus> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>expr</nonterminal> | ||
<bgf:expression> | ||
<choice> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>b</selector> | ||
<bgf:expression> | ||
<nonterminal>binary</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>a</selector> | ||
<bgf:expression> | ||
<nonterminal>apply</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>i</selector> | ||
<bgf:expression> | ||
<nonterminal>ifThenElse</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</choice> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>binary</nonterminal> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>l</selector> | ||
<bgf:expression> | ||
<nonterminal>atom</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<star> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>o</selector> | ||
<bgf:expression> | ||
<nonterminal>ops</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>r</selector> | ||
<bgf:expression> | ||
<nonterminal>atom</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</star> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>apply</nonterminal> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>i</selector> | ||
<bgf:expression> | ||
<nonterminal>ID</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<plus> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>a</selector> | ||
<bgf:expression> | ||
<nonterminal>atom</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</plus> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>ifThenElse</nonterminal> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<terminal>if</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>c</selector> | ||
<bgf:expression> | ||
<nonterminal>expr</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>then</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>e1</selector> | ||
<bgf:expression> | ||
<nonterminal>expr</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>else</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>e2</selector> | ||
<bgf:expression> | ||
<nonterminal>expr</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>atom</nonterminal> | ||
<bgf:expression> | ||
<choice> | ||
<bgf:expression> | ||
<nonterminal>ID</nonterminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<nonterminal>INT</nonterminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<sequence> | ||
<bgf:expression> | ||
<terminal>(</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<selectable> | ||
<selector>e</selector> | ||
<bgf:expression> | ||
<nonterminal>expr</nonterminal> | ||
</bgf:expression> | ||
</selectable> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>)</terminal> | ||
</bgf:expression> | ||
</sequence> | ||
</bgf:expression> | ||
</choice> | ||
</bgf:expression> | ||
</bgf:production> | ||
<bgf:production> | ||
<nonterminal>ops</nonterminal> | ||
<bgf:expression> | ||
<choice> | ||
<bgf:expression> | ||
<terminal>==</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>+</terminal> | ||
</bgf:expression> | ||
<bgf:expression> | ||
<terminal>-</terminal> | ||
</bgf:expression> | ||
</choice> | ||
</bgf:expression> | ||
</bgf:production> | ||
</bgf:grammar> |
Oops, something went wrong.