예제 #1
0
        static private bool TryGetPath(string location, out string path, out Squiggle span, out string whyFailed)
        {
            // assuming we have @"... ...\... \.cs(a,b-c,d)
            var openBracketPosition = location.LastIndexOf('(');
            int row0 = -1, col0 = -1, row1 = -1, col1 = -1;

            if (openBracketPosition >= 0)
            {
                path = location.Substring(0, openBracketPosition);
                //if (path[0] == 'c') { path = path.Replace("c:\\", "C:\\"); }

                var currSubString = String.Empty;

                var j = GetNext(location, openBracketPosition, ',', out row0); if (j < 0)
                {
                    goto fail;
                }
                j = GetNext(location, j, '-', out col0); if (j < 0)
                {
                    goto fail;
                }
                j = GetNext(location, j, ',', out row1); if (j < 0)
                {
                    goto fail;
                }
                j = GetNext(location, j, ')', out col1); if (j < 0)
                {
                    goto fail;
                }

                span = new Squiggle(row0: row0, col0: col0, row1: row1, col1: col1);

                whyFailed = null;
                return(true);
            }

fail:
            whyFailed = "The source location is invalid";
            span      = default(Squiggle);
            path      = null;
            return(false);
        }
예제 #2
0
파일: Parser.cs 프로젝트: scottcarr/ccbot
    static private bool TryGetPath(string location, out string path, out Squiggle span, out string whyFailed)
    {
      // assuming we have @"... ...\... \.cs(a,b-c,d)
      var openBracketPosition = location.LastIndexOf('(');
      int row0 = -1, col0 = -1, row1 = -1, col1 = -1;
      if (openBracketPosition >= 0)
      {
        path = location.Substring(0, openBracketPosition);
        //if (path[0] == 'c') { path = path.Replace("c:\\", "C:\\"); } 

        var currSubString = String.Empty;

        var j = GetNext(location, openBracketPosition, ',', out row0); if (j < 0) goto fail;
        j = GetNext(location, j, '-', out col0); if (j < 0) goto fail;
        j = GetNext(location, j, ',', out row1); if (j < 0) goto fail;
        j = GetNext(location, j, ')', out col1); if (j < 0) goto fail;

        span = new Squiggle(row0: row0, col0: col0, row1: row1, col1: col1);

        whyFailed = null;
        return true;
      }

    fail:
      whyFailed = "The source location is invalid";
      span = default(Squiggle);
      path = null;
      return false;
    }