diff --git a/shared/xsd/xbgf.xsd b/shared/xsd/xbgf.xsd index 750becaf..5ffabefc 100644 --- a/shared/xsd/xbgf.xsd +++ b/shared/xsd/xbgf.xsd @@ -470,11 +470,11 @@ An unused definition (at most used within the definition itself) - is removed. The undefine operator should be used instead when - the definition must be remove despite remaining uses. The - remove operator should be used instead when only part of the - definition (i.e., a production of a vertical definition) is - to be removed. + is removed. The undefine operator + should be utilised instead when the definition must be removed despite + remaining uses. The remove operator + should be utilised instead when only part of the definition (i.e., + a production of a vertical definition) is to be removed. @@ -537,8 +537,9 @@ Folding replaces every expression that matches with the right hand side of the given nonterminal's definition with the nonterminal - itself. As with unfold, fold works on the scope of the grammar, - but its impact can be limited to one labelled production or to + itself. As with unfold, + fold works on the scope of the grammar, + and its impact can be limited to one labelled production or to all the productions belonging to one nonterminal. Regardless of the specified scope, folding is not applied to the definition of the argument nonterminal. @@ -546,7 +547,7 @@ Since this transformation strives to preserve the language, it needs a horisontal definition to work. When only one of several existing - definitions is used for folding, it actually increases the semantics + definitions is used for folding, it would actually increase the semantics of the language after transformation---the corresponding XBGF command is called upgrade. @@ -606,11 +607,11 @@ - A definition of a fresh nonterminal is added. The add operator - should be used instead, if the nonterminal is already defined, - is to be merely extended. The define operator should be used - instead, if the nonterminal is readily in use, but merely lacks - a definition. + A definition of a fresh nonterminal is added. The add + operator should be used instead, if the nonterminal is already defined, + is to be merely extended. The define operator + should be used instead, if the nonterminal is readily in use, but merely + lacks a definition. @@ -925,7 +926,8 @@ - A reverse of abridge that can introduce a reflexive chain production. + A reverse of abridge that can introduce + a reflexive chain production. @@ -1058,7 +1060,7 @@ - The most basic unfolding transformation searches for all the instances + The most basic unfolding transformation searches the scope for all the instances of the given nonterminal usage and replaces such occurrences with the defining expression of that nonterminal. By default the scope of the transformation is the full grammar, but it can be limited to all the @@ -1067,9 +1069,9 @@ of the argument nonterminal. - The definition that is being unfolded is assumed to be horisontal - (see the section on refactorings for more information about horisontal - and vertical definitions). + The definition that is being unfolded is assumed to be horisontal, + i.e. to consist of one single production. See the section on refactorings + for more information about horisontal and vertical definitions. @@ -1170,16 +1172,17 @@ - This transformation is the reverse of deyaccify. The productions provided - as arguments must be yaccified with respect to the actual content of the - grammar. If the deyaccification process on them is successful and yields - the production that can be found in the grammar, it is removed and replaced - by these simpler definitions of an optional + This transformation is the reverse of deyaccify. + The productions provided as arguments must be yaccified with respect to the + actual content of the grammar. If the deyaccification process on them is + successful and yields the production that can be found in the grammar, it + is removed and replaced by these simpler definitions of an optional or repeating nonterminal, given in BNF-only expressiveness. - Some complex yaccify cases require prior use of extract for introduction of - an nonterminal for the optional or repeating phrase. + Some complex yaccify cases require prior + use of extract for introduction of an nonterminal for the optional + or repeating phrase. diff --git a/shared/xsl/ldf2tex.xslt b/shared/xsl/ldf2tex.xslt index 1739c803..b842e95b 100644 --- a/shared/xsl/ldf2tex.xslt +++ b/shared/xsl/ldf2tex.xslt @@ -19,6 +19,7 @@ \setcounter{secnumdepth}{2} \setcounter{tocdepth}{2} \usepackage{listings} +\usepackage{graphicx} \lstdefinelanguage{pp}{% numbers=none, literate={EPSILON}{{$\varepsilon$}}1 %{STRING}{{$\lambda$}}1 @@ -386,10 +387,47 @@ + + + + \begin{figure}\begin{center} + + + + \includegraphics[width=0.5\textwidth]{ + + } + + + ...don't know how to insert a figure... + + + \end{center}\caption{ + + } + + \caption{ + + } + + \end{figure} + + + + -\begin{center}\begin{tabular}{ - +\begin{center}\begin{tabular}{c| + c } diff --git a/topics/languedoc/xbgf/Makefile b/topics/languedoc/xbgf/Makefile index fbd842ea..4f637d34 100644 --- a/topics/languedoc/xbgf/Makefile +++ b/topics/languedoc/xbgf/Makefile @@ -2,7 +2,7 @@ validator = ../../../shared/tools/checkxml xldf = ../../../shared/tools/xldf xbgf = ../../../shared/tools/xbgf -build: architecture_large.pdf +build: bnfbgf.pdf ../../../shared/tools/xsd2bgf ../../../shared/xsd/xbgf.xsd xbgf.bgf ../../../topics/extraction/xsd2ldf/ldfgen.py ../../../shared/xsd/xbgf.xsd xbgf.bgf xbgf.ldf ${xldf} xbgf.xldf xbgf.ldf xbgf_ready.ldf @@ -10,9 +10,9 @@ build: architecture_large.pdf pdflatex -interaction=batchmode xbgf pdflatex -interaction=batchmode xbgf -architecture_large.pdf: +bnfbgf.pdf: cd ../../presentation/prettyprint ; make - cp ../../presentation/prettyprint/architecture_large.pdf . + cp ../../presentation/prettyprint/architecture_large.pdf bnfbgf.pdf rebuild: make clean @@ -21,8 +21,7 @@ rebuild: clean: rm -f xbgf*.bgf xbgf*.ldf xbgf.html xbgf.fo xbgf.pdf *.xbnf rm -f bgf*.bgf ldf*.bgf ldf*.ldf ldf.fo ldf.pdf xldf-tmp* - rm -f *.aux *.log *.toc *.tex printed_for_xldf.tmp - rm -f architecture_large.pdf + rm -f *.aux *.log *.toc *.tex printed_for_xldf.tmp bnfbgf.pdf check: ls -1 *.xbgf | xargs -n1 ${validator} xbgf diff --git a/topics/languedoc/xbgf/xldf/completeDecorSection.xldf b/topics/languedoc/xbgf/xldf/completeDecorSection.xldf index ccfc9770..57ec4f9a 100644 --- a/topics/languedoc/xbgf/xldf/completeDecorSection.xldf +++ b/topics/languedoc/xbgf/xldf/completeDecorSection.xldf @@ -54,7 +54,7 @@ if executed on the same grammar, would produce a selector-free yet structurally equivalent grammar. We used such a generator called strips in the FL case study as the final stage to converge - the abstract syntax (with selectors) with the concrte syntax (with + the abstract syntax (with selectors) with the concrete syntax (with terminals). diff --git a/topics/languedoc/xbgf/xldf/completeFoldSection.xldf b/topics/languedoc/xbgf/xldf/completeFoldSection.xldf index fdad47dd..03bc0e4c 100644 --- a/topics/languedoc/xbgf/xldf/completeFoldSection.xldf +++ b/topics/languedoc/xbgf/xldf/completeFoldSection.xldf @@ -6,42 +6,6 @@ xmlns:xldf="http://planet-sl.org/xldf"> - - element-fold - - - fold - - - - - - - nonterminal - - nonterminal - - - - - - - - - - in - - scope - - - - - - - - - - element-unfold @@ -93,9 +57,9 @@ - The definition that is being unfolded is assumed to be horisontal - (see the section on refactorings for more information about horisontal - and vertical definitions). + The definition that is being unfolded is assumed to be horisontal, + i.e. to consist of one single production. See the section on refactorings + for more information about horisontal and vertical definitions. @@ -148,6 +112,44 @@ ../../transformation/xbgf/tests/unfold.baseline + + + element-fold + + + fold + + + + + + + nonterminal + + nonterminal + + + + + + + + + + in + + scope + + + + + + + + + + +
element-fold
group-folding-transformation @@ -195,7 +197,7 @@ The inline transformation is by far the - most used in Java Language Specification case. One of the reasons + most used in Java Language Specification case study. One of the reasons is what we call layering: in particular expressions and statements are introduced in the $G_j^R$ with a set of related nonterminals: LabeledStatement, IfThenElseStatement, WhileStatement, ForStatement, etc, and @@ -369,7 +371,9 @@ In the same way it was removed in the previous example, - the bracketing production can be added to the grammar: + the bracketing production can be added to the grammar. + The transformation that reverts the impact of the previous + abridge, looks like this: @@ -446,7 +450,9 @@ In the same way it was removed in the previous example, - the chain production can be added to the grammar: + the chain production can be added to the grammar. + The transformation that reverts the impact of the previous + unchain, looks like this: diff --git a/topics/languedoc/xbgf/xldf/completeIntro.xldf b/topics/languedoc/xbgf/xldf/completeIntro.xldf index e85721d1..8181b820 100644 --- a/topics/languedoc/xbgf/xldf/completeIntro.xldf +++ b/topics/languedoc/xbgf/xldf/completeIntro.xldf @@ -364,6 +364,20 @@ ../../../shared/tools/xbgf2xbnf + +
+ + Full convergence diagram for BNF and BGF. The top nodes are sources, the bottom node + is the target, the arc labels are separate XBGF scripts, the nodes contain + numbers of name mismatches and structural mismatches between each step and + the synch point (marked as a double circle). + + PDF + bnfbgf.pdf +
+ compatibility-section +
+ compatibility-section @@ -386,20 +400,6 @@ ../../../shared/tools/xbgf2xbnf - -
- - Full convergence diagram for BNF and BGF. The top nodes are sources, the bottom node - is the target, the arc labels are separate XBGF scripts, the nodes contain - numbers of name mismatches and structural mismatches between each step and - the synch point (marked as a double circle). - - PDF - architecture_large.pdf -
- compatibility-section -
- compatibility-section @@ -476,4 +476,4 @@ x^\star --> - \ No newline at end of file + diff --git a/topics/languedoc/xbgf/xldf/completeRefSection.xldf b/topics/languedoc/xbgf/xldf/completeRefSection.xldf index 3c930f5a..672119fb 100644 --- a/topics/languedoc/xbgf/xldf/completeRefSection.xldf +++ b/topics/languedoc/xbgf/xldf/completeRefSection.xldf @@ -321,6 +321,7 @@ (x? y?)? = x? y? (x^\star y?)? = x^\star y? (x? y^\star)? = x? y^\star + (x^\star y^\star)? = x^\star y^\star (x | y)? = x? | y? are not explicitly covered by massage since it is @@ -528,7 +529,8 @@ element-deyaccify - In either case, it is checked if bar and wez are the same. If they are, the result is more concise: + In either case, it is checked if bar and wez are the same nonterminal. + If they are, the result is more concise: @@ -541,7 +543,82 @@
element-yaccify
group-refactoring-transformation
- + + + + + Yaccification is a typical example of grammar adaptation activity. + However, it can be utilised in grammar convergence process as well: + think of a situation when one of the sources is yaccified using left + recursion while the other one---using right recursion. In such a case + it would be better to deyaccify both of them. If this is due to some + considerations impossible or undesirable, one can deyaccify, say, + left recursion and then yaccify if back to right recursion. + + + Since it is not possible for the transformation engine to guess which + kind of BNF recursion the suite user would need, yaccify + takes two productions as parameters, unlike deyaccify + which works perfectly just given the nonterminal name. + + + + element-yaccify + + + + + For example, this piece of grammar: + + + element-yaccify + + + yaccify-example + ../../transformation/xbgf/tests/yaccify_left_plus.bgf + + + yaccify-example + + can either be yaccified with left recursion: + + + + yaccify-example + ../../transformation/xbgf/tests/yaccify_left_plus.xbgf + ../../../shared/tools/xbgf2xbnf + + + yaccify-example + + to look like this: + + + + yaccify-example + ../../transformation/xbgf/tests/yaccify_left_plus.baseline + + + yaccify-example + + or yaccified with right recursion: + + + + yaccify-example + ../../transformation/xbgf/tests/yaccify_right_plus.xbgf + ../../../shared/tools/xbgf2xbnf + + + yaccify-example + + to look like this: + + + + yaccify-example + ../../transformation/xbgf/tests/yaccify_right_plus.baseline +
element-eliminate
group-refactoring-transformation diff --git a/topics/transformation/xbgf/tests/yaccify1.xbgf b/topics/transformation/xbgf/tests/yaccify1.xbgf deleted file mode 100644 index f14ea6a7..00000000 --- a/topics/transformation/xbgf/tests/yaccify1.xbgf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - N - - - - - - N - - - - N - - - a - - - - - - diff --git a/topics/transformation/xbgf/tests/yaccify2.xbgf b/topics/transformation/xbgf/tests/yaccify2.xbgf deleted file mode 100644 index e20cc5c2..00000000 --- a/topics/transformation/xbgf/tests/yaccify2.xbgf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - N - - a - - - - N - - - - a - - - N - - - - - - diff --git a/topics/transformation/xbgf/tests/yaccify3.xbgf b/topics/transformation/xbgf/tests/yaccify3.xbgf deleted file mode 100644 index a475385f..00000000 --- a/topics/transformation/xbgf/tests/yaccify3.xbgf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - N - - a - - - - N - - - - N - - - a - - - - - - diff --git a/topics/transformation/xbgf/tests/yaccify4.xbgf b/topics/transformation/xbgf/tests/yaccify4.xbgf deleted file mode 100644 index c795431b..00000000 --- a/topics/transformation/xbgf/tests/yaccify4.xbgf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - N - - a - - - - N - - - - b - - - N - - - - - - diff --git a/topics/transformation/xbgf/tests/yaccify5.xbgf b/topics/transformation/xbgf/tests/yaccify5.xbgf deleted file mode 100644 index 6e98e71f..00000000 --- a/topics/transformation/xbgf/tests/yaccify5.xbgf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - N - - a - - - - N - - - - N - - - b - - - - - - diff --git a/topics/transformation/xbgf/tests/yaccify1.baseline b/topics/transformation/xbgf/tests/yaccify_eps.baseline similarity index 70% rename from topics/transformation/xbgf/tests/yaccify1.baseline rename to topics/transformation/xbgf/tests/yaccify_eps.baseline index d0c3a2b7..aa9c7b6d 100644 --- a/topics/transformation/xbgf/tests/yaccify1.baseline +++ b/topics/transformation/xbgf/tests/yaccify_eps.baseline @@ -1,22 +1,22 @@ - N + foo - N + foo - N + foo - a + bar - \ No newline at end of file + diff --git a/topics/transformation/xbgf/tests/yaccify1.bgf b/topics/transformation/xbgf/tests/yaccify_eps.bgf similarity index 73% rename from topics/transformation/xbgf/tests/yaccify1.bgf rename to topics/transformation/xbgf/tests/yaccify_eps.bgf index 82232600..a91619ae 100644 --- a/topics/transformation/xbgf/tests/yaccify1.bgf +++ b/topics/transformation/xbgf/tests/yaccify_eps.bgf @@ -1,11 +1,11 @@ - N + foo - a + bar diff --git a/topics/transformation/xbgf/tests/yaccify_eps.xbgf b/topics/transformation/xbgf/tests/yaccify_eps.xbgf new file mode 100644 index 00000000..e42770ba --- /dev/null +++ b/topics/transformation/xbgf/tests/yaccify_eps.xbgf @@ -0,0 +1,26 @@ + + + + + foo + + + + + + foo + + + + foo + + + bar + + + + + + diff --git a/topics/transformation/xbgf/tests/yaccify5.baseline b/topics/transformation/xbgf/tests/yaccify_left.baseline similarity index 65% rename from topics/transformation/xbgf/tests/yaccify5.baseline rename to topics/transformation/xbgf/tests/yaccify_left.baseline index ffb2a085..21b3867d 100644 --- a/topics/transformation/xbgf/tests/yaccify5.baseline +++ b/topics/transformation/xbgf/tests/yaccify_left.baseline @@ -1,20 +1,20 @@ - N + foo - a + bar - N + foo - N + foo - b + wez diff --git a/topics/transformation/xbgf/tests/yaccify4.bgf b/topics/transformation/xbgf/tests/yaccify_left.bgf similarity index 74% rename from topics/transformation/xbgf/tests/yaccify4.bgf rename to topics/transformation/xbgf/tests/yaccify_left.bgf index cce9f227..1f6b4052 100644 --- a/topics/transformation/xbgf/tests/yaccify4.bgf +++ b/topics/transformation/xbgf/tests/yaccify_left.bgf @@ -1,19 +1,19 @@ - N + foo + + bar + - b + wez - - a - diff --git a/topics/transformation/xbgf/tests/yaccify_left.xbgf b/topics/transformation/xbgf/tests/yaccify_left.xbgf new file mode 100644 index 00000000..2a9b0543 --- /dev/null +++ b/topics/transformation/xbgf/tests/yaccify_left.xbgf @@ -0,0 +1,26 @@ + + + + + foo + + bar + + + + foo + + + + foo + + + wez + + + + + + diff --git a/topics/transformation/xbgf/tests/yaccify3.baseline b/topics/transformation/xbgf/tests/yaccify_left_plus.baseline similarity index 65% rename from topics/transformation/xbgf/tests/yaccify3.baseline rename to topics/transformation/xbgf/tests/yaccify_left_plus.baseline index cafe9f3b..043cf275 100644 --- a/topics/transformation/xbgf/tests/yaccify3.baseline +++ b/topics/transformation/xbgf/tests/yaccify_left_plus.baseline @@ -1,20 +1,20 @@ - N + foo - a + bar - N + foo - N + foo - a + bar diff --git a/topics/transformation/xbgf/tests/yaccify3.bgf b/topics/transformation/xbgf/tests/yaccify_left_plus.bgf similarity index 73% rename from topics/transformation/xbgf/tests/yaccify3.bgf rename to topics/transformation/xbgf/tests/yaccify_left_plus.bgf index ff98b237..2c23000c 100644 --- a/topics/transformation/xbgf/tests/yaccify3.bgf +++ b/topics/transformation/xbgf/tests/yaccify_left_plus.bgf @@ -1,11 +1,11 @@ - N + foo - a + bar diff --git a/topics/transformation/xbgf/tests/yaccify_left_plus.xbgf b/topics/transformation/xbgf/tests/yaccify_left_plus.xbgf new file mode 100644 index 00000000..db36b77e --- /dev/null +++ b/topics/transformation/xbgf/tests/yaccify_left_plus.xbgf @@ -0,0 +1,26 @@ + + + + + foo + + bar + + + + foo + + + + foo + + + bar + + + + + + diff --git a/topics/transformation/xbgf/tests/yaccify4.baseline b/topics/transformation/xbgf/tests/yaccify_right.baseline similarity index 65% rename from topics/transformation/xbgf/tests/yaccify4.baseline rename to topics/transformation/xbgf/tests/yaccify_right.baseline index 72946154..801dbf8c 100644 --- a/topics/transformation/xbgf/tests/yaccify4.baseline +++ b/topics/transformation/xbgf/tests/yaccify_right.baseline @@ -1,20 +1,20 @@ - N + foo - a + bar - N + foo - b + wez - N + foo diff --git a/topics/transformation/xbgf/tests/yaccify5.bgf b/topics/transformation/xbgf/tests/yaccify_right.bgf similarity index 74% rename from topics/transformation/xbgf/tests/yaccify5.bgf rename to topics/transformation/xbgf/tests/yaccify_right.bgf index f17ba873..bf7d1c78 100644 --- a/topics/transformation/xbgf/tests/yaccify5.bgf +++ b/topics/transformation/xbgf/tests/yaccify_right.bgf @@ -1,19 +1,19 @@ - N + foo - - a - - b + wez + + bar + diff --git a/topics/transformation/xbgf/tests/yaccify_right.xbgf b/topics/transformation/xbgf/tests/yaccify_right.xbgf new file mode 100644 index 00000000..03ca8180 --- /dev/null +++ b/topics/transformation/xbgf/tests/yaccify_right.xbgf @@ -0,0 +1,26 @@ + + + + + foo + + bar + + + + foo + + + + wez + + + foo + + + + + + diff --git a/topics/transformation/xbgf/tests/yaccify2.baseline b/topics/transformation/xbgf/tests/yaccify_right_plus.baseline similarity index 65% rename from topics/transformation/xbgf/tests/yaccify2.baseline rename to topics/transformation/xbgf/tests/yaccify_right_plus.baseline index c4457348..b5df4fb4 100644 --- a/topics/transformation/xbgf/tests/yaccify2.baseline +++ b/topics/transformation/xbgf/tests/yaccify_right_plus.baseline @@ -1,20 +1,20 @@ - N + foo - a + bar - N + foo - a + bar - N + foo diff --git a/topics/transformation/xbgf/tests/yaccify2.bgf b/topics/transformation/xbgf/tests/yaccify_right_plus.bgf similarity index 71% rename from topics/transformation/xbgf/tests/yaccify2.bgf rename to topics/transformation/xbgf/tests/yaccify_right_plus.bgf index ac1cd258..03c57629 100644 --- a/topics/transformation/xbgf/tests/yaccify2.bgf +++ b/topics/transformation/xbgf/tests/yaccify_right_plus.bgf @@ -1,11 +1,11 @@ - + - N + foo - a + bar diff --git a/topics/transformation/xbgf/tests/yaccify_right_plus.xbgf b/topics/transformation/xbgf/tests/yaccify_right_plus.xbgf new file mode 100644 index 00000000..63ac14ef --- /dev/null +++ b/topics/transformation/xbgf/tests/yaccify_right_plus.xbgf @@ -0,0 +1,26 @@ + + + + + foo + + bar + + + + foo + + + + bar + + + foo + + + + + + diff --git a/topics/transformation/xldf/xldf.py b/topics/transformation/xldf/xldf.py index af0368b8..54f29737 100755 --- a/topics/transformation/xldf/xldf.py +++ b/topics/transformation/xldf/xldf.py @@ -258,6 +258,22 @@ def xldf_add_subsection(cmd,tree): print '[----] add-subsection failed, double check or try add-section instead' return +def xldf_add_figure(cmd,tree): + success = False + s = cmd.findall('*')[0] + found = findnode(tree,cmd.findtext('to')) + if found: + if found[-1].tag=='content': + found[-1].append(s) + print '[XLDF] add-figure to id',cmd.findtext('to') + success = True + else: + print '[----] add-figure failed, can''t find id',cmd.findtext('to') + return + if not success: + print '[----] add-figure failed, double check or try add-section instead' + return + def xldf_transform_grammar(cmd,tree): root = ET.Element('{'+xbgfns+'}sequence',{}) cx0 = 0 @@ -395,6 +411,8 @@ def xldf_perform_command(cmd,ltree): xldf_add_section(cmd,ltree) elif cmdname == 'add-subsection': xldf_add_subsection(cmd,ltree) + elif cmdname == 'add-figure': + xldf_add_figure(cmd,ltree) elif cmdname == 'transform-document': xldf_transform_document(cmd,ltree) else: