// Licensed under the terms of the GNU GPL
//
// (C) 2001 Ximian, Inc (http://www.ximian.com)
+// (C) 2004 Novell, Inc
//
// TODO:
// (1) Figure out why error productions dont work. `type-declaration' is a
/// The current file.
///
SourceFile file;
+
+ ///
+ /// Temporary Xml documentation cache.
+ /// For enum types, we need one more temporary store.
+ ///
+ string tmpComment;
+ string enumTypeComment;
+
/// Current attribute target
opt_EOF
: /* empty */
+ {
+ Lexer.check_incorrect_doc_comment ();
+ }
| EOF
+ {
+ Lexer.check_incorrect_doc_comment ();
+ }
;
outer_declarations
using_directive
: using_alias_directive
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
| using_namespace_directive
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
;
using_alias_directive
namespace_body
: OPEN_BRACE
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
opt_using_directives
opt_namespace_member_declarations
CLOSE_BRACE
} else {
$$ = new Attributes (sect);
}
+ if ($$ == null) {
+ if (RootContext.Documentation != null) {
+ Lexer.check_incorrect_doc_comment ();
+ Lexer.doc_state =
+ XmlCommentState.Allowed;
+ }
+ }
} else {
$$ = new Attributes (sect);
}
current_class.SetParameterInfo ((ArrayList) $8);
+ if (RootContext.Documentation != null)
+ current_class.DocComment = Lexer.consume_doc_comment ();
+
current_class.Register ();
}
struct_body
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
opt_semicolon
{
$$ = current_class;
;
struct_body
- : OPEN_BRACE opt_struct_member_declarations CLOSE_BRACE
+ : OPEN_BRACE
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+ opt_struct_member_declarations CLOSE_BRACE
;
opt_struct_member_declarations
(Expression) constant.expression_or_array_initializer, modflags,
(Attributes) $1, l);
+ if (RootContext.Documentation != null) {
+ c.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
current_container.AddConstant (c);
}
}
var.expression_or_array_initializer,
(Attributes) $1, l);
+ if (RootContext.Documentation != null) {
+ field.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
current_container.AddField (field);
}
}
method_declaration
: method_header {
iterator_container = (IIteratorContainer) $1;
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.NotAllowed;
}
method_body
{
current_local_parameters = null;
iterator_container = null;
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
;
current_local_parameters = (Parameters) $6;
+ if (RootContext.Documentation != null)
+ method.DocComment = Lexer.consume_doc_comment ();
+
$$ = method;
}
| opt_attributes
lexer.Location);
current_local_parameters = (Parameters) $6;
+
+ if (RootContext.Documentation != null)
+ method.DocComment = Lexer.consume_doc_comment ();
+
$$ = method;
}
| opt_attributes
lexer.Location);
current_local_parameters = (Parameters) $6;
+
+ if (RootContext.Documentation != null)
+ method.DocComment = Lexer.consume_doc_comment ();
+
$$ = method;
}
;
property_declaration
: opt_attributes
opt_modifiers
- type namespace_or_type_name
+ type
+ namespace_or_type_name
+ {
+ if (RootContext.Documentation != null)
+ tmpComment = Lexer.consume_doc_comment ();
+ }
OPEN_BRACE
{
implicit_value_parameter_type = (Expression) $3;
CLOSE_BRACE
{
Property prop;
- Pair pair = (Pair) $7;
+ Pair pair = (Pair) $8;
Accessor get_block = (Accessor) pair.First;
Accessor set_block = (Accessor) pair.Second;
- Location loc = (Location) $6;
+ Location loc = (Location) $7;
MemberName name = (MemberName) $4;
if (name.TypeArguments != null)
current_container.AddProperty (prop);
implicit_value_parameter_type = null;
iterator_container = null;
+
+ if (RootContext.Documentation != null)
+ prop.DocComment = ConsumeStoredComment ();
+
}
;
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
current_local_parameters = null;
lexer.PropertyParsing = true;
+
+ if (RootContext.Documentation != null)
+ if (Lexer.doc_state == XmlCommentState.Error)
+ Lexer.doc_state = XmlCommentState.NotAllowed;
}
;
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
current_local_parameters = null;
lexer.PropertyParsing = true;
+
+ if (RootContext.Documentation != null
+ && Lexer.doc_state == XmlCommentState.Error)
+ Lexer.doc_state = XmlCommentState.NotAllowed;
}
;
current_class.SetParameterInfo ((ArrayList) $8);
+ if (RootContext.Documentation != null) {
+ current_class.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
current_class.Register ();
}
interface_body opt_semicolon
{
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+ opt_semicolon
+ {
$$ = current_class;
current_container = current_container.Parent;
Method m = (Method) $1;
current_container.AddMethod (m);
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
| interface_property_declaration
{
Property p = (Property) $1;
current_container.AddProperty (p);
- }
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
| interface_event_declaration
{
if ($1 != null){
Event e = (Event) $1;
current_container.AddEvent (e);
}
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
| interface_indexer_declaration
{
Indexer i = (Indexer) $1;
current_container.AddIndexer (i);
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
;
$$ = new Method (current_class, generic, (Expression) $3, (int) $2, true, name,
(Parameters) $6, (Attributes) $1, lexer.Location);
+ if (RootContext.Documentation != null)
+ ((Method) $$).DocComment = Lexer.consume_doc_comment ();
}
| opt_attributes opt_new VOID namespace_or_type_name
OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
$$ = new Method (current_class, generic, TypeManager.system_void_expr, (int) $2,
true, name, (Parameters) $6, (Attributes) $1, lexer.Location);
+ if (RootContext.Documentation != null)
+ ((Method) $$).DocComment = Lexer.consume_doc_comment ();
}
;
$$ = new Property (current_class, (Expression) $3, (int) $2, true,
new MemberName ((string) $4), (Attributes) $1,
pinfo.Get, pinfo.Set, lexer.Location);
+ if (RootContext.Documentation != null)
+ ((Property) $$).DocComment = Lexer.consume_doc_comment ();
}
| opt_attributes
opt_new
$$ = new EventField (current_class, (Expression) $4, (int) $2, true,
new MemberName ((string) $5), null,
(Attributes) $1, lexer.Location);
+ if (RootContext.Documentation != null)
+ ((EventField) $$).DocComment = Lexer.consume_doc_comment ();
}
| opt_attributes opt_new EVENT type error {
CheckIdentifierToken (yyToken);
new MemberName (TypeContainer.DefaultIndexerName),
(int) $2, true, (Parameters) $6, (Attributes) $1,
info.Get, info.Set, lexer.Location);
+ if (RootContext.Documentation != null)
+ ((Indexer) $$).DocComment = ConsumeStoredComment ();
}
;
new Parameters (param_list, null, decl.location),
(ToplevelBlock) $5, (Attributes) $1, decl.location);
+ if (RootContext.Documentation != null)
+ op.DocComment = ConsumeStoredComment ();
+
if (SimpleIteratorContainer.Simple.Yields)
op.SetYields ();
op = Operator.OpType.UnaryNegation;
Parameter [] pars = new Parameter [1];
+ Expression type = (Expression) $5;
- pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null);
+ pars [0] = new Parameter (type, (string) $6, Parameter.Modifier.NONE, null);
current_local_parameters = new Parameters (pars, null, lexer.Location);
- $$ = new OperatorDeclaration (op, (Expression) $1, (Expression) $5, (string) $6,
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
+ $$ = new OperatorDeclaration (op, (Expression) $1, type, (string) $6,
null, null, lexer.Location);
}
| type OPERATOR overloadable_operator
type IDENTIFIER
CLOSE_PARENS
{
- CheckBinaryOperator ((Operator.OpType) $3);
+ CheckBinaryOperator ((Operator.OpType) $3);
- Parameter [] pars = new Parameter [2];
+ Parameter [] pars = new Parameter [2];
- pars [0] = new Parameter ((Expression) $5, (string) $6, Parameter.Modifier.NONE, null);
- pars [1] = new Parameter ((Expression) $8, (string) $9, Parameter.Modifier.NONE, null);
+ Expression typeL = (Expression) $5;
+ Expression typeR = (Expression) $8;
+
+ pars [0] = new Parameter (typeL, (string) $6, Parameter.Modifier.NONE, null);
+ pars [1] = new Parameter (typeR, (string) $9, Parameter.Modifier.NONE, null);
current_local_parameters = new Parameters (pars, null, lexer.Location);
+
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
$$ = new OperatorDeclaration ((Operator.OpType) $3, (Expression) $1,
- (Expression) $5, (string) $6,
- (Expression) $8, (string) $9, lexer.Location);
+ typeL, (string) $6,
+ typeR, (string) $9, lexer.Location);
}
| conversion_operator_declarator
;
c.OptAttributes = (Attributes) $1;
c.ModFlags = (int) $2;
+ if (RootContext.Documentation != null)
+ c.DocComment = ConsumeStoredComment ();
+
if (c.Name == current_container.Basename){
if ((c.ModFlags & Modifiers.STATIC) != 0){
if ((c.ModFlags & Modifiers.Accessibility) != 0){
current_container.AddConstructor (c);
current_local_parameters = null;
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
;
constructor_declarator
- : IDENTIFIER
+ : IDENTIFIER
+ {
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+ }
OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS
{
oob_stack.Push (lexer.Location);
- current_local_parameters = (Parameters) $3;
+ current_local_parameters = (Parameters) $4;
}
opt_constructor_initializer
{
Location l = (Location) oob_stack.Pop ();
- $$ = new Constructor (current_class, (string) $1, 0, (Parameters) $3,
- (ConstructorInitializer) $6, l);
+ $$ = new Constructor (current_class, (string) $1, 0, (Parameters) $4,
+ (ConstructorInitializer) $7, l);
}
;
;
destructor_declaration
- : opt_attributes opt_finalizer TILDE IDENTIFIER OPEN_PARENS CLOSE_PARENS block
+ : opt_attributes opt_finalizer TILDE
+ {
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.NotAllowed;
+ }
+ }
+ IDENTIFIER OPEN_PARENS CLOSE_PARENS block
{
- if ((string) $4 != current_container.Basename){
+ if ((string) $5 != current_container.Basename){
Report.Error (574, lexer.Location, "Name of destructor must match name of class");
} else if (!(current_container is Class)){
Report.Error (575, lexer.Location, "Destructors are only allowed in class types");
Method d = new Destructor (
current_class, TypeManager.system_void_expr, m, "Finalize",
new Parameters (null, null, l), (Attributes) $1, l);
+ if (RootContext.Documentation != null)
+ d.DocComment = ConsumeStoredComment ();
- d.Block = (ToplevelBlock) $7;
+ d.Block = (ToplevelBlock) $8;
current_container.AddMethod (d);
}
}
lexer.Location);
current_container.AddEvent (e);
-
+
+ if (RootContext.Documentation != null) {
+ e.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
}
}
| opt_attributes
current_class, (Expression) $4, (int) $2, false, name, null,
(Attributes) $1, (Accessor) pair.First, (Accessor) pair.Second,
loc);
-
+ if (RootContext.Documentation != null) {
+ e.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
current_container.AddEvent (e);
implicit_value_parameter_type = null;
}
Report.Error (71, lexer.Location, "Explicit implementation of events requires property syntax");
else
Report.Error (71, lexer.Location, "Event declaration should use property syntax");
+
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
}
;
indexer = new Indexer (current_class, decl.type, name,
(int) $2, false, decl.param_list, (Attributes) $1,
get_block, set_block, loc);
+ if (RootContext.Documentation != null)
+ indexer.DocComment = ConsumeStoredComment ();
current_container.AddIndexer (indexer);
} else if (pars.FixedParameters == null && pars.ArrayParameter == null){
Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
}
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
$$ = new IndexerDeclaration ((Expression) $1, null, pars);
}
} else if (pars.FixedParameters == null && pars.ArrayParameter == null){
Report.Error (1551, lexer.Location, "Indexers must have at least one parameter");
}
+
MemberName name = (MemberName) $2;
if (name.TypeArguments != null)
syntax_error (lexer.Location, "an indexer can't have type arguments");
$$ = new IndexerDeclaration ((Expression) $1, name, pars);
+
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
}
;
: opt_attributes
opt_modifiers
ENUM IDENTIFIER
- opt_enum_base
+ opt_enum_base {
+ if (RootContext.Documentation != null)
+ enumTypeComment = Lexer.consume_doc_comment ();
+ }
enum_body
opt_semicolon
{
Enum e = new Enum (current_namespace, current_container, (Expression) $5, (int) $2,
full_name, (Attributes) $1, enum_location);
- foreach (VariableDeclaration ev in (ArrayList) $6) {
+ if (RootContext.Documentation != null)
+ e.DocComment = enumTypeComment;
+
+ foreach (VariableDeclaration ev in (ArrayList) $7) {
e.AddEnumMember (ev.identifier,
(Expression) ev.expression_or_array_initializer,
- ev.Location, ev.OptAttributes);
+ ev.Location, ev.OptAttributes,
+ ev.DocComment);
}
string name = full_name.GetName ();
;
enum_body
- : OPEN_BRACE opt_enum_member_declarations CLOSE_BRACE
+ : OPEN_BRACE
{
- $$ = $2;
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+ opt_enum_member_declarations
+ {
+ // here will be evaluated after CLOSE_BLACE is consumed.
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+ CLOSE_BRACE
+ {
+ $$ = $3;
}
;
enum_member_declaration
: opt_attributes IDENTIFIER
{
- $$ = new VariableDeclaration ((string) $2, null, lexer.Location, (Attributes) $1);
+ VariableDeclaration vd = new VariableDeclaration ((string) $2, null, lexer.Location, (Attributes) $1);
+
+ if (RootContext.Documentation != null) {
+ vd.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
+ $$ = vd;
}
| opt_attributes IDENTIFIER
{
- $$ = lexer.Location;
+ $$ = lexer.Location;
+ if (RootContext.Documentation != null) {
+ tmpComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.NotAllowed;
+ }
}
ASSIGN expression
{
- $$ = new VariableDeclaration ((string) $2, $5, lexer.Location, (Attributes) $1);
+ VariableDeclaration vd = new VariableDeclaration ((string) $2, $5, lexer.Location, (Attributes) $1);
+
+ if (RootContext.Documentation != null)
+ vd.DocComment = ConsumeStoredComment ();
+
+ $$ = vd;
}
;
Delegate del = new Delegate (current_namespace, current_container, (Expression) $4,
(int) $2, name, (Parameters) $7, (Attributes) $1, l);
+ if (RootContext.Documentation != null) {
+ del.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
current_container.AddDelegate (del);
RootContext.Tree.RecordDecl (name.GetName (true), del);
TypeManager.system_void_expr, (int) $2, name,
(Parameters) $7, (Attributes) $1, l);
+ if (RootContext.Documentation != null) {
+ del.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
current_container.AddDelegate (del);
RootContext.Tree.RecordDecl (name.GetName (true), del);
current_class.SetParameterInfo ((ArrayList) $8);
+ if (RootContext.Documentation != null) {
+ current_class.DocComment = Lexer.consume_doc_comment ();
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
+
current_class.Register ();
}
- class_body
+ class_body
+ {
+ if (RootContext.Documentation != null)
+ Lexer.doc_state = XmlCommentState.Allowed;
+ }
opt_semicolon
{
$$ = current_class;
public object expression_or_array_initializer;
public Location Location;
public Attributes OptAttributes;
+ public string DocComment;
public VariableDeclaration (string id, object eoai, Location l, Attributes opt_attrs)
{
CheckToken (1041, yyToken, "Identifier expected");
}
+string ConsumeStoredComment ()
+{
+ string s = tmpComment;
+ tmpComment = null;
+ Lexer.doc_state = XmlCommentState.Allowed;
+ return s;
+}
+
/* end end end */
}