Is basic access defined in the C # 4.0 language specification correctly?

While I was looking at C# Language Specification v4.0 , I noticed that there was a rule group defined as follows:

 invocationExpression: primaryExpression '(' argumentList? ')' primary-expression: primary-no-array-creation-expression array-creation-expression primary-no-array-creation-expression: literal simple-name parenthesized-expression member-access invocation-expression element-access this-access base-access post-increment-expression post-decrement-expression object-creation-expression delegate-creation-expression anonymous-object-creation-expression typeof-expression checked-expression unchecked-expression default-value-expression anonymous-method-expression base-access: 'base' '.' identifier 'base' '[' argument-list ']' 

When I tried to compare this statement (which, by the way, is correct, I saw how it was used in the project)

 base.VisitList<T>(list, visitor); 

to these rules, I have not seen a way how to do this. There should be no base-access defined as:

  base-access: 'base' '.' identifier type-parameter-list(opt) 'base' '[' argument-list ']' 

or something similar in such a way that the grammar can capture the statement?

EDIT The example I saw was in the C # version of the db4o project, and it is something like this (I deleted most of the ads and left only the important ones)

 internal abstract class ExpressionVisitor { protected virtual void VisitList<T>() { } } internal class HashCodeCalculation : ExpressionVisitor { protected override void VisitList<T>() { base.VisitList<T>(); } } 
+4
source share
2 answers

Indeed, it looks like there might be a mistake in the specification.

Expression Analysis Method

 this.VisitList<T>(list, visitor) 

as follows:

 invocation-expression primary-expression '(' argumentList? ')' primary-no-array-creation-expression '(' argumentList? ')' member-access '(' argumentList? ')' primary-expression '.' identifier type-argument-listopt '(' argumentList? ')' this-access '.' identifier type-argument-listopt '(' argumentList? ')' 'this' '.' identifier type-argument-listopt '(' argumentList? ')' 

Etc.

In other words, this-access is defined as

 this-access: 'this' 

It would be very helpful if base-access were defined as

 base-access: 'base' 

Then the way to parse the expression

 base.VisitList<T>(list, visitor) 

will look like this:

 invocation-expression primary-expression '(' argumentList? ')' primary-no-array-creation-expression '(' argumentList? ')' member-access '(' argumentList? ')' primary-expression '.' identifier type-argument-listopt '(' argumentList? ')' base-access '.' identifier type-argument-listopt '(' argumentList? ')' 'base' '.' identifier type-argument-listopt '(' argumentList? ')' 

Etc.

But this is not so.

+4
source

I doubt this is really valid C # code. Perhaps you saw it in C ++?

The following code cannot compile with a syntax error:

 public class VisitList<T> : List<T> { public VisitList(int n) : base.VisitList<T>(n) { } } 

It works:

 public class VisitList<T> : List<T> { public VisitList(int n) : base(n) { } } 
+1
source

All Articles