diff --git a/shared/tools/ldf2bgf b/shared/tools/ldf2bgf new file mode 100755 index 00000000..c612b790 --- /dev/null +++ b/shared/tools/ldf2bgf @@ -0,0 +1,20 @@ +#! /bin/sh + +# Get our hands on the languedoc basedir +LOCAL=${PWD} +cd `dirname $0` +cd ../.. +SLPS=${PWD} +cd ${LOCAL} + +if [ $# -ne 2 ]; then + echo "This tool transforms Language Document Format to BNF-like Grammar Format" + echo "Usage: ldf2bgf " + exit 1 +elif [ ! -r $1 ]; then + echo "Oops: $1 not found or not readable." + exit 1 +else + rm -f $2 + xsltproc ${SLPS}/shared/xsl/ldf2bgf.xslt $1 > $2 +fi diff --git a/shared/tools/ldf2html b/shared/tools/ldf2html new file mode 100755 index 00000000..951e0775 --- /dev/null +++ b/shared/tools/ldf2html @@ -0,0 +1,19 @@ +#!/bin/sh + +LOCAL=${PWD} +cd `dirname $0` +cd ../.. +SLPS=${PWD} +cd ${LOCAL} + +if [ $# -ne 2 ]; then + echo "This tool transforms Language Document Format to HyperText Markup Language" + echo "Usage: ldf2html " + exit 1 +elif [ ! -r $1 ]; then + echo "Oops: $1 not found or not readable." + exit 1 +else + rm -f $2 + xsltproc ${SLPS}/shared/xsl/ldf2xhtml.xslt $1 | python ${SLPS}/topics/extraction/ldf2pdf/closemeta.py > $2 +fi diff --git a/shared/tools/ldf2pdf b/shared/tools/ldf2pdf new file mode 100755 index 00000000..f92d34eb --- /dev/null +++ b/shared/tools/ldf2pdf @@ -0,0 +1,23 @@ +#!/bin/sh + +LOCAL=${PWD} +cd `dirname $0` +cd ../.. +SLPS=${PWD} +cd ${LOCAL} + +if [ $# -ne 2 ]; then + echo "This tool transforms Language Document Format to Portable Document Format" + echo "Usage: ldf2pdf " + exit 1 +elif [ ! -r $1 ]; then + echo "Oops: $1 not found or not readable." + exit 1 +else + rm -f $2 + sh ${SLPS}/shared/tools/ldf2html $1 html.tmp + xsltproc ${SLPS}/shared/xsl/xhtml2fo.xslt html.tmp > fo.tmp + ${SLPS}/download/fop/fop -q fo.tmp $2 + rm -f html.tmp fo.tmp +fi + diff --git a/shared/xsl/ldf2bgf.xslt b/shared/xsl/ldf2bgf.xslt new file mode 100644 index 00000000..48031acb --- /dev/null +++ b/shared/xsl/ldf2bgf.xslt @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/shared/xsl/ldf2xhtml.xslt b/shared/xsl/ldf2xhtml.xslt new file mode 100644 index 00000000..1e87ca86 --- /dev/null +++ b/shared/xsl/ldf2xhtml.xslt @@ -0,0 +1,273 @@ + + + + + + + + + + + + <xsl:value-of select="/ldf:document/title"/> - generated by LGF2XHTML + + + + +

+ +

+

+ (c) + +

+

Abstract

+

+ +

+ +
+ + + + +
+ + + +

+ + + + + + + + + + +

+ +
+ + +
+

+ + + + + + Grammar productions + + (ver. ) + + + +

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + +
+

+ + + + + + Source code sample + + (ver. ) + + + +

+
+
+        
+      
+
+
+ + + +
+

+ + + + + + Sample execution + + (ver. ) + + + +

+
+ + + + # + + + + + + +
+

+ + (Should return ) + +

+
+
+ + + + + + + + +

+ +

+ +
+ + + + + + + + + + + + + + ::= + +
+
+
+ + + + + + + + * + + + + ? + + + + "" + + + + + # + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ | +
+ + + + + + + + # + + + + + + + +
diff --git a/shared/xsl/xhtml2fo.xslt b/shared/xsl/xhtml2fo.xslt new file mode 100644 index 00000000..a319f934 --- /dev/null +++ b/shared/xsl/xhtml2fo.xslt @@ -0,0 +1,1705 @@ + + + + + + + + + + + auto + auto + 1in + 1in + 1in + 1in + + + 0.5in + 0.5in + true + true + + + 1 + 12pt + + + lr-tb + + + start + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + small + center + + + + + small + center + + + + + + 2em + bold + 0.67em + 0.67em + always + always + + + + 1.5em + bold + 0.83em + 0.83em + always + always + + + + 1.17em + bold + 1em + 1em + always + always + + + + 1em + bold + 1.17em + 1.17em + always + always + + + + 0.83em + bold + 1.33em + 1.33em + always + always + + + + 0.67em + bold + 1.67em + 1.67em + always + always + + + + 1em + 1em + + + + + + + + + + + + + + inherited-property-value(start-indent) + 24pt + inherited-property-value(end-indent) + 24pt + 1em + 1em + + + + 0.83em + monospace + pre + 1em + 1em + + + + italic + + + + 1px inset + 0.67em + 0.67em + + + + + + 1em + 1em + + + + 0pt + 0pt + + + + 1em + 1em + + + + 0pt + 0pt + + + + + baseline + + + + + baseline + + + + 1em + 1em + + + + always + always + + + + inherited-property-value(start-indent) + 24pt + + + + + + + 1em serif + + + o + + 0.67em monospace + 0.25em + + + - + + bold 0.9em sans-serif + 0.05em + + + 1. + + + a. + + + i. + + + + + + + 0pt + 0pt + 0pt + 0pt + start + relative + + + + + + center + + + + separate + 2px + 1px + + + + + center + + + + + + + + + + + + + + + + + + + bolder + center + 1px + + 1px + + + + 1px + + 1px + + + + + + bolder + + + bolder + + + + bolder + italic + + + + italic + + + italic + + + italic + + + italic + + + italic + + + + monospace + + + monospace + + + monospace + + + monospace + + + + larger + + + smaller + + + + sub + smaller + + + super + smaller + + + + line-through + + + line-through + + + line-through + + + + underline + + + underline + + + + + + + + + + + + + + + + + + + + 2px solid + + + + + + underline + blue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + before + + + after + + + center + + + auto + baseline + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rl-tb + lr-tb + + + + + + + + + + + + + + + + + + + + + + true + + + + true + false + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + px + + + + + + + + px + + + + + hidden + + + outset hidden hidden hidden + + + hidden hidden outset hidden + + + outset hidden + + + hidden outset + + + hidden hidden hidden outset + + + hidden outset hidden hidden + + + outset + + + + + + px + separate + + + collapse + + hidden + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1px solid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1px solid + + + + + + + + + + + + + + + + + + + + 1px solid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inset + + + + + + + + + px + + + + + + from-table-column() + + + from-table-column() + from-table-column() + + + + + + + + + + + + + + proportional-column-width( + + ) + + + + + + px + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + center + after + auto + before + + + + baseline + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + url(' + + ') + + + + + + + + + + + + + scale-to-fit + + + + px + + + + + + + + + + scale-to-fit + + + + px + + + + + + px solid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + url(' + + ') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/topics/extraction/ldf2pdf/README.txt b/topics/extraction/ldf2pdf/README.txt new file mode 100644 index 00000000..8df75bd7 --- /dev/null +++ b/topics/extraction/ldf2pdf/README.txt @@ -0,0 +1,2 @@ +This directory should contain any presentation layer bits for LDF: +producing PDFs, HTMLs, MIFs, whatever. diff --git a/topics/extraction/ldf2pdf/closemeta.py b/topics/extraction/ldf2pdf/closemeta.py new file mode 100755 index 00000000..35866c0f --- /dev/null +++ b/topics/extraction/ldf2pdf/closemeta.py @@ -0,0 +1,9 @@ +#!/usr/bin/python +import sys + +for line in sys.stdin: + if (line.find('',''), + diff --git a/topics/fl/ldf/Makefile b/topics/fl/ldf/Makefile new file mode 100644 index 00000000..9f65a1ac --- /dev/null +++ b/topics/fl/ldf/Makefile @@ -0,0 +1,7 @@ +all: + java -jar ../../../download/msv/msv.jar ../../../shared/xsd/ldf.xsd fl.ldf + ../../../shared/tools/ldf2bgf fl.ldf fl.bgf + +clean: + rm -f fl.bgf + diff --git a/topics/fl/ldf/fl.ldf b/topics/fl/ldf/fl.ldf new file mode 100644 index 00000000..fd77dbc8 --- /dev/null +++ b/topics/fl/ldf/fl.ldf @@ -0,0 +1,134 @@ + + The Factorial Language + The Software Languages Team in Koblenz + + The Factorial Language (FL) is a trivial functional language; + it's a toy language made up as an illustrative language for language processing. + It's carefully designed to be trivial + but still involved enough to trigger a lot of issues in language processing + (including issues of parsing, semantics, type checking, transformation). + This document provides a documentation of the FL language. + + +
+ A quick start + + + Here is sample that hopefully explains the name of the language. + That is, FL is capable of expressing the factorial function. + We need a helper function for multiplication because FL provides addition but not multiplication. + + + mult n m = if (n==0) then 0 else (m + (mult (n - 1) m)) + fac n = if (n==0) then 1 else (mult n (fac (n - 1))) + + + Functions are called by placing their arguments after their names: + + + main_library +
mult
+ 5 + 7 + 35 +
+ + main_library +
fac
+ 5 + 120 +
+
+
+
+ FL programs + + + As illustrated above, FL programs are lists of function definitions. + Each function definition has 1 or more integer-typed arguments. + The following grammar fragment shows this formally. + + + + program + + + + function + + + + + + + Function definitions are separated by one or more eoln markers. + More details are explained in the next section. + + +
+
+ FL functions + + + Function defintions are separated by newlines. + + + + function + + + + name + + + + + name + + + + + = + + + = + + + expr + + + + + eoln + + + + + + + + + Each function definition consists of + a name of the function, + its arguments (again, names), + and a right-hand side expression. + + + +
+
+ FL expression forms + + + An expression is understood intuitively by everyone: + + + (1 + 2) - 3 + + +
+
+