enum_declaration
: opt_attributes
opt_modifiers
- opt_partial
ENUM IDENTIFIER
opt_enum_base {
if (RootContext.Documentation != null)
enum_body
opt_semicolon
{
- LocatedToken lt = (LocatedToken) $5;
+ LocatedToken lt = (LocatedToken) $4;
Location enum_location = lt.Location;
- if ($3 != null) {
- Report.Error (267, lt.Location, "The partial modifier can only appear immediately before `class', `struct' or `interface'");
- break; // assumes that the parser put us in a switch
- }
-
MemberName name = MakeName (new MemberName (lt.Value, enum_location));
- Enum e = new Enum (current_namespace, current_class, (Expression) $6, (int) $2,
+ Enum e = new Enum (current_namespace, current_class, (Expression) $5, (int) $2,
name, (Attributes) $1);
if (RootContext.Documentation != null)
EnumMember em = null;
- foreach (VariableDeclaration ev in (ArrayList) $8) {
+ foreach (VariableDeclaration ev in (ArrayList) $7) {
em = new EnumMember (e, em, (Expression) ev.expression_or_array_initializer,
new MemberName (ev.identifier, ev.Location), ev.OptAttributes);
: /* empty */ { $$ = (int) 0; }
| modifiers
;
-
+
modifiers
: modifier
| modifiers modifier
}
$$ = (int) (m1 | m2);
}
- ;
+ ;
modifier
: NEW { $$ = Modifiers.NEW; }
int next_token = token ();
bool ok = (next_token == Token.CLASS) ||
(next_token == Token.STRUCT) ||
- (next_token == Token.INTERFACE) ||
- (next_token == Token.ENUM); // "partial" is a keyword in 'partial enum', even though it's not valid
+ (next_token == Token.INTERFACE);
reader.Position = old;
ref_line = old_ref_line;
if (ok)
return res;
- else {
- val = new LocatedToken (Location, "partial");
- return Token.IDENTIFIER;
- }
+
+ Report.Error (267, Location, "The `partial' modifier can be used only immediately before keyword `class', `struct', or `interface'");
+ val = new LocatedToken (Location, "partial");
+ return Token.IDENTIFIER;
}
return res;