예제 #1
0
        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;
        }
예제 #2
0
 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;
 }
예제 #3
0
		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);
		}
예제 #4
0
 public void Accept(EnumDeclaration enumDecl)
 {
     module.SetAttribute (enumDecl.Name, CompileEnum (enumDecl));
 }
예제 #5
0
		public override void Accept (EnumDeclaration enumDecl)
		{
			errorLog.AddError (ErrorType.ParserError, enumDecl.Location,
				"statement can not exist inside pattern!");
		}
예제 #6
0
 public virtual void Accept(EnumDeclaration enumDecl)
 {
 }
예제 #7
0
 public void Accept(EnumDeclaration enumDecl)
 {
     symbolTable.AddSymbol (enumDecl.Name);
 }
예제 #8
0
 public void Accept(EnumDeclaration enumDecl)
 {
 }