src/compiler/Parser.cpp
changeset 261 219b49bf4a03
parent 258 241d082d6d89
child 263 ba85a47ee414
     1.1 --- a/src/compiler/Parser.cpp	Sat Jan 12 16:35:26 2013 -0800
     1.2 +++ b/src/compiler/Parser.cpp	Sun Jan 27 17:34:30 2013 -0800
     1.3 @@ -1106,7 +1106,7 @@
     1.4          break;
     1.5  
     1.6        case TOK_ENUM:
     1.7 -        if ((statement = enum_()) == NULL)
     1.8 +        if ((statement = enum_(TOK_NONE)) == NULL)
     1.9            return NULL;
    1.10          break;
    1.11  
    1.12 @@ -1189,7 +1189,7 @@
    1.13  }
    1.14  
    1.15  Statement *
    1.16 -Parser::enum_()
    1.17 +Parser::enum_(TokenKind kind)
    1.18  {
    1.19      // enum ::= "enum" name? { enum_members? }
    1.20      // enum_members ::= enum_member ","? |
    1.21 @@ -1229,7 +1229,7 @@
    1.22      if (!expect(TOK_RBRACE))
    1.23          return NULL;
    1.24  
    1.25 -    return new (pool_) EnumStatement(pos, name, entries);
    1.26 +    return new (pool_) EnumStatement(pos, kind, name, entries);
    1.27  }
    1.28  
    1.29  template <class T>
    1.30 @@ -1460,6 +1460,11 @@
    1.31                      return NULL;
    1.32                  if (!matchSemicolon())
    1.33                      return NULL;
    1.34 +            } else if (kind == TOK_PUBLIC && peek(TOK_ENUM)) {
    1.35 +                if ((statement = enum_(kind)) == NULL)
    1.36 +                    return NULL;
    1.37 +                if (!matchSemicolon())
    1.38 +                    return NULL;
    1.39              } else {
    1.40                  if ((statement = function(kind)) == NULL)
    1.41                      return NULL;
    1.42 @@ -1485,7 +1490,7 @@
    1.43            }
    1.44  
    1.45            case TOK_ENUM:
    1.46 -            if ((statement = enum_()) == NULL)
    1.47 +            if ((statement = enum_(TOK_NONE)) == NULL)
    1.48                  return NULL;
    1.49              if (!matchSemicolon())
    1.50                  return NULL;