Commit bd4373fc authored by david_v's avatar david_v
Browse files

from Valentin David <valentin@lrde.epita.fr>

	* src/disamb/disambiguate/UsingDefinition.str,
	* src/disamb/disambiguate/UsingDefinition.meta: New.
	* src/disamb/disambiguate/Definition.str: Handle using declarations.

	* src/disamb/disambiguate/Makefile.am: Update.

	* src/disamb/disambiguate/NamespaceDefinition.str: Use getkey.

	* src/disamb/disambiguate/CheckNamespaceName.str,
	* src/disamb/disambiguate/CheckClassName.str: Use scopes.

	* src/disamb/disambiguate/GetKey.str:
	Add rules for namespaces. Fix bugs on alias

	* src/disamb/disambiguate/EnumDefinitionCandidate.str,
	* src/disamb/disambiguate/EnumDefinition.str: Check only named enums.

	* src/disamb/disambiguate/DeclaratorIdAmbiguity.str: Correct a mistake.

	* src/disamb/disambiguate/ClassOrNamespaceTraverse.str:
	Check if the class or the namespace exists.

	* test/disambiguate/Makefile.am (XFAIL_TESTS): Update.

2004-04-05  Valentin David  <valentin@lrde.epita.fr>
parent 88100c11
2004-04-05 Valentin David <valentin@lrde.epita.fr>
* src/disamb/disambiguate/UsingDefinition.str,
* src/disamb/disambiguate/UsingDefinition.meta: New.
* src/disamb/disambiguate/Definition.str: Handle using declarations.
* src/disamb/disambiguate/Makefile.am: Update.
* src/disamb/disambiguate/NamespaceDefinition.str: Use getkey.
* src/disamb/disambiguate/CheckNamespaceName.str,
* src/disamb/disambiguate/CheckClassName.str: Use scopes.
* src/disamb/disambiguate/GetKey.str:
Add rules for namespaces. Fix bugs on alias
* src/disamb/disambiguate/EnumDefinitionCandidate.str,
* src/disamb/disambiguate/EnumDefinition.str: Check only named enums.
* src/disamb/disambiguate/DeclaratorIdAmbiguity.str: Correct a mistake.
* src/disamb/disambiguate/ClassOrNamespaceTraverse.str:
Check if the class or the namespace exists.
* test/disambiguate/Makefile.am (XFAIL_TESTS): Update.
2004-04-05 Valentin David <valentin@lrde.epita.fr>
* src/strcxxgen/strcxxgen.str: Fix variable name productions.
......
/*
* Copyright (C) 2003 EPITA Research and Development Laboratory
* Copyright (C) 2003, 2004 EPITA Research and Development Laboratory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -41,14 +41,15 @@ rules
CheckClassName : |ClassOrNamespaceName[ ClassName ]| -> |ClassOrNamespaceName[ ClassName' ]|
where < CheckClassName > ClassName => ClassName'
//FIXME: nested-name-specifier
CheckClassName : |MemInitializerId[ Dummy0-opt la1 NestedNameSpecifier-opt la2 ClassName ]| -> |MemInitializerId[ Dummy0-opt la1 NestedNameSpecifier-opt la2 ClassName' ]|
where < CheckClassName > ClassName => ClassName'
CheckClassName : a@|ClassName[ ID ]| -> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; (< lookup > c => class-kind
<+ < lookup > c => type-kind) // Bugfix for Std C++ grammar
; (< scope(!"$namespace", lookup) > c => class-kind
<+ < scope(!"$namespace", lookup) > c => type-kind) // Bugfix for Std C++ grammar
; < print-key > d => e
; < concat-strings ; ifdebug (debug) > ["Resolved ambiguity on name", " ", c, " ",
"in namespace", " ", e, " ",
......@@ -57,7 +58,7 @@ rules
CheckClassName : |ClassName[ ~TemplateId: tid@|TemplateId[ID < TemplateArgumentList-opt > ]|~ ]| -> |ClassName[ ~TemplateId: tid'~ ]|
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < lookup > c => class-template-kind([_])
; < scope(!"$namespace", lookup) > c => class-template-kind([_])
; < print-key > d => e
; < resolve > tid => tid'
; < concat-strings ; ifdebug (debug) > ["Resolved ambiguity on name", " ", c, " ",
......
......@@ -37,7 +37,7 @@ rules
CheckNamespaceOriginalName : a@|NamespaceName[ ~OriginalNamespaceName: |OriginalNamespaceName[ ID ]|~ ]| -> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < lookup > c => namespace-kind
; < scope(!"$namespace", lookup) > c => namespace-kind
; < print-key > d => e
; < concat-strings ; ifdebug (debug) > ["Resolved ambiguity on name", " ", c, " ",
"in namespace", " ", e, " ",
......@@ -46,7 +46,7 @@ rules
CheckNamespaceAliasName : a@|NamespaceName[ ~NamespaceAlias: |NamespaceAlias[ ID ]|~ ]| -> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < lookup > c => alias-kind
; < scope(!"$namespace", lookup) > c => alias-kind
; < print-key > d => e
; < concat-strings ; ifdebug (debug) > ["Resolved ambiguity on name", " ", c, " ",
"in namespace", " ", e, " ",
......
......@@ -36,9 +36,18 @@ rules
where < oncetd(?|Identifier[ ID ]|); !ID; identifier > nsn => c
; < rewrite (!"$namespace") > "$value" => d
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [string-key (c)]) => e
; < print-key > e => e'
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to namespace", " ", e']
; < conc; ?x; !list-key (x) > (d', [string-key (c)])
; try(get-alias)
; list-key(at-last([string-key(?name)]; ![])) => path
; scope(!"$namespace",
< assert (!"$namespace") >
("$value", path)
; <lookup> name
; (namespace-kind <+ alias-kind)
; < rewrite (!"$namespace") > "$value"
; 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)
ClassOrNamespaceTraverse-1 : a@|ClassOrNamespaceName[
......@@ -48,8 +57,16 @@ rules
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [string-key (c)])
; try(get-alias) => e
; < print-key > e => e'
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to class", " ", e']
; list-key(at-last([string-key(?name)]; ![])) => path
; scope(!"$namespace",
< assert (!"$namespace") >
("$value", path)
; <lookup> name
; class-kind
; < rewrite (!"$namespace")> "$value"
; 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)
ClassOrNamespaceTraverse-2 : a@|ClassOrNamespaceName[
......@@ -58,15 +75,18 @@ rules
-> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < scope (!"$namespace", lookup) > c => class-template-kind (l)
; scope (!"$namespace",
<lookup> c => class-template-kind (l)
; < template-arguments-resolve(!l) > TemplateArgumentList-opt => TemplateArgumentList-opt'
; < template-arguments > TemplateArgumentList-opt => g
; < rewrite (!"$namespace") > "$value"
; list-key(<concat> [<id>, [template-key(c,g)]]) => p)
; < id > template-key (c, g) => f
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [f]) => e
; < print-key > e => e'
; < print-key > p => e'
; < concat-strings ; ifdebug (debug) > ["Following nested name resolution to class-template", " ", e']
; < assert (!"$namespace") > ("$value", e)
; < assert (!"$namespace") > ("$value", p)
strategies
......
......@@ -37,7 +37,7 @@ strategies
TypeName ]|}
)
)
; where (< ifdebug (debug) > "Candidate for declarator id ambituity")
; where (< ifdebug (debug) > "Candidate for declarator id ambiguity")
declarator-id-ambiguity-stop(s) = declarator-id-ambiguity-candidate
......
......@@ -35,6 +35,7 @@ imports
EnumDefinition
TemplateFunctionDefinition
ConstructorDefinition
UsingDefinition
strategies
......@@ -46,6 +47,7 @@ strategies
class-definition-stop(s) <+
enum-definition-stop(s) <+
type-definition-stop(s) <+
using-definition-stop(s) <+
constructor-definition-stop(s) <+
compound-statement-candidate
......@@ -56,6 +58,7 @@ strategies
class-definition <+
enum-definition <+
type-definition <+
using-definition <+
constructor-definition <+
variable-definition <+
not (namespace-definition-candidate <+
......@@ -65,6 +68,7 @@ strategies
class-definition-candidate <+
enum-definition-candidate <+
type-definition-candidate <+
using-definition-candidate <+
variable-definition-candidate)
definition = topdownS (definition-single,
......
/*
* Copyright (C) 2003 EPITA Research and Development Laboratory
* Copyright (C) 2003, 2004 EPITA Research and Development Laboratory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -34,8 +34,8 @@ imports
rules
EnumDefinition : a@|EnumSpecifier[ enum Identifier-opt { EnumeratorList } ]| -> a
where < ?|Identifier?[ ID ]|; !ID; identifier > Identifier-opt => c
EnumDefinition : a@|EnumSpecifier[ enum ID { EnumeratorList-opt } ]| -> a
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < assert (!d) > (c, enum-kind)
; < ?list-key (as); !as > d => d'
......
/*
* Copyright (C) 2003 EPITA Research and Development Laboratory
* Copyright (C) 2003, 2004 EPITA Research and Development Laboratory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -34,7 +34,7 @@ imports
rules
EnumDefinitionCandidate : a@|EnumSpecifier[ enum Identifier-opt { EnumeratorList } ]| -> a
EnumDefinitionCandidate : a@|EnumSpecifier[ enum ID { EnumeratorList-opt } ]| -> a
where < ifdebug (debug) > "Candidate for enum definition"
strategies
......
......@@ -36,13 +36,28 @@ signature
rules
Namespace-GetKey : |NamespaceName[ ~OriginalNamespaceName: |OriginalNamespaceName[ ID ]|~ ]| -> key
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; !list-key([string-key(c)])
; < ?list-key(a) > d
; !list-key(<conc>(a, [string-key(c)])) => key
Namespace-GetKey : |NamespaceName[ ~NamespaceAlias: |NamespaceAlias[ ID ]|~ ]| -> key
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < get-alias > c
; < ?(list-key(a), list-key(b)) > (d, <id>)
; !list-key(<conc>(a, b)) => key
TypeName-GetKey : |TypeName[ ~ClassName: |ClassName[ ID ]|~ ]| -> key
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; ( < scope(!"$namespace", lookup) > c => class-kind
; !list-key([string-key(c)])
<+ < scope(!"$namespace", lookup) > c => type-kind
; < get-alias > c)
; ( < get-alias > c
<+!list-key([string-key(c)])))
; < ?(list-key(a), list-key(b)) > (d, <id>)
; !list-key(<conc>(a, b)) => key
......@@ -53,7 +68,8 @@ rules
; ( < scope(!"$namespace", lookup) > c => class-template-kind(_)
; !list-key([template-key(c,g)])
<+ < scope(!"$namespace", lookup) > c => type-kind
; < get-alias > c)
; ( < get-alias > c
<+!list-key([string-key(c)])))
; < ?(list-key(a), list-key(b)) > (d, <id>)
; !list-key(<conc>(a, b)) => key
......@@ -62,18 +78,30 @@ rules
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < scope (!"$namespace", lookup) > c => type-kind
; < get-alias > c
; ( < get-alias > c
<+!list-key([string-key(c)]))
; < ?(list-key(a), list-key(b)) > (d, <id>)
; !list-key(<conc>(a, b)) => key
SimpleTypeSpecifier-GetKey : |SimpleTypeSpecifier[ Dummy0-opt NestedNameSpecifier-opt TypeName ]| -> key
where < local-or-global > Dummy0-opt
where scope(!"$namespace",
< local-or-global > Dummy0-opt
; < try(
?|NestedNameSpecifier?[ ~NestedNameSpecifier: nested~ ]|;
!nested; nested-name-specifier; ?nested';
!|NestedNameSpecifier?[ ~NestedNameSpecifier: nested'~ ]|)
> NestedNameSpecifier-opt
; < TypeName-GetKey > TypeName => key)
QNamespace-GetKey : |QualifiedNamespaceSpecifier[ Dummy0-opt NestedNameSpecifier-opt NamespaceName ]| -> key
where scope(!"$namespace",
< local-or-global > Dummy0-opt
; < try(
?|NestedNameSpecifier?[ ~NestedNameSpecifier: nested~ ]|;
!nested; nested-name-specifier; ?nested';
!|NestedNameSpecifier?[ ~NestedNameSpecifier: nested'~ ]|)
> NestedNameSpecifier-opt
; < TypeName-GetKey > TypeName => key
; < Namespace-GetKey > NamespaceName => key)
strategies
......
......@@ -71,6 +71,7 @@ SRCS = \
TypeDeclaratorCandidate.str \
TypeDefinition.str \
TypeDefinitionCandidate.str \
UsingDefinition.str \
VariableDeclarator.str \
VariableDeclaratorCandidate.str \
VariableDefinition.str \
......@@ -134,6 +135,7 @@ METAS = \
TypeDeclaratorCandidate.meta \
TypeDefinition.meta \
TypeDefinitionCandidate.meta \
UsingDefinition.meta \
VariableDeclarator.meta \
VariableDeclaratorCandidate.meta \
VariableDefinition.meta \
......
......@@ -98,8 +98,7 @@ rules
; < rewrite (!"$namespace") > "$value" => d
; < try(namespace-name-ambiguity) > NamespaceName
=> NamespaceName'
; collect(?|Identifier[ ID' ]|)
; !ID' => alias)
; Namespace-GetKey => alias)
; < identifier > ID => c
; < assert (!d) > (c, alias-kind)
; < assert (!alias-table(d)) > (c, alias)
......
/*
* Copyright (C) 2004 EPITA Research and Development Laboratory
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
module UsingDefinition
imports
lib
signature
constructors
assoc : Term -> Term
imports
AsFix2-Syntax
asfix
Cxx
Identifier
Kinds
rules
UsingDefinition: a@|UsingDeclaration[
using typename Dummy0-opt NestedNameSpecifier ID ; ]| -> a
where (<SimpleTypeSpecifier-GetKey> |SimpleTypeSpecifier[
Dummy0-opt NestedNameSpecifier ~TypedefName:
|TypedefName[ ID ]|~ ]|
<+ ![]) => alias
; <type-declarator(!alias)>
|DeclaratorId[ ~IdExpression:|IdExpression[ ID ]|~ ]|
UsingDefinition: a@|UsingDeclaration[
using Dummy0-opt NestedNameSpecifier ID ; ]| -> a
where try(<simple-type-specifier> |SimpleTypeSpecifier[
Dummy0-opt NestedNameSpecifier
~TypeName: amb([
|TypeName[ ~TypedefName:|TypedefName[ ID ]|~]|,
|TypeName[ ~ClassName:|ClassName[ ID ]|~]|,
|TypeName[ ~EnumName:|EnumName[ ID ]|~]|])~ ]|
; SimpleTypeSpecifier-GetKey => alias
; <type-declarator(!alias)> |DeclaratorId[ ~IdExpression:
|IdExpression[ ID ]|~ ]|)
UsingDefinition: a@|UsingDeclaration[ using :: ID ; ]| -> a
where try(<simple-type-specifier> |SimpleTypeSpecifier[
::
~TypeName: amb([
|TypeName[ ~TypedefName:|TypedefName[ ID ]|~]|,
|TypeName[ ~ClassName:|ClassName[ ID ]|~]|,
|TypeName[ ~EnumName:|EnumName[ ID ]|~]|])~ ]|
; SimpleTypeSpecifier-GetKey => alias
; <type-declarator(!alias)>
|DeclaratorId[ ~IdExpression:|IdExpression[ ID ]|~ ]|)
strategies
using-definition = using-definition-candidate; UsingDefinition
using-definition-candidate =
(?|UsingDeclaration[
using Dummy1-opt Dummy0-opt NestedNameSpecifier UnqualifiedId ; ]|
<+ ?|UsingDeclaration[ using :: UnqualifiedId' ; ]|)
; where(<ifdebug(debug)> "Candidate for using definition")
using-definition-stop(s) = using-definition-candidate
\ No newline at end of file
......@@ -84,10 +84,7 @@ TESTS = \
variable-01
XFAIL_TESTS = \
namespace-08 \
namespace-09 \
namespace-10 \
namespace-11 \
template-12
EXTRA_DIST = test $(TESTS:=.cc) $(TESTS:=.detcc)
Supports Markdown
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