diff --git a/topics/extraction/sdf2bgf/Main.asf b/topics/extraction/sdf2bgf/Main.asf
index e2a8ea4d..a25a4e01 100644
--- a/topics/extraction/sdf2bgf/Main.asf
+++ b/topics/extraction/sdf2bgf/Main.asf
@@ -37,6 +37,25 @@ trafoSymbols() =
+[transform-a-labelled-production]
+&C1 := sort2chardata(&N1),
+&E2 := trafoSymbols(&Ss1),
+&C0 := guessLabel(&Acs1)
+=====================
+trafoProd ( &Ss1 -> &N1 {&Acs1} ) =
+
+ &C0
+ &C1
+ &E2
+
+
+[transform-empty-definition-of-nonterminal]
+trafoSymbols() =
+
+
+
+
+
[transform-definition-that-is-not-a-sequence]
trafoSymbols(&S1) = trafoSymbol(&S1)
@@ -99,3 +118,18 @@ trafoSymbol(&S1?) =
&E1
+
+[cons-to-label-only-cons]
+guessLabel(cons(&I1)) =
+
+[cons-to-label-cons-etc]
+guessLabel(cons(&I1),&Acs2) =
+
+[cons-to-label-empty]
+guessLabel() =
+
+[default-cons-to-label-no-cons]
+guessLabel(&A1) =
+
+[default-cons-to-label-head-is-not-cons]
+guessLabel(&A1,&Acs2) = guessLabel(&Acs2)
diff --git a/topics/extraction/sdf2bgf/Main.sdf b/topics/extraction/sdf2bgf/Main.sdf
index 0c4265dd..92fb5f03 100644
--- a/topics/extraction/sdf2bgf/Main.sdf
+++ b/topics/extraction/sdf2bgf/Main.sdf
@@ -26,22 +26,25 @@ module Main
trafoSymbol(Symbol) -> Element
trafoSymbols(Symbols) -> Element
mapTrafoSymbol(Symbols) -> Content*
+ guessLabel({Attribute ","}*) -> Content?
variables
- "&A" [0-9]+ -> Attribute
+ "&A" [0-9]+ -> Attribute
"&A*" [0-9]+ -> Attribute*
"&As" [0-9]+ -> Attributes
- "&C" [0-9]+ -> Content
+ "&Acs"[0-9]+ -> {Attribute ","}*
+ "&C" [0-9]+ -> Content
"&C*" [0-9]+ -> Content*
- "&E" [0-9]+ -> Element
- %% "&E*" [0-9]+ -> Element* %% Useless because of lack of covariance
- "&G" [0-9]+ -> Grammar
- "&M" [0-9]+ -> Module
- "&N" [0-9]+ -> Sort
- "&P" [0-9]+ -> Production
+ "&E" [0-9]+ -> Element
+%% "&E*" [0-9]+ -> Element* %% Useless because of lack of covariance
+ "&G" [0-9]+ -> Grammar
+ "&M" [0-9]+ -> Module
+ "&N" [0-9]+ -> Sort
+ "&P" [0-9]+ -> Production
"&P*" [0-9]+ -> Production*
"&Ps" [0-9]+ -> Productions
- "&S" [0-9]+ -> Symbol
+ "&S" [0-9]+ -> Symbol
"&S*" [0-9]+ -> Symbol*
"&Ss" [0-9]+ -> Symbols
- "&Z" [0-9]+ -> StrCon
+ "&Z" [0-9]+ -> StrCon
+ "&I" [0-9]+ -> IdCon
diff --git a/topics/extraction/sdf2bgf/Tokens.asf b/topics/extraction/sdf2bgf/Tokens.asf
index a0d5026a..0f25a782 100644
--- a/topics/extraction/sdf2bgf/Tokens.asf
+++ b/topics/extraction/sdf2bgf/Tokens.asf
@@ -21,3 +21,14 @@ strchar(&Chr1) := &StrChar1,
chardata(&Char1 &Chars1) := strcon2chardata(strcon(\" &StrChar+2 \"))
===========================================================
strcon2chardata(strcon(\" &StrChar1 &StrChar+2 \")) = chardata(&Chr1 &Char1 &Chars1)
+
+[idcon-of-length-1]
+idcon2chardata(idcon(&IdHead1)) = chardata(&IdHead1)
+
+[idcon-of-length-2]
+idcon2chardata(idcon(&IdHead1 &Middle1)) = chardata(&IdHead1 &Middle1)
+
+[idcon-of-length-greater-than-2]
+chardata(&Char1 &Chars1) := idcon2chardata(idcon(&IdHead1 &Middles1))
+===============================================================
+idcon2chardata(idcon(&IdHead1 &Middle1 &Middles1)) = chardata(&Char1 &Middle1 &Chars1)
diff --git a/topics/extraction/sdf2bgf/Tokens.sdf b/topics/extraction/sdf2bgf/Tokens.sdf
index be43d91e..009f8bf3 100644
--- a/topics/extraction/sdf2bgf/Tokens.sdf
+++ b/topics/extraction/sdf2bgf/Tokens.sdf
@@ -4,18 +4,18 @@ imports
languages/sdf2/syntax/Sorts
languages/xml/syntax/XML
basic/StrCon
+ basic/IdentifierCon
exports
-
- sorts CharData
-
- context-free syntax
- sort2chardata(Sort) -> CharData
- strcon2chardata(StrCon) -> CharData
+ sorts
+ CharData
+ context-free syntax
+ sort2chardata(Sort) -> CharData
+ strcon2chardata(StrCon) -> CharData
+ idcon2chardata(IdCon) -> CharData
hiddens
-
- lexical syntax
+ lexical syntax
%% Let's remind ourselves of the relevant lexical syntax.
%%
%% 1. languages/sdf2/syntax/Sorts
@@ -35,13 +35,14 @@ hiddens
%% ~[\0-\31\n\t\"\\] -> StrChar {cons("normal")}
%% [\"] chars:StrChar* [\"] -> StrCon {cons("default")}
- lexical variables
- "&Head" [0-9]* -> [A-Z] %% Part of Sort
- "&Middle" [0-9]* -> [A-Za-z0-9\-] %% Part of Sort
- "&Middles" [0-9]* -> [A-Za-z0-9\-]* %% Part of Sort
- "&Last" [0-9]* -> [A-Za-z0-9] %% Part of Sort
- "&Char" [0-9]* -> ~[\<\&] %% Part of CharData
- "&Chars" [0-9]* -> ~[\<\&]* %% Part of CharData
- "&StrChar" [0-9]* -> StrChar %% Part of StrCon
- "&StrChar+" [0-9]* -> StrChar+ %% Part of StrCon
- "&Chr" [0-9]* -> ~[\0-\31\n\t\"\\\<\&]
+ lexical variables
+ "&Head" [0-9]* -> [A-Z] %% Part of Sort
+ "&IdHead" [0-9]* -> [A-Za-z] %% Part of IdCon
+ "&Middle" [0-9]* -> [A-Za-z0-9\-] %% Part of Sort
+ "&Middles" [0-9]* -> [A-Za-z0-9\-]* %% Part of Sort
+ "&Last" [0-9]* -> [A-Za-z0-9] %% Part of Sort
+ "&Char" [0-9]* -> ~[\<\&] %% Part of CharData
+ "&Chars" [0-9]* -> ~[\<\&]* %% Part of CharData
+ "&StrChar" [0-9]* -> StrChar %% Part of StrCon
+ "&StrChar+" [0-9]* -> StrChar+ %% Part of StrCon
+ "&Chr" [0-9]* -> ~[\0-\31\n\t\"\\\<\&]