Commit 39e61dd1 authored by david_v's avatar david_v
Browse files

2004-01-22 Valentin David <valentin@lrde.epita.fr>

	* configure.ac, src/disamb/Makefile.am: Update.

	* TODO: Update.

	* src/syn/TemplateParameters.sdf: Add tag for deterministic syntax.

	* test/disambiguate/template-05.cc,
	* test/disambiguate/template-10.detcc,
	* test/disambiguate/template-09.detcc,
	* test/disambiguate/template-05.detcc: Fix.

	* test/disambiguate/test.test, test/disambiguate/Makefile.am,
	* test/expressions/Makefile.am, test/expressions/test.test,
	* test/g++/template/Makefile.am, test/g++/template/test.test,
	* test/g++/parse/Makefile.am, test/g++/parse/test.test,
	* test/g++/overload/Makefile.am, test/g++/overload/test.test,
	* test/g++/other/Makefile.am, test/g++/other/test.test,
	* test/g++/opt/Makefile.am, test/g++/opt/test.test,
	* test/g++/lookup/Makefile.am, test/g++/lookup/test.test,
	* test/g++/init/Makefile.am, test/g++/init/test.test,
	* test/g++/inherit/Makefile.am, test/g++/inherit/test.test,
	* test/g++/eh/Makefile.am, test/g++/eh/test.test,
	* test/g++/debug/Makefile.am, test/g++/debug/test.test,
	* test/g++/abi/Makefile.am, test/g++/abi/test.test: Fix and update.

	* src/disamb/disambiguate/TemplateArguments.str,
	* src/disamb/disambiguate/TemplateTraverse.str,
	* src/disamb/disambiguate/TemplateDefinition.str,
	* src/disamb/disambiguate/TemplateClassTraverse.str,
	* src/disamb/disambiguate/TemplateClassDefinition.str,
	* src/disamb/disambiguate/SimpleTypeSpecifier.str,
	* src/disamb/disambiguate/ResolveCompound.str,
	* src/disamb/disambiguate/Resolve.str,
	* src/disamb/disambiguate/PrimaryExpression.str,
	* src/disamb/disambiguate/Parameter.str,
	* src/disamb/disambiguate/Makefile.am,
	* src/disamb/disambiguate/afcxx-disambiguate.str,
	* src/disamb/disambiguate/Kinds.str,
	* src/disamb/disambiguate/Keys.str,
	* src/disamb/disambiguate/Definition.str,
	* src/disamb/disambiguate/ClassOrNamespaceTraverse.str,
	* src/disamb/disambiguate/ClassOrNamespaceAmbiguity.str,
	* src/disamb/disambiguate/BaseTraverse.str,
	* src/disamb/disambiguate/AmbiguityCandidate.str: Fix several bugs.

	* src/parser/parse-cxx.str, config/check-rules.mk: Update.

	* src/disamb/simpledeclaration/Makefile.am,
	* src/disamb/simpledeclaration/afcxx-simpledeclaration.str,
	* src/disamb/simpledeclaration/afcxx-simpledeclaration.meta: New.

	* src/disamb/classparam/Makefile.am,
	* src/disamb/classparam/afcxx-classparam.str,
	* src/disamb/classparam/afcxx-classparam.meta: New.

	* src/disamb/disambiguate/PostfixExpressionAmbiguity.str,
	* src/disamb/disambiguate/PostfixExpressionAmbiguity.meta,
	* src/disamb/disambiguate/PostfixExpressionAmbiguityCandidate.str,
	* src/disamb/disambiguate/PostfixExpressionAmbiguityCandidate.meta,
	* src/disamb/disambiguate/TemplateIdAmbiguityCut.str,
	* src/disamb/disambiguate/TemplateIdAmbiguityCandidate.str,
	* src/disamb/disambiguate/TemplateIdAmbiguity.str,
	* src/disamb/disambiguate/TemplateIdAmbiguityCut.meta,
	* src/disamb/disambiguate/TemplateIdAmbiguityCandidate.meta,
	* src/disamb/disambiguate/TemplateIdAmbiguity.meta,
	* src/disamb/disambiguate/TemplateFunctionDefinitionCandidate.str,
	* src/disamb/disambiguate/TemplateFunctionDefinition.str,
	* src/disamb/disambiguate/TemplateFunctionDefinitionCandidate.meta,
	* src/disamb/disambiguate/TemplateFunctionDefinition.meta,
	* src/disamb/disambiguate/TemplateFunctionTraverse.str,
	* src/disamb/disambiguate/TemplateFunctionTraverse.meta: New.

	* src/disamb/ambdown/ambdown.str, src/disamb/ambdown/Makefile.am: New.
parent b21eb4fe
/*
* 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 PostfixExpresionAmbiguity
imports
lib
imports
AsFix2-Syntax
PostfixExpressionAmbiguityCandidate
Identifier
Kinds
rules
PostfixExpressionAmbiguity : amb (a) -> b
where < filter(check-postfix-expression) > a
; (?[e]; !e <+ getfirst(only-type)) => b
strategies
check-postfix-expression =
?|PostfixExpression[ SimpleTypeSpecifier ( ExpressionList-opt ) ]|
; where(<simple-type-specifier> SimpleTypeSpecifier)
check-postfix-expression =
?|PostfixExpression[ PostfixExpression ( ExpressionList-opt ) ]|
only-type =
?|PostfixExpression[ SimpleTypeSpecifier ( ExpressionList-opt ) ]|
postfix-expression-ambiguity-stop(s) = postfix-expression-ambiguity-candidate
postfix-expression-ambiguity = (postfix-expression-ambiguity-candidate;
PostfixExpressionAmbiguity)
/*
* 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 PostfixExpressionAmbiguityCandidate
imports
lib
imports
AsFix2-Syntax
asfix
Cxx
IfDebug
rules
PostfixExpressionAmbiguityCandidate : a@amb (l) -> a
where <map(
({SimpleTypeSpecifier, ExpressionList-opt:
?|PostfixExpression[ SimpleTypeSpecifier ( ExpressionList-opt ) ]|}
<+ {PostfixExpression, ExpressionList-opt:
?|PostfixExpression[ PostfixExpression ( ExpressionList-opt ) ]|})
)> l
; < ifdebug (debug) > "Candidate for postfix expression ambiguity"
strategies
postfix-expression-ambiguity-candidate = PostfixExpressionAmbiguityCandidate
/*
* 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
......@@ -38,30 +38,6 @@ rules
where < local-or-global > Dummy0-opt => Dummy0-opt'
; < nested-name-specifier > NestedNameSpecifier => NestedNameSpecifier'
(*
PrimaryExpression : appl (prod (x, cf (sort ("PrimaryExpression")), y),
[appl (prod (x', cf (sort ("IdExpression")), y'),
[appl (prod (x'', cf (sort ("QualifiedId")), y''),
[global,
lay1,
nested,
lay2,
template,
lay3,
name])])]) ->
appl (prod (x, cf (sort ("PrimaryExpression")), y),
[appl (prod (x', cf (sort ("IdExpression")), y'),
[appl (prod (x'', cf (sort ("QualifiedId")), y''),
[global',
lay1,
nested',
lay2,
template,
lay3,
name])])])
*)
strategies
primary-expression-stop(s) = primary-expression-candidate
......
/*
* 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
......@@ -27,44 +27,57 @@ imports
Ambiguity
AsFix2-Syntax
BaseTraverse
ClassOrNamespaceAmbiguity
ClassTraverse
CompoundStatement
NamespaceTraverse
PostfixExpressionAmbiguity
PrimaryExpression
SimpleTypeSpecifier
TemplateClassTraverse
TemplateTraverse
TypeAmbiguity
TemplateIdAmbiguity
TemplateFunctionTraverse
strategies
resolve-stop(s) = namespace-traverse-stop(s) <+
template-traverse-stop(s) <+
template-class-traverse-stop(s) <+
template-function-traverse-stop(s) <+
class-or-namespace-ambiguity-stop(s) <+
class-traverse-stop(s) <+
base-traverse-stop(s) <+
simple-type-specifier-stop(s) <+
primary-expression-stop(s) <+
compound-statement-stop(s) <+
templateid-ambiguity-stop(s) <+
ambiguity-stop(s)
resolve-single = namespace-traverse <+
template-traverse <+
template-class-traverse <+
template-function-traverse <+
class-or-namespace-ambiguity <+
class-traverse <+
base-traverse <+
simple-type-specifier <+
primary-expression <+
compound-statement <+
ambiguity <+
templateid-ambiguity <+
// ambiguity <+
not (namespace-traverse-candidate <+
template-traverse-candidate <+
template-class-traverse-candidate <+
template-function-traverse-candidate <+
class-or-namespace-ambiguity-candidate <+
class-traverse-candidate <+
base-traverse-candidate <+
simple-type-specifier-candidate <+
primary-expression-candidate <+
compound-statement-candidate <+
templateid-ambiguity-candidate <+
ambiguity-candidate)
resolve = topdownS (resolve-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
......@@ -26,11 +26,14 @@ imports
Ambiguity
AsFix2-Syntax
ClassOrNamespaceAmbiguity
ClassTraverse
CompoundStatement
NamespaceTraverse
PostfixExpressionAmbiguity
PrimaryExpression
SimpleTypeSpecifier
TemplateIdAmbiguity
TemplateTraverse
TypeDefinition
VariableDefinition
......@@ -38,32 +41,43 @@ imports
strategies
resolve-compound-stop(s) = namespace-traverse-stop(s) <+
postfix-expression-ambiguity-stop(s) <+
template-traverse-stop(s) <+
template-class-traverse-stop(s) <+
class-or-namespace-ambiguity-stop(s) <+
class-traverse-stop(s) <+
simple-type-specifier-stop(s) <+
primary-expression-stop(s) <+
compound-statement-stop(s)
templateid-ambiguity-stop(s) <+
compound-statement-stop(s) <+
type-definition-stop(s) <+
variable-definition-stop(s)
resolve-compound-single = namespace-traverse <+
postfix-expression-ambiguity <+
template-traverse <+
template-class-traverse <+
class-or-namespace-ambiguity <+
class-traverse <+
simple-type-specifier <+
primary-expression <+
templateid-ambiguity <+
compound-statement <+
type-definition <+
variable-definition <+
ambiguity <+
// ambiguity <+
not (namespace-traverse-candidate <+
postfix-expression-ambiguity-candidate <+
template-traverse-candidate <+
template-class-traverse-candidate <+
class-or-namespace-ambiguity-candidate <+
class-traverse-candidate <+
simple-type-specifier-candidate <+
primary-expression-candidate <+
compound-statement-candidate <+
type-definition-candidate <+
variable-definition-candidate <+
templateid-ambiguity-candidate <+
ambiguity-candidate)
resolve-compound = topdownS (resolve-compound-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
......@@ -42,7 +42,13 @@ rules
!nested; nested-name-specifier; ?nested';
!|NestedNameSpecifier?[ ~NestedNameSpecifier: nested'~ ]|)
> NestedNameSpecifier-opt => NestedNameSpecifier-opt'
; < type-ambiguity > TypeName => TypeName'
; < type-ambiguity <+ type-ambiguity-cut
<+ (?|TypeName[ TemplateId ]|
; resolve-compound
; where(!TemplateId
; GetTemplateIdKind
; class-template-kind(id))
)> TypeName => TypeName'
strategies
......
/*
* 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
......@@ -29,11 +29,65 @@ imports
Cxx
Kinds
rules
get-argument-kind: |TemplateArgument[ TypeId ]| -> type-kind
get-argument-kind: |TemplateArgument[ AssignmentExpression ]| -> variable-kind
strategies
extract-type = collect({TypeId: (?|TemplateArgument[ TypeId ]|; !type-kind)})
argument-kind-candidate = ?|TemplateArgument[ TypeId ]|
argument-kind-candidate = ?|TemplateArgument[ AssignmentExpression ]|
extract-type = collect(argument-kind-candidate); map(get-argument-kind)
rules
template-arguments : |TemplateArgumentList?[ TemplateArgumentList ]| -> l
where < extract-type > TemplateArgumentList => l
where < extract-type > TemplateArgumentList => l
strategies
next-kind = where(<TailKind> () => list
; rules(FirstKind : _ -> <Hd> list)
; rules(TailKind: _ -> <Tl> list)
)
resolve-argument = ?|TemplateArgument[ TypeId ]|
; <resolve> TypeId => TypeId'
; !|TemplateArgument[ TypeId' ]|
resolve-template-argument = argument-kind-candidate
; try(resolve-argument)
; ?argument
; <FirstKind> () => kind
; <get-argument-kind> argument => kind
; next-kind
; !argument
resolve-template-argument = amb(
getfirst(
{|FirstKind, TailKind:
resolve-template-argument
|})
; ?res)
; !res
; next-kind
foreach(candidate,do) = rec x(candidate < do + all(x))
template-arguments-resolve(list) = {|FirstKind, TailKind:
where(
list; Hd => hd
; rules(FirstKind : _ -> hd)
)
; where(
list; Tl => tl
; rules(TailKind: _ -> tl)
)
; foreach(argument-kind-candidate
+ amb(map(argument-kind-candidate))
, resolve-template-argument)
|}
\ No newline at end of file
/*
* 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,8 +41,11 @@ rules
where < identifier > ID => c // Read identifier (name of C).
; < rewrite (!"$namespace") > "$value" => d // Get current namespace name.
; < rewrite (!"$template") > "$value" => e // Consume template parameters.
; < rewrite (!"$template-parameters") > "$value" => p
; < end-scope (!"$template") > a
; < assert (!d) > (c, class-template-kind ([e])) // In N, mark C as being a class template.
; < 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.
; < ?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.
......
/*
* 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
......@@ -46,7 +46,10 @@ rules
where < identifier > ID => c
; < rewrite (!"$namespace") > "$value" => d
; < rewrite (!"$template") > "$value" => e
; < 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
; < id > template-key (c, e) => f
; < ?list-key (as); !as > d => d'
; < conc; ?x; !list-key (x) > (d', [f]) => g
......
/*
* 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
......@@ -36,8 +36,10 @@ rules
TemplateDefinition : a@|TemplateDeclaration[ Dummy2-opt template < TemplateParameterList > Declaration ]| -> a
where < begin-scope (!"$template") > a
; < parameters-normalize > TemplateParameterList => TemplateParameterList'
; < assert (!"$template") > ("$value", TemplateParameterList')
; < begin-scope (!"$template-parameters") > a
; < parameters-decl > TemplateParameterList => TemplateParameterList'
; < assert (!"$template") > ("$value", <map({x: ?(_,x); !x})> TemplateParameterList')
; < assert (!"$template-parameters") > ("$value", TemplateParameterList')
; < definition > Declaration
strategies
......
/*
* 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 TemplateFunctionDefinition
imports
lib
imports
AsFix2-Syntax
asfix
Cxx
Identifier
Kinds
TemplateFunctionDefinitionCandidate
rules
TemplateFunctionDefinition : a@|FunctionDefinition[ DeclSpecifierSeq-opt Declarator CtorInitializer-opt FunctionBody ]| -> a
where < oncetd(?|DeclaratorId[ ~IdExpression: |IdExpression[ ID ]|~ ]|); !ID; identifier > Declarator => c
; < rewrite (!"$namespace") > "$value" => d
; < rewrite (!"$template") > "$value" => e
; < 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
; < ?list-key (as); !as > d => d'
; < 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'
; < concat-strings; debug > ["+ Definition of template function", " ", g']
; < definition > FunctionBody
; < concat-strings; debug > ["- Definition of template function", " ", g']
strategies
template-function-definition-stop(s) = template-function-definition-candidate
template-function-definition = (template-function-definition-candidate;
TemplateFunctionDefinition)
/*
* 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 TemplateFunctionDefinitionCandidate
imports
lib
imports
AsFix2-Syntax
asfix
Cxx
Identifier
rules
TemplateFunctionDefinitionCandidate : a@|FunctionDefinition[ DeclSpecifierSeq-opt Declarator CtorInitializer-opt FunctionBody ]| -> a
where < rewrite (!"$template") > "$value"
; < ifdebug (debug) > "Candidate for template function declaration"
strategies
template-function-definition-candidate = TemplateFunctionDefinitionCandidate
/*
* 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 TemplateFunctionTraverse
imports
lib
imports
AsFix2-Syntax
asfix
Cxx
TemplateFunctionDefinitionCandidate
Identifier
Keys
Kinds
Resolve
rules
TemplateFunctionTraverse : a@|FunctionDefinition[ DeclSpecifierSeq-opt la1 Declarator la2 CtorInitializer-opt la3 FunctionBody ]| -> |FunctionDefinition[ DeclSpecifierSeq-opt la1 Declarator la2 CtorInitializer-opt la3 FunctionBody' ]|
where < oncetd(?|DeclaratorId[ ~IdExpression: |IdExpression[ ID ]|~ ]|); !ID; identifier > Declarator => c
; < rewrite (!"$namespace") > "$value" => d
; < rewrite (!"$template") > "$value" => e
; < 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
; < 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; debug > ["+ Entering template function", " ", g']
; < resolve > FunctionBody => FunctionBody'
; < concat-strings; debug > ["- Entering template function", " ", g']
strategies
template-function-traverse-candidate = template-function-definition-candidate
template-function-traverse-stop(s) = template-function-traverse-candidate
template-function-traverse = (template-function-traverse-candidate;
TemplateFunctionTraverse)