// $ANTLR start "kstat"
    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:908:1: kstat : ( kforStat -> {$kforStat.st} | kexpr ';' -> statement(expr=$kexpr.st) | kkblock -> statementList(locals=$slist::localsstats=$slist::stats) | kassignStat ';' -> {$kassignStat.st} | kselection_statement -> {$kselection_statement.st} | kprint_statement ';' -> {$kprint_statement.st} | kwhile_statement -> {$kwhile_statement.st} | kreturn_statement ';' -> {$kreturn_statement.st} | kfunc_call -> {$kfunc_call.st} | kvariable -> {$kvariable.st} | ';' -> {new StringTemplate(\";\")});
    public C2CUDATranslatorParser.kstat_return kstat() // throws RecognitionException [1]
    {   
        slist_stack.Push(new slist_scope());

        C2CUDATranslatorParser.kstat_return retval = new C2CUDATranslatorParser.kstat_return();
        retval.Start = input.LT(1);

        C2CUDATranslatorParser.kforStat_return kforStat131 = default(C2CUDATranslatorParser.kforStat_return);

        C2CUDATranslatorParser.kexpr_return kexpr132 = default(C2CUDATranslatorParser.kexpr_return);

        C2CUDATranslatorParser.kassignStat_return kassignStat133 = default(C2CUDATranslatorParser.kassignStat_return);

        C2CUDATranslatorParser.kselection_statement_return kselection_statement134 = default(C2CUDATranslatorParser.kselection_statement_return);

        C2CUDATranslatorParser.kprint_statement_return kprint_statement135 = default(C2CUDATranslatorParser.kprint_statement_return);

        C2CUDATranslatorParser.kwhile_statement_return kwhile_statement136 = default(C2CUDATranslatorParser.kwhile_statement_return);

        C2CUDATranslatorParser.kreturn_statement_return kreturn_statement137 = default(C2CUDATranslatorParser.kreturn_statement_return);

        C2CUDATranslatorParser.kfunc_call_return kfunc_call138 = default(C2CUDATranslatorParser.kfunc_call_return);

        C2CUDATranslatorParser.kvariable_return kvariable139 = default(C2CUDATranslatorParser.kvariable_return);



          ((slist_scope)slist_stack.Peek()).locals =  new ArrayList();
          ((slist_scope)slist_stack.Peek()).stats =  new ArrayList();

        try 
    	{
            // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:914:5: ( kforStat -> {$kforStat.st} | kexpr ';' -> statement(expr=$kexpr.st) | kkblock -> statementList(locals=$slist::localsstats=$slist::stats) | kassignStat ';' -> {$kassignStat.st} | kselection_statement -> {$kselection_statement.st} | kprint_statement ';' -> {$kprint_statement.st} | kwhile_statement -> {$kwhile_statement.st} | kreturn_statement ';' -> {$kreturn_statement.st} | kfunc_call -> {$kfunc_call.st} | kvariable -> {$kvariable.st} | ';' -> {new StringTemplate(\";\")})
            int alt70 = 11;
            alt70 = dfa70.Predict(input);
            switch (alt70) 
            {
                case 1 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:914:7: kforStat
                    {
                    	PushFollow(FOLLOW_kforStat_in_kstat5113);
                    	kforStat131 = kforStat();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 914:16: -> {$kforStat.st}
                    	{
                    	    retval.ST = ((kforStat131 != null) ? kforStat131.ST : null);
                    	}


                    }
                    break;
                case 2 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:916:7: kexpr ';'
                    {
                    	PushFollow(FOLLOW_kexpr_in_kstat5126);
                    	kexpr132 = kexpr();
                    	state.followingStackPointer--;

                    	Match(input,19,FOLLOW_19_in_kstat5128); 


                    	// TEMPLATE REWRITE
                    	// 916:17: -> statement(expr=$kexpr.st)
                    	{
                    	    retval.ST = templateLib.GetInstanceOf("statement",
                    	  new STAttrMap().Add("expr", ((kexpr132 != null) ? kexpr132.ST : null)));
                    	}


                    }
                    break;
                case 3 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:917:7: kkblock
                    {
                    	PushFollow(FOLLOW_kkblock_in_kstat5145);
                    	kkblock();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 917:15: -> statementList(locals=$slist::localsstats=$slist::stats)
                    	{
                    	    retval.ST = templateLib.GetInstanceOf("statementList",
                    	  new STAttrMap().Add("locals", ((slist_scope)slist_stack.Peek()).locals).Add("stats", ((slist_scope)slist_stack.Peek()).stats));
                    	}


                    }
                    break;
                case 4 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:918:7: kassignStat ';'
                    {
                    	PushFollow(FOLLOW_kassignStat_in_kstat5167);
                    	kassignStat133 = kassignStat();
                    	state.followingStackPointer--;

                    	Match(input,19,FOLLOW_19_in_kstat5169); 
                    	 if(((kassignStat133 != null) ? kassignStat133.ST : null).ToString().Contains("[") && (((kassignStat133 != null) ? kassignStat133.ST : null).ToString().Contains("]")) && (((kassignStat133 != null) ? kassignStat133.ST : null).ToString().IndexOf("[")!=((kassignStat133 != null) ? kassignStat133.ST : null).ToString().LastIndexOf("[")) )
                    	    {
                    	   
                    	   
                    	 //   q = ((kassignStat133 != null) ? kassignStat133.ST : null).ToString().LastIndexOf("[");
                    	    
                    	    C2CUDATranslator.Analysis analysis = new C2CUDATranslator.Analysis();
                    	      System.Collections.ArrayList one = new   System.Collections.ArrayList(); 
                    	      System.Collections.ArrayList two = new   System.Collections.ArrayList();
                    	      String temp,temp2;
                    	      temp = ((kassignStat133 != null) ? kassignStat133.ST : null).ToString().Substring(0,((kassignStat133 != null) ? kassignStat133.ST : null).ToString().IndexOf("]")+1);
                    	    one = analysis.GetindexofArrayfromassignmentStatement(temp);
                    	    temp2 = ((kassignStat133 != null) ? kassignStat133.ST : null).ToString().Substring(((kassignStat133 != null) ? kassignStat133.ST : null).ToString().IndexOf("]")+1,((kassignStat133 != null) ? kassignStat133.ST : null).ToString().Length-(((kassignStat133 != null) ? kassignStat133.ST : null).ToString().IndexOf("]")+1));
                    	    two = analysis.GetindexofArrayfromassignmentStatement(temp2);

                    	    int n1= ((program_scope)program_stack.Peek()).ReadOnly.Count;
                    	    int n2= ((program_scope)program_stack.Peek()).WriteOnly.Count;
                    	    String temp1="";
                    	    String temp3 = "";
                    	    Boolean flag=false;
                    		
                    	    for(int i=0;i<n1;i++)
                    		{
                    		     for(int j=0;j<n2;j++)
                    		         {
                    		         temp1=((program_scope)program_stack.Peek()).ReadOnly[i].ToString();
                    		         temp2=((program_scope)program_stack.Peek()).WriteOnly[j].ToString();
                    		          if (temp1.Contains("[") && temp2.Contains("["))
                    		             {
                    		              if (String.Compare(temp1, temp) == 0)
                    		              {
                    		              }
                    		              else
                    		              {
                    		                  if (String.Compare(temp1.Substring(0, temp1.IndexOf("[")), temp.Substring(0, temp.IndexOf("["))) == 0)
                    		                  {
                    		                      if (analysis.BenergyTest(one, two))
                    		                      {
                    		                          flag = true;
                    		                      }
                    		                  }
                    		              }
                    		             }
                    		         }
                    		}
                    		
                    	    if(flag)
                    	    {
                    	    
                    	    	Console.WriteLine(((kassignStat133 != null) ? kassignStat133.ST : null).ToString() + " Iterative Dependecy");
                    	    	((program_scope)program_stack.Peek()).iteraiveflag =  true;   
                    	    }
                    	    else
                    	    {
                    	   // Console.WriteLine(((kassignStat133 != null) ? kassignStat133.ST : null).ToString());
                    	    ((program_scope)program_stack.Peek()).iteraiveflag =  false  ;  
                    	       
                    	    }
                    	    }
                    	    else
                    	    {
                    	    	
                    	    }
                    	    


                    	// TEMPLATE REWRITE
                    	// 981:7: -> {$kassignStat.st}
                    	{
                    	    retval.ST = ((kassignStat133 != null) ? kassignStat133.ST : null);
                    	}


                    }
                    break;
                case 5 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:982:7: kselection_statement
                    {
                    	PushFollow(FOLLOW_kselection_statement_in_kstat5185);
                    	kselection_statement134 = kselection_statement();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 982:29: -> {$kselection_statement.st}
                    	{
                    	    retval.ST = ((kselection_statement134 != null) ? kselection_statement134.ST : null);
                    	}


                    }
                    break;
                case 6 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:983:7: kprint_statement ';'
                    {
                    	PushFollow(FOLLOW_kprint_statement_in_kstat5198);
                    	kprint_statement135 = kprint_statement();
                    	state.followingStackPointer--;

                    	Match(input,19,FOLLOW_19_in_kstat5200); 


                    	// TEMPLATE REWRITE
                    	// 983:28: -> {$kprint_statement.st}
                    	{
                    	    retval.ST = ((kprint_statement135 != null) ? kprint_statement135.ST : null);
                    	}


                    }
                    break;
                case 7 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:984:7: kwhile_statement
                    {
                    	PushFollow(FOLLOW_kwhile_statement_in_kstat5214);
                    	kwhile_statement136 = kwhile_statement();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 984:25: -> {$kwhile_statement.st}
                    	{
                    	    retval.ST = ((kwhile_statement136 != null) ? kwhile_statement136.ST : null);
                    	}


                    }
                    break;
                case 8 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:985:7: kreturn_statement ';'
                    {
                    	PushFollow(FOLLOW_kreturn_statement_in_kstat5227);
                    	kreturn_statement137 = kreturn_statement();
                    	state.followingStackPointer--;

                    	Match(input,19,FOLLOW_19_in_kstat5229); 


                    	// TEMPLATE REWRITE
                    	// 985:29: -> {$kreturn_statement.st}
                    	{
                    	    retval.ST = ((kreturn_statement137 != null) ? kreturn_statement137.ST : null);
                    	}


                    }
                    break;
                case 9 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:986:7: kfunc_call
                    {
                    	PushFollow(FOLLOW_kfunc_call_in_kstat5241);
                    	kfunc_call138 = kfunc_call();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 986:18: -> {$kfunc_call.st}
                    	{
                    	    retval.ST = ((kfunc_call138 != null) ? kfunc_call138.ST : null);
                    	}


                    }
                    break;
                case 10 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:989:7: kvariable
                    {
                    	PushFollow(FOLLOW_kvariable_in_kstat5255);
                    	kvariable139 = kvariable();
                    	state.followingStackPointer--;



                    	// TEMPLATE REWRITE
                    	// 989:18: -> {$kvariable.st}
                    	{
                    	    retval.ST = ((kvariable139 != null) ? kvariable139.ST : null);
                    	}


                    }
                    break;
                case 11 :
                    // Z:\\C2CUDATranslator\\C2CUDATranslator\\C2CUDATranslator.g:990:7: ';'
                    {
                    	Match(input,19,FOLLOW_19_in_kstat5268); 


                    	// TEMPLATE REWRITE
                    	// 990:11: -> {new StringTemplate(\";\")}
                    	{
                    	    retval.ST = new StringTemplate(";");
                    	}


                    }
                    break;

            }
            retval.Stop = input.LT(-1);

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
            slist_stack.Pop();

        }
        return retval;
    }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                string inputFileName;
                string templateFileName;

                if ((args.Length == 1) || (args.Length == 2))
                {
                    if (args.Length == 1)
                    {
                        templateFileName = "CUDAC.stg";
                        inputFileName = args[0];
                    }
                    else
                    {
                        templateFileName = args[0];
                        inputFileName = args[1];
                    }

                    if (!Path.IsPathRooted(templateFileName))
                    {
                        //templateFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, templateFileName);
                        templateFileName = Path.Combine(Environment.CurrentDirectory, templateFileName);
                    }
                    if (!Path.IsPathRooted(inputFileName))
                    {
                        inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
                    }

                    templates = new StringTemplateGroup(new StreamReader(templateFileName),
                                        typeof(AngleBracketTemplateLexer));
                    templates2 = new StringTemplateGroup(new StreamReader("CUDAPattern.stg"),
                                        typeof(AngleBracketTemplateLexer));
                    templates3 = new StringTemplateGroup(new StreamReader("CUDACkernel.stg"),
                                       typeof(AngleBracketTemplateLexer));

                    //ArrayList one=new ArrayList();
                    //one.Add("i");
                    ////one.Add("+");
                    ////one.Add("1");

                    //ArrayList two = new ArrayList();
                    //two.Add("i");

                    Analysis analysis = new Analysis();
                    //if (analysis.BenergyTest(one, two))
                    //{
                    //    Console.Out.WriteLine("Iterative Dependecy");
                    //}
                    //else
                    //{
                    //    Console.Out.WriteLine("No Dependecy");
                    //}
                    //return;

                    ICharStream input = new ANTLRFileStream(inputFileName);
                    C2CUDATranslatorLexer lexer = new C2CUDATranslatorLexer(input);
                    CommonTokenStream tokens = new CommonTokenStream(lexer);
                    C2CUDATranslatorParser parser = new C2CUDATranslatorParser(tokens);
                    parser.TemplateLib = templates;
                    RuleReturnScope r = parser.program();
                    Console.Out.WriteLine(r.Template.ToString().Replace(@"\/", "/").ToString());
                    // Part 2
                    // Console.Error.WriteLine("Getting Pattern");
                    ICharStream input3 = new ANTLRFileStream(inputFileName);
                    C2CUDATranslatorLexer lexer3 = new C2CUDATranslatorLexer(input3);
                    CommonTokenStream tokens3 = new CommonTokenStream(lexer3);
                    C2CUDATranslatorParser parser3 = new C2CUDATranslatorParser(tokens3);
                    parser3.TemplateLib = templates3;
                    RuleReturnScope r3 = parser3.program();

                    ICharStream input2 = new ANTLRStringStream(r3.Template.ToString().Replace("((", "( (").Replace(@"\/", "/").ToString().ToString().Replace("))", ") )").ToString().Replace("){", ") {").ToString().Replace("**", "*").ToString());
                    PatternGeneratorLexer lexer2 = new PatternGeneratorLexer(input2);
                    CommonTokenStream tokens2 = new CommonTokenStream(lexer2);
                    PatternGeneratorParser parser2 = new PatternGeneratorParser(tokens2);
                    parser2.TemplateLib = templates2;
                    RuleReturnScope r2 = parser2.pattern();
                    Console.Error.WriteLine("// Pattern : ");
                    string pattern= r2.Template.ToString();
                    Console.Out.WriteLine("//" + r2.Template.ToString().Replace("\r\n","\r\n//"));

                    //Console.Out.WriteLine("Checking in Database");

                    //string connecstr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;User Instance=True";
                    //SqlConnection con = new SqlConnection(connecstr);
                    //con.Close();
                    //con.Open();
                    //String sql = "Select * from PatternDatabase";
                    //DataTable dt = new DataTable();
                    //SqlDataAdapter adp = new SqlDataAdapter(sql,con);
                    //adp.Fill(dt);
                    //bool flag=false ;
                    //for(int i=0;i<dt.Rows.Count -1 ;i++)
                    //{
                    //    if(pattern==dt.Rows[i][1].ToString())
                    //    {
                    //        Console.Out.WriteLine("Found in Database");
                    //        flag =true ;
                    //    }
                    //    else
                    //    {
                    //    }
                    //}
                    //if (flag == true)
                    //{
                    //}
                    //else
                    //{
                    //    sql = "Insert into PatternDatabase values('"+pattern.ToString()+"','"+pattern.ToString()+"')";
                    //    SqlCommand cmd = new SqlCommand(sql, con);
                    //    cmd.ExecuteNonQuery();
                    //    con.Close();
                    //    Console.Out.WriteLine("Not Found in Database But added in database");
                    //}
                    //con.Close();
                    string lines = "group CUDA;\r\n pattern(type,name,args,";

                     string[] p = pattern.ToString().Replace("{", " ").ToString().Replace("}", " ").ToString().Replace("\n", ",").Replace(@"\/", "/").ToString().Substring(34, pattern.Length - 34).ToString().Split(',');
                    for (int i = 0;i< p.Length  -1; i++)
                    {
                        if (p[i].ToString().Trim() != "")
                        {
                            lines = lines + p[i].ToString().Trim() + ",\r\n";
                        }
                    }
                    lines = lines + ") ::= << " + "\r\n" + "<type> <name>(<args; separator=\"\\n\">) {" + "\r\n";

                    for (int i = 0;i< p.Length  -1; i++)
                    {
                        if (p[i].ToString().Trim() != "")
                        {
                            lines = lines + " <" + p[i].ToString().Trim() + ">" + "\r\n";
                        }
                    }
                    lines = lines + ">>";
                    System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.stg");
                    file.WriteLine(lines);

                    file.Close();

                    Console.ReadLine();

                }
                else
                    Console.Error.WriteLine("Usage: C2CUDATranslator [<output-template-file>] <input-file>");
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine("exception: " + e);
                Console.Error.WriteLine(e.StackTrace);
                Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                string inputFileName;
                string templateFileName;

                if ((args.Length == 1) || (args.Length == 2))
                {
                    if (args.Length == 1)
                    {
                        templateFileName = "CUDAC.stg";
                        inputFileName    = args[0];
                    }
                    else
                    {
                        templateFileName = args[0];
                        inputFileName    = args[1];
                    }


                    if (!Path.IsPathRooted(templateFileName))
                    {
                        //templateFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, templateFileName);
                        templateFileName = Path.Combine(Environment.CurrentDirectory, templateFileName);
                    }
                    if (!Path.IsPathRooted(inputFileName))
                    {
                        inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
                    }

                    templates = new StringTemplateGroup(new StreamReader(templateFileName),
                                                        typeof(AngleBracketTemplateLexer));
                    templates2 = new StringTemplateGroup(new StreamReader("CUDAPattern.stg"),
                                                         typeof(AngleBracketTemplateLexer));
                    templates3 = new StringTemplateGroup(new StreamReader("CUDACkernel.stg"),
                                                         typeof(AngleBracketTemplateLexer));

                    //ArrayList one=new ArrayList();
                    //one.Add("i");
                    ////one.Add("+");
                    ////one.Add("1");

                    //ArrayList two = new ArrayList();
                    //two.Add("i");

                    Analysis analysis = new Analysis();
                    //if (analysis.BenergyTest(one, two))
                    //{
                    //    Console.Out.WriteLine("Iterative Dependecy");
                    //}
                    //else
                    //{
                    //    Console.Out.WriteLine("No Dependecy");
                    //}
                    //return;

                    ICharStream            input  = new ANTLRFileStream(inputFileName);
                    C2CUDATranslatorLexer  lexer  = new C2CUDATranslatorLexer(input);
                    CommonTokenStream      tokens = new CommonTokenStream(lexer);
                    C2CUDATranslatorParser parser = new C2CUDATranslatorParser(tokens);
                    parser.TemplateLib = templates;
                    RuleReturnScope r = parser.program();
                    Console.Out.WriteLine(r.Template.ToString().Replace(@"\/", "/").ToString());
                    // Part 2
                    // Console.Error.WriteLine("Getting Pattern");
                    ICharStream            input3  = new ANTLRFileStream(inputFileName);
                    C2CUDATranslatorLexer  lexer3  = new C2CUDATranslatorLexer(input3);
                    CommonTokenStream      tokens3 = new CommonTokenStream(lexer3);
                    C2CUDATranslatorParser parser3 = new C2CUDATranslatorParser(tokens3);
                    parser3.TemplateLib = templates3;
                    RuleReturnScope r3 = parser3.program();


                    ICharStream            input2  = new ANTLRStringStream(r3.Template.ToString().Replace("((", "( (").Replace(@"\/", "/").ToString().ToString().Replace("))", ") )").ToString().Replace("){", ") {").ToString().Replace("**", "*").ToString());
                    PatternGeneratorLexer  lexer2  = new PatternGeneratorLexer(input2);
                    CommonTokenStream      tokens2 = new CommonTokenStream(lexer2);
                    PatternGeneratorParser parser2 = new PatternGeneratorParser(tokens2);
                    parser2.TemplateLib = templates2;
                    RuleReturnScope r2 = parser2.pattern();
                    Console.Error.WriteLine("// Pattern : ");
                    string pattern = r2.Template.ToString();
                    Console.Out.WriteLine("//" + r2.Template.ToString().Replace("\r\n", "\r\n//"));


                    //Console.Out.WriteLine("Checking in Database");

                    //string connecstr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Database1.mdf;Integrated Security=True;User Instance=True";
                    //SqlConnection con = new SqlConnection(connecstr);
                    //con.Close();
                    //con.Open();
                    //String sql = "Select * from PatternDatabase";
                    //DataTable dt = new DataTable();
                    //SqlDataAdapter adp = new SqlDataAdapter(sql,con);
                    //adp.Fill(dt);
                    //bool flag=false ;
                    //for(int i=0;i<dt.Rows.Count -1 ;i++)
                    //{
                    //    if(pattern==dt.Rows[i][1].ToString())
                    //    {
                    //        Console.Out.WriteLine("Found in Database");
                    //        flag =true ;
                    //    }
                    //    else
                    //    {
                    //    }
                    //}
                    //if (flag == true)
                    //{
                    //}
                    //else
                    //{
                    //    sql = "Insert into PatternDatabase values('"+pattern.ToString()+"','"+pattern.ToString()+"')";
                    //    SqlCommand cmd = new SqlCommand(sql, con);
                    //    cmd.ExecuteNonQuery();
                    //    con.Close();
                    //    Console.Out.WriteLine("Not Found in Database But added in database");
                    //}
                    //con.Close();
                    string lines = "group CUDA;\r\n pattern(type,name,args,";

                    string[] p = pattern.ToString().Replace("{", " ").ToString().Replace("}", " ").ToString().Replace("\n", ",").Replace(@"\/", "/").ToString().Substring(34, pattern.Length - 34).ToString().Split(',');
                    for (int i = 0; i < p.Length - 1; i++)
                    {
                        if (p[i].ToString().Trim() != "")
                        {
                            lines = lines + p[i].ToString().Trim() + ",\r\n";
                        }
                    }
                    lines = lines + ") ::= << " + "\r\n" + "<type> <name>(<args; separator=\"\\n\">) {" + "\r\n";

                    for (int i = 0; i < p.Length - 1; i++)
                    {
                        if (p[i].ToString().Trim() != "")
                        {
                            lines = lines + " <" + p[i].ToString().Trim() + ">" + "\r\n";
                        }
                    }
                    lines = lines + ">>";
                    System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.stg");
                    file.WriteLine(lines);

                    file.Close();



                    Console.ReadLine();
                }
                else
                {
                    Console.Error.WriteLine("Usage: C2CUDATranslator [<output-template-file>] <input-file>");
                }
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine("exception: " + e);
                Console.Error.WriteLine(e.StackTrace);
                Console.ReadLine();
            }
        }