Skip to content

Commit

Permalink
consistent testing; param -> variable in XSL
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@737 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Dec 25, 2009
1 parent 024fdde commit cbd2c0e
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 18 deletions.
2 changes: 1 addition & 1 deletion shared/tools/ecore2bgf
Expand Up @@ -15,7 +15,7 @@ elif [ $# -eq 2 ]; then
elif [ $# -eq 1 ]; then
xsltproc ${SLPS}/shared/xsl/ecore2bgf.xslt $1 > ${LOCAL}/`basename $1 .ecore`.bgf
else
echo "This tool extracts a BGF grammar from an ECore model"
echo "This tool extracts a BGF grammar from an Ecore model"
echo "Usage: ecore2bgf <ecore-model> [<output-grammar>]"
exit 2
fi
Expand Down
5 changes: 2 additions & 3 deletions shared/xsl/ecore2bgf.xslt
@@ -1,7 +1,6 @@
<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:bgf="http://planet-sl.org/bgf"
xmlns:ldf="http://planet-sl.org/ldf"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
Expand All @@ -15,8 +14,8 @@
</xsl:template>

<xsl:template match="eClassifiers">
<xsl:param name="ourEType" select="concat('#//',./@name)"/>
<xsl:param name="ourSuperType" select="substring(@eSuperTypes,4)"/>
<xsl:variable name="ourEType" select="concat('#//',./@name)"/>
<xsl:variable name="ourSuperType" select="substring(@eSuperTypes,4)"/>
<xsl:choose>
<xsl:when test="@abstract='true'">
<bgf:production>
Expand Down
2 changes: 1 addition & 1 deletion topics/extraction/antlr2bgf/Makefile
Expand Up @@ -9,7 +9,7 @@ build:
test:
make clean-tests
../../../shared/tools/antlr2bgf ${source} ${target}.bgf
../../../shared/tools/showbgf ${target}.bgf > ${target}.out
../../../shared/tools/bgf2bnf ${target}.bgf ${target}.out
diff ${target}.out ${target}.baseline

clean:
Expand Down
33 changes: 22 additions & 11 deletions topics/extraction/antlr2bgf/tests/fl.baseline
@@ -1,11 +1,22 @@
Loading XML file 'tests/fl.bgf'.
g( [], [
p([], program, +n(function)),
p([], function, ','([n('ID'), +n('ID'), t(=), n(expr), +n('NEWLINE')])),
p([], expr, ;([n(binary), n(apply), n(ifThenElse)])),
p([], binary, ','([n(atom), *(','([n(ops), n(atom)]))])),
p([], apply, ','([n('ID'), +n(atom)])),
p([], ifThenElse, ','([t(if), n(expr), t(then), n(expr), t(else), n(expr)])),
p([], atom, ;([n('ID'), n('INT'), ','([t('('), n(expr), t(')')])])),
p([], ops, ;([t(==), t(+), t(-)]))
])
program:
function+
function:
ID ID+ "=" expr NEWLINE+
expr:
binary
apply
ifThenElse
binary:
atom (ops atom)*
apply:
ID atom+
ifThenElse:
"if" expr "then" expr "else" expr
atom:
ID
INT
"(" expr ")"
ops:
"=="
"+"
"-"
16 changes: 16 additions & 0 deletions topics/extraction/ecore2bgf/Makefile
@@ -0,0 +1,16 @@
source1 = ../../fl/emf1/fl.ecore
target1 = fl1
source2 = ../../fl/emf2/model/fl.ecore
target2 = fl2

test:
make clean
../../../shared/tools/ecore2bgf ${source1} ${target1}.bgf
../../../shared/tools/ecore2bgf ${source2} ${target2}.bgf
../../../shared/tools/bgf2bnf ${target1}.bgf ${target1}.out
../../../shared/tools/bgf2bnf ${target2}.bgf ${target2}.out
diff ${target1}.out ${target1}.baseline
diff ${target2}.out ${target2}.baseline

clean:
rm -f *.bgf *.out
30 changes: 30 additions & 0 deletions topics/extraction/ecore2bgf/fl1.baseline
@@ -0,0 +1,30 @@
Program:
function::Function+
Function:
name::STR argument::Argument+ definition::Exp
Argument:
name::STR
Exp:
LiteralExp
ArgumentExp
IfThenElseExp
ApplyExp
BinaryExp
LiteralExp:
value::INT
ArgumentExp:
argument::Argument
IfThenElseExp:
if::Exp then::Exp else::Exp
ApplyExp:
function::Function argument::Exp+
BinaryExp:
PlusExp
MinusExp
EqualExp
PlusExp:
left::Exp right::Exp
MinusExp:
left::Exp right::Exp
EqualExp:
left::Exp right::Exp
24 changes: 24 additions & 0 deletions topics/extraction/ecore2bgf/fl2.baseline
@@ -0,0 +1,24 @@
Apply:
name::STR arg::Expr+
Argument:
name::STR
Binary:
ops::Ops left::Expr right::Expr
Expr:
Apply
Argument
Binary
IfThenElse
Literal
Function:
name::STR arg::STR+ rhs::Expr
IfThenElse:
ifExpr::Expr thenExpr::Expr elseExpr::Expr
Literal:
info::INT
Ops:
Equal::EPSILON
Plus::EPSILON
Minus::EPSILON
ProgramType:
function::Function+
12 changes: 10 additions & 2 deletions topics/extraction/txl2bgf/Makefile
@@ -1,3 +1,11 @@
source = ../../fl/txl/FL.Txl
target = tests/fl

test:
../../../shared/tools/txl2bgf ../../fl/txl/FL.Txl fl.bgf
../../../shared/tools/bgf2bnf fl.bgf
make clean
../../../shared/tools/txl2bgf ${source} ${target}.bgf
../../../shared/tools/bgf2bnf ${target}.bgf ${target}.out
diff ${target}.out ${target}.baseline

clean:
rm -f tests/*.bgf tests/*.out
15 changes: 15 additions & 0 deletions topics/extraction/txl2bgf/tests/fl.baseline
@@ -0,0 +1,15 @@
program:
fun+
fun:
id id+ "=" expression newline
expression:
expression op expression
id expression+
"if" expression "then" expression "else" expression
"(" expression ")"
id
number
op:
"+"
"-"
"=="

0 comments on commit cbd2c0e

Please sign in to comment.