示例#1
0
文件: Form1.cs 项目: Northcode/NXCODE
        private void buildToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (name != null)
            {
                GetCode();
                Scanner s = new Scanner(code);
                s.Scan();
                tokens = s.Tokens.ToArray();
                TokenList t = new TokenList();
                foreach (Token tk in tokens)
                {
                    t.listBox1.Items.Add(tk.type.ToString() + " : " + tk.val.ToString());
                }
                t.MdiParent = this;
                t.Show();
                if (tokens != null)
                {
                    Parser p = new Parser(tokens);
                    p.Parse();
                    stmts = p.Result;

                    AST_Viewer a = new AST_Viewer();

                    foreach (ISTMT st in stmts)
                    {
                        a.treeView1.Nodes.Add(st.ToNode());
                    }

                    a.MdiParent = this;
                    a.Show();
                }
                StringBuilder asmb = new StringBuilder();
                asmb.AppendLine("call main\n\r");
                asmb.AppendLine("terminate\n\r");
                foreach (ISTMT st in stmts)
                {
                    asmb.Append(st.ToAssembly());
                }
                asmcode = asmb.ToString();
                CodeViewer v = new CodeViewer();
                v.textBox1.Text = asmcode;
                v.MdiParent = this;
                v.Show();
                NXCODE.Assembler asm = new NXCODE.Assembler(name, Environment.UserName, asmcode);
                asm.Assemble();
                asm.Save(name + ".nxe");
            }
        }
示例#2
0
        private void buildToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (name != null)
            {
                GetCode();
                Scanner s = new Scanner(code);
                s.Scan();
                tokens = s.Tokens.ToArray();
                TokenList t = new TokenList();
                foreach (Token tk in tokens)
                {
                    t.listBox1.Items.Add(tk.type.ToString() + " : " + tk.val.ToString());
                }
                t.MdiParent = this;
                t.Show();
                if (tokens != null)
                {
                    Parser p = new Parser(tokens);
                    p.Parse();
                    stmts = p.Result;

                    AST_Viewer a = new AST_Viewer();

                    foreach (ISTMT st in stmts)
                    {
                        a.treeView1.Nodes.Add(st.ToNode());
                    }

                    a.MdiParent = this;
                    a.Show();
                }
                StringBuilder asmb = new StringBuilder();
                asmb.AppendLine("call main\n\r");
                asmb.AppendLine("terminate\n\r");
                foreach (ISTMT st in stmts)
                {
                    asmb.Append(st.ToAssembly());
                }
                asmcode = asmb.ToString();
                CodeViewer v = new CodeViewer();
                v.textBox1.Text = asmcode;
                v.MdiParent     = this;
                v.Show();
                NXCODE.Assembler asm = new NXCODE.Assembler(name, Environment.UserName, asmcode);
                asm.Assemble();
                asm.Save(name + ".nxe");
            }
        }
示例#3
0
        private void generateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder asmb = new StringBuilder();

            asmb.AppendLine("call main\n\r");
            asmb.AppendLine("terminate\n\r");
            foreach (ISTMT s in stmts)
            {
                asmb.Append(s.ToAssembly());
            }
            asmcode = asmb.ToString();
            CodeViewer v = new CodeViewer();

            v.textBox1.Text = asmcode;
            v.MdiParent     = this;
            v.Show();
        }
示例#4
0
文件: Form1.cs 项目: Northcode/NXCODE
 private void generateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     StringBuilder asmb = new StringBuilder();
     asmb.AppendLine("call main\n\r");
     asmb.AppendLine("terminate\n\r");
     foreach (ISTMT s in stmts)
     {
         asmb.Append(s.ToAssembly());
     }
     asmcode = asmb.ToString();
     CodeViewer v = new CodeViewer();
     v.textBox1.Text = asmcode;
     v.MdiParent = this;
     v.Show();
 }