private static AstNode ParseEnum(TokenStream stream) { stream.Expect (TokenClass.Keyword, "enum"); string name = stream.Expect (TokenClass.Identifier).Value; EnumDeclaration decl = new EnumDeclaration (stream.Location, name); stream.Expect (TokenClass.OpenBrace); int defaultVal = -1; while (!stream.Match (TokenClass.CloseBrace)) { string ident = stream.Expect (TokenClass.Identifier).Value; if (stream.Accept (TokenClass.Operator, "=")) { string val = stream.Expect (TokenClass.IntLiteral).Value; int numVal = 0; if (val != "") { numVal = Int32.Parse (val); } decl.Items [ident] = numVal; } else { decl.Items [ident] = defaultVal--; } if (!stream.Accept (TokenClass.Comma)) { break; } } stream.Expect (TokenClass.CloseBrace); return decl; }
private IodineEnum CompileEnum(EnumDeclaration enumDecl) { IodineEnum ienum = new IodineEnum (enumDecl.Name); foreach (string name in enumDecl.Items.Keys) { ienum.AddItem (name, enumDecl.Items [name]); } return ienum; }
public override void Accept (EnumDeclaration enumDecl) { IodineEnum ienum = new IodineEnum (enumDecl.Name); foreach (string name in enumDecl.Items.Keys) { ienum.AddItem (name, enumDecl.Items [name]); } methodBuilder.EmitInstruction (enumDecl.Location, Opcode.LoadConst, methodBuilder.Module.DefineConstant (ienum)); methodBuilder.EmitInstruction (enumDecl.Location, Opcode.StoreLocal, symbolTable.GetSymbol (enumDecl.Name).Index); }
public void Accept(EnumDeclaration enumDecl) { module.SetAttribute (enumDecl.Name, CompileEnum (enumDecl)); }
public override void Accept (EnumDeclaration enumDecl) { errorLog.AddError (ErrorType.ParserError, enumDecl.Location, "statement can not exist inside pattern!"); }
public virtual void Accept(EnumDeclaration enumDecl) { }
public void Accept(EnumDeclaration enumDecl) { symbolTable.AddSymbol (enumDecl.Name); }
public void Accept(EnumDeclaration enumDecl) { }