コード例 #1
0
ファイル: Statement.cs プロジェクト: jncronin/tymake
            static string pretty_string(string msg, LocationBase e)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append(msg);
                if (e != null)
                {
                    FileInfo fi;
                    if (e.fname == null || ((fi = new FileInfo(e.fname)).Exists == false))
                    {
                        sb.Append(Environment.NewLine + "  at line " + e.sline + ", column " + e.scol);
                    }
                    else
                    {
                        var    f     = new StreamReader(fi.OpenRead());
                        int    cline = 0;
                        string cl    = null;
                        while (cline < e.sline)
                        {
                            cline++;
                            cl = f.ReadLine();
                        }
                        cl = cl.Insert(e.ecol, "^").Insert(e.scol, "^");
                        f.Close();
                        sb.Append(Environment.NewLine + "  at line " + e.sline + ", column " + e.scol + " in " + fi.FullName + ":");
                        sb.Append(Environment.NewLine + "    " + cl);
                    }
                }
                return(sb.ToString());
            }
コード例 #2
0
ファイル: Statement.cs プロジェクト: jncronin/tymake
 public SyntaxException(string msg, LocationBase e) : base(pretty_string(msg, e))
 {
     expr = e;
 }