Commit cb0aa7df authored by gourne_o's avatar gourne_o
Browse files

from Olivier Gournet <gourne_o@lrde.epita.fr>

	* src/disamb/sslext/ScopedFiniteMap.str: New file.
	* src/disamb/specifier/Makefile.am: Add path in include.
	* src/disamb/specifier/afcxx-specifier.str,
	* src/disamb/namespace/afcxx-namespace.str,
	* src/disamb/disambiguate/afcxx-disambiguate.str: 
	Save and reload symbol tables.
	* src/disamb/disambiguate/ClassDefinition.str,
	* src/disamb/disambiguate/BaseTraverse.str,
	* src/disamb/disambiguate/NamespaceDefinition.str,
	* src/disamb/disambiguate/LocalOrGlobal.str,
	* src/disamb/disambiguate/EnumDefinition.str,
	* src/disamb/disambiguate/ClassTraverse.str,
	* src/disamb/disambiguate/VariableDeclarator.str,
	* src/disamb/disambiguate/TemplateClassDefinition.str,
	* src/disamb/disambiguate/TypeDeclarator.str,
	* src/disamb/disambiguate/TemplateFunctionDefinition.str,
	* src/disamb/disambiguate/Lookup.str,
	* src/disamb/disambiguate/TemplateTraverse.str,
	* src/disamb/disambiguate/GetKey.str,
	* src/disamb/disambiguate/NamespaceTraverse.str,
	* src/disamb/disambiguate/TemplateClassTraverse.str,
	* src/disamb/disambiguate/TemplateFunctionTraverse.str,
	* src/disamb/disambiguate/ClassOrNamespaceTraverse.str,
	* src/disamb/disambiguate/TemplateDefinition.str: Use map wrapper strategies.
	* src/parser/ParsePPDirective.str,
	* src/parser/parse-cxx.str: Rewrite with context dump and less temporary files.

2004-05-14  Olivier Gournet  <gourne_o@lrde.epita.fr>
parent 3947519c
2004-05-14 Olivier Gournet <gourne_o@lrde.epita.fr>
* src/disamb/sslext/ScopedFiniteMap.str: New file.
* src/disamb/specifier/Makefile.am: Add path in include.
* src/disamb/specifier/afcxx-specifier.str,
* src/disamb/namespace/afcxx-namespace.str,
* src/disamb/disambiguate/afcxx-disambiguate.str:
Save and reload symbol tables.
* src/disamb/disambiguate/ClassDefinition.str,
* src/disamb/disambiguate/BaseTraverse.str,
* src/disamb/disambiguate/NamespaceDefinition.str,
* src/disamb/disambiguate/LocalOrGlobal.str,
* src/disamb/disambiguate/EnumDefinition.str,
* src/disamb/disambiguate/ClassTraverse.str,
* src/disamb/disambiguate/VariableDeclarator.str,
* src/disamb/disambiguate/TemplateClassDefinition.str,
* src/disamb/disambiguate/TypeDeclarator.str,
* src/disamb/disambiguate/TemplateFunctionDefinition.str,
* src/disamb/disambiguate/Lookup.str,
* src/disamb/disambiguate/TemplateTraverse.str,
* src/disamb/disambiguate/GetKey.str,
* src/disamb/disambiguate/NamespaceTraverse.str,
* src/disamb/disambiguate/TemplateClassTraverse.str,
* src/disamb/disambiguate/TemplateFunctionTraverse.str,
* src/disamb/disambiguate/ClassOrNamespaceTraverse.str,
* src/disamb/disambiguate/TemplateDefinition.str: Use map wrapper strategies.
* src/parser/ParsePPDirective.str,
* src/parser/parse-cxx.str: Rewrite with context dump and less temporary files.
2004-05-14 Olivier Gournet <gourne_o@lrde.epita.fr>
* src/syn/ThrowExpressions.sdf,
......
......@@ -83,7 +83,7 @@ rules
; < conc; ?x; !list-key (x) > (base', [string-key (ID')]) => inherit
; < rewrite (!local) <+ (!Nil) > "$inherit" => inherits
; < conc > (inherits, [inherit]) => inherits'
; < assert (!local) > ("$inherit", inherits')
; < my-assert (!local) > ("$inherit", inherits')
strategies
......
......@@ -41,14 +41,14 @@ rules
ClassDefinition : a@|ClassSpecifier[ ClassKey la1 ID la2 BaseClause-opt la3 { la4 MemberSpecification-opt la5 } ]| -> |ClassSpecifier[ ClassKey la1 ID la2 BaseClause-opt la3 { la4 MemberSpecification-opt' la5 } ]|
where < identifier > ID => c // Read identifier (name of C).
; < rewrite (!"$namespace") > "$value" => d // Get current namespace name.
; < assert (!d) > (c, class-kind) // In N, mark C as being a class.
; < my-assert (!d) > (c, class-kind) // In N, mark C as being a class.
; < ?list-key (as); !as > d => d' // Extract the list of nested namespace names.
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e // Append the new namespace name to the current list.
; < print-key > e => e' // Print the current list (this is for debugging only).
; < concat-strings; ifdebug (debug) > ["+ Definition of class", " ", e']
; < init-name-space (!e) > a // Initialize symbol table for N.
; < my-init-name-space (!e) > a // Initialize symbol table for N.
; < begin-scope (!"$namespace") > a // Save old current namespace name.
; < assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < my-assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < definition > MemberSpecification-opt => MemberSpecification-opt' // Process the class definition body.
; < end-scope (!"$namespace") > a // Restore old current namespace name.
; < concat-strings; ifdebug (debug) > ["- Definition of class", " ", e']
......@@ -63,7 +63,7 @@ rules
> NestedNameSpecifier-opt
; < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < assert (!d) > (c, class-kind)
; < my-assert (!d) > (c, class-kind)
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e
; < print-key > e => e'
......
......@@ -42,7 +42,7 @@ rules
; try(get-alias)
; list-key(at-last([string-key(?name)]; ![])) => path
; scope(!"$namespace",
< assert (!"$namespace") >
< my-assert (!"$namespace") >
("$value", path)
; <lookup> name
; (namespace-kind <+ alias-kind)
......@@ -50,7 +50,7 @@ rules
; list-key(<concat> [<id>, [string-key(name)]]) => e)
; print-key
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to namespace", " ", <id>]
; < assert (!"$namespace") > ("$value", e)
; < my-assert (!"$namespace") > ("$value", e)
ClassOrNamespaceTraverse-1 : a@|ClassOrNamespaceName[
~ClassName: |ClassName[ ID ]|~ ]| -> a
......@@ -61,7 +61,7 @@ rules
; try(get-alias) => e
; list-key(at-last([string-key(?name)]; ![])) => path
; scope(!"$namespace",
< assert (!"$namespace") >
< my-assert (!"$namespace") >
("$value", path)
; <lookup> name
; class-kind
......@@ -69,7 +69,7 @@ rules
; list-key(<concat> [<id>, [string-key(name)]]) => e)
; print-key
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to class", " ", <id>]
; < assert (!"$namespace") > ("$value", e)
; < my-assert (!"$namespace") > ("$value", e)
ClassOrNamespaceTraverse-2 : a@|ClassOrNamespaceName[
~ClassName: |ClassName[
......@@ -88,7 +88,7 @@ rules
; < conc; ?x; !list-key (x) > (d', [f]) => e
; < print-key > p => e'
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to class-template", " ", e']
; < assert (!"$namespace") > ("$value", p)
; < my-assert (!"$namespace") > ("$value", p)
strategies
......
......@@ -51,7 +51,7 @@ rules
; < print-key > e => e'
; < concat-strings; ifdebug (debug) > ["+ Entering class", " ", e']
; < begin-scope (!"$namespace") > a
; < assert (!"$namespace") > ("$value", e)
; < my-assert (!"$namespace") > ("$value", e)
; < resolve > BaseClause-opt => BaseClause-opt'
; < resolve > MemberSpecification-opt => MemberSpecification-opt'
; < end-scope (!"$namespace") > a
......
......@@ -38,7 +38,7 @@ rules
EnumDefinition : a@|EnumSpecifier[ enum ID { EnumeratorList-opt } ]| -> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < assert (!d) > (c, enum-kind)
; < my-assert (!d) > (c, enum-kind)
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e
; < print-key > e => e'
......
......@@ -109,7 +109,7 @@ strategies
follow = rec x(?[e]; ![] <+ [id|x]) => ns
; <rewrite(!"$namespace")> "$value" => list-key(old)
; !list-key(<conc> (old, ns))
; <assert(!"$namespace")> ("$value", <id>)
; <my-assert(!"$namespace")> ("$value", <id>)
; !e
get-alias = scope(!"$namespace",
......
......@@ -33,7 +33,7 @@ imports
rules
LocalOrGlobal-0 : a@|Dummy0?[ :: ]| -> a
where < assert (!"$namespace") > ("$value", list-key ([]))
where < my-assert (!"$namespace") > ("$value", list-key ([]))
; < ifdebug (debug) > "Starting nested name resolution from global namespace"
LocalOrGlobal-1 : a@|Dummy0?[ ]| -> a
......
......@@ -64,7 +64,7 @@ rules
Lookup-current(table) : (namespace, identifier) -> result
where < rewrite (!namespace; table) > identifier => result
; < assert (!"$namespace") > ("$value", namespace)
; < my-assert (!"$namespace") > ("$value", namespace)
//
// Recurse the lookup to the outer namespace.
......
......@@ -50,14 +50,14 @@ rules
where < identifier > ID => c // Read identifier (name of N).
; < rewrite (!"$namespace") > "$value" => d // Get current namespace name.
; < assert (!d) > (c, namespace-kind) // In N', mark N as being a namespace.
; < my-assert (!d) > (c, namespace-kind) // In N', mark N as being a namespace.
; < ?list-key (as); !as > d => d' // Extract the list of nested namespace names.
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e // Append the new namespace name to the current list.
; < print-key > e => e' // Print the current list (this is for debugging only).
; < concat-strings; ifdebug (debug) > ["+ Original definition of namespace", " ", e']
; < init-name-space (!e) > a // Initialize symbol table for N.
; < my-init-name-space (!e) > a // Initialize symbol table for N.
; < begin-scope (!"$namespace") > a // Save old current namespace name.
; < assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < my-assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < definition > NamespaceBody => NamespaceBody' // Process the namespace definition body.
; < end-scope (!"$namespace") > a // Restore old current namespace name.
; < concat-strings; ifdebug (debug) > ["- Original definition of namespace", " ", e']
......@@ -73,7 +73,7 @@ rules
|NamedNamespaceDefinition[
~ExtensionNamespaceDefinition:
|ExtensionNamespaceDefinition[
namespace la1 ID la2 { la3 NamespaceBody la4 } ]|~ ]|
namespace la1 ID la2 { la3 NamespaceBody' la4 } ]|~ ]|
where < identifier > ID => c // Read identifier (name of N).
; < rewrite (!"$namespace") > "$value" => d // Get current namespace name.
; < ?list-key (as); !as > d => d' // Extract the list of nested namespace names.
......@@ -81,7 +81,7 @@ rules
; < print-key > e => e' // Print the current list (this is for debugging only).
; < concat-strings; ifdebug (debug) > ["+ Extension of namespace", " ", e']
; < begin-scope (!"$namespace") > a // Save old current namespace name.
; < assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < my-assert (!"$namespace") > ("$value", e) // Set new current namespace name.
; < definition > NamespaceBody => NamespaceBody' // Process the namespace extension body.
; < end-scope (!"$namespace") > a // Restore old current namespace name.
; < concat-strings; ifdebug (debug) > ["- Extension of namespace", " ", e']
......@@ -101,8 +101,8 @@ rules
=> NamespaceName'
; Namespace-GetKey => alias)
; < identifier > ID => c
; < assert (!d) > (c, alias-kind)
; < assert (!alias-table(d)) > (c, alias)
; < my-assert (!d) > (c, alias-kind)
; < my-assert (!alias-table(d)) > (c, alias)
strategies
......
......@@ -57,8 +57,8 @@ rules
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e
; < print-key > e => e'
; < concat-strings; ifdebug (debug) > ["+ Entering namespace", " ", e']
; < begin-scope (!"$namespace") > ("$value", e)
; < assert (!"$namespace") > ("$value", e)
; < begin-scope (!"$namespace") > a
; < my-assert (!"$namespace") > ("$value", e)
; < resolve > inner => inner'
; < end-scope (!"$namespace") > a
; < concat-strings; ifdebug (debug) > ["- Entering namespace", " ", e']
......@@ -84,8 +84,8 @@ rules
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e
; < print-key > e => e'
; < concat-strings; ifdebug (debug) > ["+ Entering namespace", " ", e']
; < begin-scope (!"$namespace") > ("$value", e)
; < assert (!"$namespace") > ("$value", e)
; < begin-scope (!"$namespace") > a
; < my-assert (!"$namespace") > ("$value", e)
; < resolve > inner => inner'
; < end-scope (!"$namespace") > a
; < concat-strings; ifdebug (debug) > ["- Entering namespace", " ", e']
......
......@@ -45,16 +45,16 @@ rules
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < end-scope (!"$template-parameters") > a
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <assert(!d)> (idt, kind)) }) > p
; < assert (!d) > (c, class-template-kind (e)) // In N, mark C as being a class template.
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <my-assert(!d)> (idt, kind)) }) > p
; < my-assert (!d) > (c, class-template-kind (e)) // In N, mark C as being a class template.
; < ?list-key (as); !as > d => d' // Extract the list of nested namespace names.
; < id > template-key (c, e) => f // Form full name of class template.
; < conc; ?x; !list-key (x) > (d', [f]) => g // Append the new namespace name to the current list.
; < print-key > g => g' // Print the current list (this is for debugging only).
; < concat-strings; ifdebug (debug) > ["+ Definition of template class", " ", g']
; < init-name-space (!e) > a // Initialize symbol table for N.
; < my-init-name-space (!e) > a // Initialize symbol table for N.
; < begin-scope (!"$namespace") > a // Save old current namespace name.
; < assert (!"$namespace") > ("$value", g) // Set new current namespace name.
; < my-assert (!"$namespace") > ("$value", g) // Set new current namespace name.
; < definition > MemberSpecification-opt => MemberSpecification-opt' // Process the class definition body.
; < end-scope (!"$namespace") > a // Restore old current namespace name.
; < concat-strings; ifdebug (debug) > ["- Definition of template class", " ", g']
......@@ -73,8 +73,8 @@ rules
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < end-scope (!"$template-parameters") > a
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <assert(!d)> (idt, kind)) }) > p
; < assert (!d) > (c, class-template-kind (e))
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <my-assert(!d)> (idt, kind)) }) > p
; < my-assert (!d) > (c, class-template-kind (e))
; < ?list-key (as); !as > d => d'
; < id > template-key (c, e) => f
; < conc; ?x; !list-key (x) > (d', [f]) => g
......
......@@ -50,14 +50,14 @@ rules
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < end-scope (!"$template-parameters") > a
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <assert(!d)> (idt, kind)) }) > p
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <my-assert(!d)> (idt, kind)) }) > p
; < id > template-key (c, e) => f
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [f]) => g
; < print-key > g => g'
; < concat-strings; ifdebug (debug) > ["+ Entering template class", " ", g']
; < begin-scope (!"$namespace") > a
; < assert (!"$namespace") > ("$value", g)
; < my-assert (!"$namespace") > ("$value", g)
; < resolve > BaseClause-opt => BaseClause-opt'
; < resolve > MemberSpecification-opt => MemberSpecification-opt'
; < end-scope (!"$namespace") > a
......
......@@ -40,8 +40,8 @@ rules
; < begin-scope (!"$template-parameters") > a
; < resolve > TemplateParameterList => TemplateParameterList'
; < parameters-decl > TemplateParameterList' => l
; < assert (!"$template") > ("$value", <map({x: ?(_,x); !x})> l)
; < assert (!"$template-parameters") > ("$value", l)
; < my-assert (!"$template") > ("$value", <map({x: ?(_,x); !x})> l)
; < my-assert (!"$template-parameters") > ("$value", l)
; < definition > Declaration => Declaration'
strategies
......
......@@ -41,9 +41,9 @@ rules
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < end-scope (!"$template-parameters") > a
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <assert(!d)> (idt, kind)) }) > p
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <my-assert(!d)> (idt, kind)) }) > p
; < ?list-key (as); !as > d => d'
; < assert (!d) > (c, function-template-kind (e))
; < my-assert (!d) > (c, function-template-kind (e))
; < id > template-key (c, e) => f
; < conc; ?x; !list-key (x) > (d', [f]) => g
; < print-key > g => g'
......
......@@ -46,7 +46,7 @@ rules
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < end-scope (!"$template-parameters") > a
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <assert(!d)> (idt, kind)) }) > p
; < map({idt, kind: ?(idt, kind); !idt; ("" <+ <my-assert(!d)> (idt, kind)) }) > p
; < id > template-key (c, e) => f
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [f]) => g
......
......@@ -41,8 +41,8 @@ rules
where < begin-scope (!"$template") > a
; < begin-scope (!"$template-parameters") > a
; < parameters-decl > TemplateParameterList => TemplateParameterList'
; < assert (!"$template") > ("$value", <map({x: ?(_,x); !x})> TemplateParameterList')
; < assert (!"$template-parameters") > ("$value", TemplateParameterList')
; < my-assert (!"$template") > ("$value", <map({x: ?(_,x); !x})> TemplateParameterList')
; < my-assert (!"$template-parameters") > ("$value", TemplateParameterList')
; < topdown (not (?amb(xs))) > TemplateParameterList
; < resolve > Declaration => Declaration'
......
......@@ -40,7 +40,7 @@ rules
; < rewrite (!"$namespace") > "$value" => d
; < print-key > d => d'
; < concat-strings ; ifdebug (debug) > ["Type", " ", c, " ", "being defined in namespace", " ", d']
; < assert (!d) > (c, type-kind)
; < my-assert (!d) > (c, type-kind)
TypeDeclarator(s) : a@|DeclaratorId[ ~IdExpression: |IdExpression[ ID ]|~ ]| -> a
where s; not([]) => alias
......@@ -49,8 +49,8 @@ rules
; < print-key > d => d'
; < print-key > alias => alias'
; < concat-strings ; ifdebug (debug) > ["Type", " ", c, " ", "being defined in namespace", " ", d', " aliasing to ", alias']
; < assert (!d) > (c, type-kind)
; < assert (!alias-table(d)) > (c, alias)
; < my-assert (!d) > (c, type-kind)
; < my-assert (!alias-table(d)) > (c, alias)
strategies
......
......@@ -39,7 +39,7 @@ rules
; < rewrite (!"$namespace") > "$value" => d
; < print-key > d => d'
; < concat-strings ; ifdebug (debug) > ["Variable", " ", c, " ", "being defined in namespace", " ", d']
; < assert (!d) > (c, variable-kind)
; < my-assert (!d) > (c, variable-kind)
strategies
......
......@@ -29,32 +29,49 @@ imports
Definition
Keys
Resolve
ScopedFiniteMap
rules
Init : x -> x
where < assert (!"$namespace") > ("$value", list-key ([]))
where < my-assert (!"$namespace") > ("$value", list-key ([]))
Finish : x -> x
where < ifdebug (debug) > ""
where < ifdebug (debug) > ""
strategies
init = Init
finish = Finish
afcxx-disambiguate = iowrap (where(< table-create > "$parameters-normalize");
init-name-space (!"$namespace");
init-name-space (!"$template");
begin-scope (!"$namespace");
begin-scope (!"$template");
init;
definition;
finish;
init;
resolve;
finish;
end-scope (!"$template");
end-scope (!"$namespace");
exit-name-space (!"$template");
exit-name-space (!"$namespace"))
afcxx-disambiguate = io-wrap (symbtable-option,
where (< get-config > ("--symtable")
; ( restore-maplist
<+ (
ifdebug (debug (!"create disambiguate symbol tables (file):"))
; < my-table-create > "$parameters-normalize"
; my-init-name-space (!"$namespace")
; my-init-name-space (!"$template")
; begin-scope (!"$namespace")
; begin-scope (!"$template")
; init
)
)
)
; definition
; finish
; init
; resolve
; finish
; where (< get-config > ("--symtable"); save-maplist)
; end-scope (!"$template")
; end-scope (!"$namespace")
; exit-name-space (!"$template")
; exit-name-space (!"$namespace")
)
symbtable-option =
ArgOption("--symtable"
, where(<set-config> ("--symtable", <id>))
, !"--symtable Specify the symbol file to load"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment