private void ProcessEnumDeclaration() { Token enumName = _source.ReadNextTokenAndThrowIfAlreadyDefined(); ScriptEnum enumDefinition = new ScriptEnum(enumName.Name); enumName.Define(TokenType.EnumType, enumDefinition); enumName.IsVariableType = true; _source.ExpectKeyword(PredefinedSymbol.OpenBrace); int nextEnumValue = 0; while (!_source.NextIsKeyword(PredefinedSymbol.CloseBrace)) { Token enumEntry = _source.ReadNextTokenAndThrowIfAlreadyDefined(); KeywordToken nextToken = _source.ReadNextAsKeyword(); if (nextToken.SymbolType == PredefinedSymbol.SetEqual) { nextEnumValue = _source.ReadNextAsConstInt(); nextToken = _source.ReadNextAsKeyword(); } enumDefinition.Values.Add(enumEntry.Name, nextEnumValue); enumEntry.Define(TokenType.Constant, nextEnumValue); nextEnumValue++; if (nextToken.SymbolType == PredefinedSymbol.CloseBrace) { break; } else if (nextToken.SymbolType != PredefinedSymbol.Comma) { throw new CompilerMessage(ErrorCode.UnexpectedToken, "Expected comma at '" + nextToken.Name + "'"); } } _source.ExpectKeyword(PredefinedSymbol.Semicolon); }