diff --git a/shared/prolog/cli/dcg2bgf.pro b/shared/prolog/cli/dcg2bgf.pro
index e7ad2f58..b79b1773 100644
--- a/shared/prolog/cli/dcg2bgf.pro
+++ b/shared/prolog/cli/dcg2bgf.pro
@@ -29,6 +29,12 @@ rhsToX([],true).
rhsToX({_},true).
+rhsToX([0' ],t(' ')).
+
+rhsToX([0' ],t('\t')).
+
+rhsToX([10],n('NEWLINE')).
+
rhsToX(R,X)
:-
R = (_,_),
@@ -45,7 +51,7 @@ rhsToX(R1,X)
rhsToX(R,t(Y))
:-
R =.. [F,X],
- member(F,[reserved,@]),
+ member(F,[reserved,keyword,@]),
name(Y,X).
rhsToX(R1,','([Y,*(','([X,Y]))]))
diff --git a/topics/extraction/dcg/Makefile b/topics/extraction/dcg/Makefile
new file mode 100644
index 00000000..9cfe8b50
--- /dev/null
+++ b/topics/extraction/dcg/Makefile
@@ -0,0 +1,7 @@
+build:
+
+test:
+ cat tests/set | xargs -n1 ./testperform
+
+clean:
+ rm -f *.bgf *~
\ No newline at end of file
diff --git a/topics/extraction/dcg/testperform b/topics/extraction/dcg/testperform
new file mode 100755
index 00000000..4681ad78
--- /dev/null
+++ b/topics/extraction/dcg/testperform
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+echo [Test Case] $1
+../../../shared/tools/dcg2bgf $1 extracted.bgf
+../../../shared/tools/validate bgf extracted.bgf
+../../../shared/tools/gdt extracted.bgf tests/`echo $1 | tr -d ./`.baseline || exit -1
\ No newline at end of file
diff --git a/topics/extraction/dcg/tests/exerciseswhile3Parserpro.baseline b/topics/extraction/dcg/tests/exerciseswhile3Parserpro.baseline
new file mode 100644
index 00000000..4780a1fd
--- /dev/null
+++ b/topics/extraction/dcg/tests/exerciseswhile3Parserpro.baseline
@@ -0,0 +1,398 @@
+
+
+
+ program
+
+ statements
+
+
+
+
+ statements
+
+
+
+ statement
+
+
+ ;
+
+
+ statements
+
+
+
+
+
+ statements
+
+ statement
+
+
+
+
+ statement
+
+ skip
+
+
+
+
+ statement
+
+
+
+ identifier
+
+
+ :=
+
+
+ aexpression
+
+
+
+
+
+
+ statement
+
+
+
+ if
+
+
+ bexpression
+
+
+ then
+
+
+ statement
+
+
+ else
+
+
+ statement
+
+
+
+
+
+
+ statement
+
+
+
+ while
+
+
+ bexpression
+
+
+ do
+
+
+ statement
+
+
+
+
+
+
+ aexpression
+
+ number
+
+
+
+
+ aexpression
+
+ identifier
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ +
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ -
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ *
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ bexpression
+
+ true
+
+
+
+
+ bexpression
+
+ false
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ =
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ ≤
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ ¬
+
+
+ bexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ (
+
+
+ bexpression
+
+
+ ^
+
+
+ bexpression
+
+
+ )
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+ NEWLINE
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+ keyword
+
+
+
+ layout
+
+
+ string
+
+
+
+
+
+ number
+
+
+
+ layout
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+
+
+ identifier
+
+
+
+ layout
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+
+
diff --git a/topics/extraction/dcg/tests/exerciseswhile4Parserpro.baseline b/topics/extraction/dcg/tests/exerciseswhile4Parserpro.baseline
new file mode 100644
index 00000000..4780a1fd
--- /dev/null
+++ b/topics/extraction/dcg/tests/exerciseswhile4Parserpro.baseline
@@ -0,0 +1,398 @@
+
+
+
+ program
+
+ statements
+
+
+
+
+ statements
+
+
+
+ statement
+
+
+ ;
+
+
+ statements
+
+
+
+
+
+ statements
+
+ statement
+
+
+
+
+ statement
+
+ skip
+
+
+
+
+ statement
+
+
+
+ identifier
+
+
+ :=
+
+
+ aexpression
+
+
+
+
+
+
+ statement
+
+
+
+ if
+
+
+ bexpression
+
+
+ then
+
+
+ statement
+
+
+ else
+
+
+ statement
+
+
+
+
+
+
+ statement
+
+
+
+ while
+
+
+ bexpression
+
+
+ do
+
+
+ statement
+
+
+
+
+
+
+ aexpression
+
+ number
+
+
+
+
+ aexpression
+
+ identifier
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ +
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ -
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ *
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ bexpression
+
+ true
+
+
+
+
+ bexpression
+
+ false
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ =
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ ≤
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ ¬
+
+
+ bexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ (
+
+
+ bexpression
+
+
+ ^
+
+
+ bexpression
+
+
+ )
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+ NEWLINE
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+ keyword
+
+
+
+ layout
+
+
+ string
+
+
+
+
+
+ number
+
+
+
+ layout
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+
+
+ identifier
+
+
+
+ layout
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+
+
diff --git a/topics/extraction/dcg/tests/exerciseswhile5Parserpro.baseline b/topics/extraction/dcg/tests/exerciseswhile5Parserpro.baseline
new file mode 100644
index 00000000..ae13fcbf
--- /dev/null
+++ b/topics/extraction/dcg/tests/exerciseswhile5Parserpro.baseline
@@ -0,0 +1,412 @@
+
+
+
+ program
+
+ statements
+
+
+
+
+ statements
+
+
+
+ statement
+
+
+ ;
+
+
+ statements
+
+
+
+
+
+ statements
+
+ statement
+
+
+
+
+ statement
+
+
+
+ var
+
+
+ identifier
+
+
+
+
+
+
+ statement
+
+ skip
+
+
+
+
+ statement
+
+
+
+ identifier
+
+
+ :=
+
+
+ aexpression
+
+
+
+
+
+
+ statement
+
+
+
+ if
+
+
+ bexpression
+
+
+ then
+
+
+ statement
+
+
+ else
+
+
+ statement
+
+
+
+
+
+
+ statement
+
+
+
+ while
+
+
+ bexpression
+
+
+ do
+
+
+ statement
+
+
+
+
+
+
+ aexpression
+
+ number
+
+
+
+
+ aexpression
+
+ identifier
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ +
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ -
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ aexpression
+
+
+
+ (
+
+
+ aexpression
+
+
+ *
+
+
+ aexpression
+
+
+ )
+
+
+
+
+
+
+ bexpression
+
+ true
+
+
+
+
+ bexpression
+
+ false
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ =
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ aexpression
+
+
+ ≤
+
+
+ aexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ ¬
+
+
+ bexpression
+
+
+
+
+
+
+ bexpression
+
+
+
+ (
+
+
+ bexpression
+
+
+ ^
+
+
+ bexpression
+
+
+ )
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+ NEWLINE
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+ keyword
+
+
+
+ layout
+
+
+ string
+
+
+
+
+
+ number
+
+
+
+ layout
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+ digit
+
+
+ digits
+
+
+
+
+
+ digits
+
+
+
+
+
+ identifier
+
+
+
+ layout
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+
+
diff --git a/topics/extraction/dcg/tests/exercisesxml1Parserpro.baseline b/topics/extraction/dcg/tests/exercisesxml1Parserpro.baseline
new file mode 100644
index 00000000..aa3b02c5
--- /dev/null
+++ b/topics/extraction/dcg/tests/exercisesxml1Parserpro.baseline
@@ -0,0 +1,108 @@
+
+
+
+
+ tree
+
+
+
+ spaces
+
+
+ string
+
+
+ tag
+
+
+ string
+
+
+ trees
+
+
+ string
+
+
+ tag
+
+
+ string
+
+
+ spaces
+
+
+
+
+
+ trees
+
+
+
+ tree
+
+
+ trees
+
+
+
+
+
+ trees
+
+
+
+
+
+ spaces
+
+
+
+
+
+
+ spaces
+
+
+
+
+
+ spaces
+
+
+
+
+
+ tag
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+
+
diff --git a/topics/extraction/dcg/tests/exercisesxml2Parserpro.baseline b/topics/extraction/dcg/tests/exercisesxml2Parserpro.baseline
new file mode 100644
index 00000000..d66b1f9c
--- /dev/null
+++ b/topics/extraction/dcg/tests/exercisesxml2Parserpro.baseline
@@ -0,0 +1,191 @@
+
+
+
+
+ tree
+
+
+
+ layout
+
+
+ string
+
+
+ name
+
+
+ attrs
+
+
+ string
+
+
+ trees
+
+
+ string
+
+
+ name
+
+
+ string
+
+
+ layout
+
+
+
+
+
+ trees
+
+
+
+ tree
+
+
+ trees
+
+
+
+
+
+ trees
+
+
+
+
+
+ attrs
+
+
+
+ layout
+
+
+ attr
+
+
+ attrs
+
+
+
+
+
+ attrs
+
+
+
+
+
+ attr
+
+
+
+ name
+
+
+ string
+
+
+ value
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+ NEWLINE
+
+
+ layout
+
+
+
+
+
+ layout
+
+
+
+
+
+ name
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+ letter
+
+
+ letters
+
+
+
+
+
+ letters
+
+
+
+
+
+ value
+
+
+
+ string
+
+
+ string
+
+
+ string
+
+
+
+
+
diff --git a/topics/extraction/dcg/tests/flprolog1Parserpro.baseline b/topics/extraction/dcg/tests/flprolog1Parserpro.baseline
new file mode 100644
index 00000000..92801b41
--- /dev/null
+++ b/topics/extraction/dcg/tests/flprolog1Parserpro.baseline
@@ -0,0 +1,163 @@
+
+
+
+ program
+
+
+
+ function
+
+
+
+
+
+ function
+
+
+
+ name
+
+
+
+
+ name
+
+
+
+
+ =
+
+
+ expr
+
+
+
+
+ newline
+
+
+
+
+
+
+
+
+ expr
+
+
+
+ atom
+
+
+
+
+
+
+ ops
+
+
+ atom
+
+
+
+
+
+
+
+
+
+
+ expr
+
+
+
+ name
+
+
+
+
+ atom
+
+
+
+
+
+
+
+
+ expr
+
+
+
+ if
+
+
+ expr
+
+
+ then
+
+
+ expr
+
+
+ else
+
+
+ expr
+
+
+
+
+
+
+ atom
+
+ int
+
+
+
+
+ atom
+
+ name
+
+
+
+ atom
+
+
+
+ (
+
+
+ expr
+
+
+ )
+
+
+
+
+
+
+ ops
+
+ ==
+
+
+
+
+ ops
+
+ +
+
+
+
+
+ ops
+
+ -
+
+
+
diff --git a/topics/extraction/dcg/tests/set b/topics/extraction/dcg/tests/set
new file mode 100644
index 00000000..c4fb09da
--- /dev/null
+++ b/topics/extraction/dcg/tests/set
@@ -0,0 +1,6 @@
+../../fl/prolog1/Parser.pro
+../../exercises/while3/Parser.pro
+../../exercises/while4/Parser.pro
+../../exercises/while5/Parser.pro
+../../exercises/xml1/Parser.pro
+../../exercises/xml2/Parser.pro
\ No newline at end of file
diff --git a/topics/extraction/dcg2bgf/Makefile b/topics/extraction/dcg2bgf/Makefile
deleted file mode 100644
index 60a20763..00000000
--- a/topics/extraction/dcg2bgf/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-source = ../../fl/prolog1/Parser.pro
-target = tests/fl
-
-build:
-
-test:
- make clean-tests
- ../../../shared/tools/dcg2bgf ${source} ${target}.bgf
- ../../../shared/tools/validate bgf ${target}.bgf
- ../../../shared/tools/showbgf ${target}.bgf > ${target}.out
- diff ${target}.out ${target}.baseline
-
-clean:
- make clean-tests
- rm -f *~
-
-clean-tests:
- rm -f tests/*.bgf
- rm -f tests/*.out
diff --git a/topics/extraction/dcg2bgf/tests/fl.baseline b/topics/extraction/dcg2bgf/tests/fl.baseline
deleted file mode 100644
index 749f894f..00000000
--- a/topics/extraction/dcg2bgf/tests/fl.baseline
+++ /dev/null
@@ -1,14 +0,0 @@
-Loading XML file 'tests/fl.bgf'.
-g( [], [
- p([], program, +n(function)),
- p([], function, ','([n(name), +n(name), t(=), n(expr), +n(newline)])),
- p([l(binary)], expr, ','([n(atom), *(','([n(ops), n(atom)]))])),
- p([l(apply)], expr, ','([n(name), +n(atom)])),
- p([l(ifThenElse)], expr, ','([t(if), n(expr), t(then), n(expr), t(else), n(expr)])),
- p([l(literal)], atom, n(int)),
- p([l(argument)], atom, n(name)),
- p([], atom, ','([t('('), n(expr), t(')')])),
- p([l(equal)], ops, t(==)),
- p([l(plus)], ops, t(+)),
- p([l(minus)], ops, t(-))
-])