コード例 #1
0
        private void InitTableStack()
        {
            tstack.AddSymbol(new Symbols.INT("int", 0, 0));
            tstack.AddSymbol(new Symbols.CHAR("char", 0, 0));
            tstack.AddSymbol(new Symbols.DOUBLE("double", 0, 0));
            tstack.AddSymbol(new Symbols.VOID("void", 0, 0));


            Symbols.ExternFunc f   = new Symbols.ExternFunc("printf");
            Symbols.GlobalVar  v   = new Symbols.GlobalVar("printf", 0, 0);
            Symbols.ParamVar   str = new Symbols.ParamVar();
            v.SetType(f);
            str.SetType(new Symbols.POINTER(new Symbols.CHAR()));
            f.AddArgument(str);
            f.SetUnspecifiedArgs();
            tstack.AddSymbol(v);

            f = new Symbols.ExternFunc("scanf");
            v = new Symbols.GlobalVar("scanf", 0, 0);
            v.SetType(f);
            f.AddArgument(str);
            f.SetUnspecifiedArgs();
            tstack.AddSymbol(v);

            f = new Symbols.ExternFunc("getchar");
            v = new Symbols.GlobalVar("getchar", 0, 0);
            v.SetType(f);
            f.SetType(new Symbols.INT());
            tstack.AddSymbol(v);
        }
コード例 #2
0
ファイル: Parser.cs プロジェクト: khomyakov42/Compiler
        private void InitTableStack()
        {
            tstack.AddSymbol(new Symbols.INT("int", 0, 0));
            tstack.AddSymbol(new Symbols.CHAR("char", 0, 0));
            tstack.AddSymbol(new Symbols.DOUBLE("double", 0, 0));
            tstack.AddSymbol(new Symbols.VOID("void", 0, 0));

            Symbols.ExternFunc f = new Symbols.ExternFunc("printf");
            Symbols.GlobalVar v = new Symbols.GlobalVar("printf", 0, 0);
            Symbols.ParamVar str = new Symbols.ParamVar();
            v.SetType(f);
            str.SetType(new Symbols.POINTER(new Symbols.CHAR()));
            f.AddArgument(str);
            f.SetUnspecifiedArgs();
            tstack.AddSymbol(v);

            f = new Symbols.ExternFunc("scanf");
            v = new Symbols.GlobalVar("scanf", 0, 0);
            v.SetType(f);
            f.AddArgument(str);
            f.SetUnspecifiedArgs();
            tstack.AddSymbol(v);

            f = new Symbols.ExternFunc("getchar");
            v = new Symbols.GlobalVar("getchar", 0, 0);
            v.SetType(f);
            f.SetType(new Symbols.INT());
            tstack.AddSymbol(v);
        }