Esempio n. 1
0
    //> DoParseRange

    //< DoRepetition {{used-repetition}}
    private State DoRepetition(State state, List <Result> results, int min, int max, ParseMethod method)
    {
        int startIndex = state.Index;

        int count = 0;

        while (count <= max)
        {
            State temp = method(state, results);
            if (temp.Parsed && temp.Index > state.Index)
            {
                state = temp;
                ++count;
            }
            else
            {
                if (count >= min && count <= max)
                {
                    state = new State(state.Index, true);
                }
                break;
            }
        }

        if (count < min || count > max)
        {
            state = new State(startIndex, false);
        }
        return(state);
    }
Esempio n. 2
0
    private State DoRepetition(State state, List <Result> results, int min, int max, ParseMethod method)
    {
        State start = state;

        int count = 0;

        while (count <= max)
        {
            State temp = method(state, results);
            if (temp.Parsed && temp.Index > state.Index)
            {
                state = temp;
                ++count;
            }
            else
            {
                state = new State(state.Index, true, ErrorSet.Combine(state.Errors, temp.Errors));
                break;
            }
        }

        if (count < min || count > max)
        {
            state = new State(start.Index, false, ErrorSet.Combine(start.Errors, state.Errors));
        }

        return(state);
    }
Esempio n. 3
0
        //---------------------------------------------------------------------

        /// <summary>
        /// Registers a method to parse a word for a value of a specific type.
        /// </summary>
        public static void Register <T>(ParseMethod <T> method)
        {
            Register <T>(new ParseMethodWrapper <T>(method).Read);
            string typeFullName = typeof(T).FullName;

            parseMethods[typeFullName] = method;
        }
 public void Build(ParseMethod method) {
   _stateHash.Clear();
   Stopwatch sw = new Stopwatch();
   sw.Start(); 
   var i1 = sw.ElapsedMilliseconds;
   Data = _language.ParserData = new ParserData(_language.Grammar, method);
   CheckPrecedenceSettings(_language.GrammarData, method); 
   var i2 = sw.ElapsedMilliseconds;
   var i3 = sw.ElapsedMilliseconds;
   CreateLalrParserStates(); 
   var i4 = sw.ElapsedMilliseconds;
   //TODO: move all the following to a single method
   //ComputeTransitionIncludesAndItemLookbacks();  //5 ms
   var i5 = sw.ElapsedMilliseconds;
   PropagateTransitionsIncludes(0);               //220 ms
   var i6 = sw.ElapsedMilliseconds;
   //ComputeTransitionsSources(0); 
   var i7 = sw.ElapsedMilliseconds;
   ComputeLookaheads(); 
   var i8 = sw.ElapsedMilliseconds;
   var i9 = sw.ElapsedMilliseconds;
   ComputeAndResolveConflicts();
   var i10 = sw.ElapsedMilliseconds;
   var i11 = sw.ElapsedMilliseconds;
   var i12 = sw.ElapsedMilliseconds;
   if (Data.ParseMethod == ParseMethod.Nlalr) {
     SwitchConflictingStatesToNonCanonicalLookaheads();
   }
   var i13 = sw.ElapsedMilliseconds;
   ReportAndSetDefaultActionsForRemainingConflicts();
   CreateReduceActions();
   ComputeStateExpectedLists(); 
 }//method
 //---------------------------------------------------------------------
 static AgeRangeParsing()
 {
     //  Register the local method for parsing a cohort age or age range.
     InputValues.Register<AgeRange>(ParseAgeOrRange);
     Type.SetDescription<AgeRange>("cohort age or age range");
     uShortParse = InputValues.GetParseMethod<ushort>();
 }
Esempio n. 6
0
        // column by number
        public Boolean ReadZ <T>(String filename, ref T[,] dataZ, ref String fileheader)
        {
            filename = ValidFileOpen(filename);
            if (filename == null)
            {
                return(false);
            }

            try
            {
                TryParseMethod <T> TTryParse = FindTryParse <T>();
                ParseMethod <T>    TParse    = FindParse <T>();

                String[] strData = File.ReadAllLines(filename);
                Int32    firstData; Int32 lastData;

                fileheader = ReadHeaderAndFooter(strData, 1, out firstData, out lastData);
                dataZ      = ReadDataAll <T>(ref strData, TParse, firstData, lastData);
            }

            catch (Exception e)
            {
                MessageBox.Show("Error in " + this.ToString() + ":\n" + e.Message + "\nIn file: " + filename,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
 private void CheckPrecedenceSettings(GrammarData data, ParseMethod method)
 {
     if (!_grammar.UsePrecedenceRestricted)
     {
         // All terms registered with RegisterOperator method already have IsOperator and UsePrecedence flags set.
         // What we need to do is detect non-terminals (like BinOp) that also should be treated as operators
         // in the parser input, and set the UsePrecedence flag on them.
         // We find all non-terminals having all productions either empty or consisting of a single term which is operator
         // It will cover situations when we define non-terminal like 'BinOp.Rule = "+" | "-" | "*" | "/";'
         //  After reducing lookaheads in NLALR BinOp may become a lookahead, and it must be treated as operator
         foreach (NonTerminal nt in data.NonTerminals)
         {
             var isOp = true;
             foreach (var prod in nt.Productions)
             {
                 isOp &= prod.RValues.Count == 0 || prod.RValues.Count == 1 && prod.RValues[0].IsSet(TermOptions.IsOperator);
                 if (!isOp)
                 {
                     break;
                 }
             }//foreac prod
             if (isOp)
             {
                 nt.SetOption(TermOptions.UsePrecedence);
             }
         } //foreach
     }     //else
 }         //method
        //---------------------------------------------------------------------

        static AgeRangeParsing()
        {
            //  Register the local method for parsing a cohort age or age range.
            InputValues.Register <AgeRange>(ParseAgeOrRange);
            Type.SetDescription <AgeRange>("cohort age or age range");
            uShortParse = InputValues.GetParseMethod <ushort>();
        }
Esempio n. 9
0
        // read several columns
        private T[,] ReadDataMany <T>(ref String[] strData, Int32[] colNumbers,
                                      ParseMethod <T> TParse, Int32 firstDataLine, Int32 lastdataline)
        {
            T[,] dataZ = new T[lastdataline - firstDataLine + 1, colNumbers.Length];

            Int32 colNmax = 0;
            Int32 k       = 0;

            for (k = 0; k < colNumbers.Length; k++)
            {
                if (--colNumbers[k] > colNmax)
                {
                    colNmax = colNumbers[k];
                }
            }
            Int32[] si = new Int32[colNmax + 2]; si[0] = 0;

            for (Int32 i = firstDataLine; i <= lastdataline; i++)
            {
                for (k = 1; k <= colNmax + 1; k++)
                {
                    si[k] = strData[i].IndexOfAny(saDelimeters, si[k - 1] + 1);
                }
                if (si[colNmax + 1] == -1)
                {
                    si[colNmax + 1] = strData[i].Length;
                }
                for (k = 0; k < colNumbers.Length; k++)
                {
                    dataZ[i - firstDataLine, k] = TParse(strData[i].Substring(si[colNumbers[k]], si[colNumbers[k] + 1] - si[colNumbers[k]]));
                }
            }
            return(dataZ);
        }
Esempio n. 10
0
        // column by name
        public Boolean ReadY <T>(String filename, ref T[] dataY, ref String fileheader, String colYname)
        {
            filename = ValidFileOpen(filename);
            if (filename == null)
            {
                return(false);
            }

            try
            {
                TryParseMethod <T> TTryParse = FindTryParse <T>();
                ParseMethod <T>    TParse    = FindParse <T>();

                String[] strData = File.ReadAllLines(filename);
                Int32    firstData; Int32 lastData;

                fileheader = ReadHeaderAndFooter(strData, 1, out firstData, out lastData);
                String[] tmpStr = fileheader.Split(saDelimeters, StringSplitOptions.RemoveEmptyEntries);
                Int32    colY   = Array.IndexOf <String>(tmpStr, colYname) + 1;
                if (colY == 0)
                {
                    throw new ArgumentException("Column " + colYname + " not found");
                }
                dataY = ReadDataOne <T>(ref strData, colY, TParse, firstData, lastData);
            }

            catch (Exception e)
            {
                MessageBox.Show("Error in " + this.ToString() + ":\n" + e.Message + "\nIn file: " + filename,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Esempio n. 11
0
    //> DoGetLine

    //< DoNAssert {{used-nassert}}
    private State DoNAssert(State state, List <Result> results, ParseMethod method)
    {
        State temp = method(state, results);

        state = new State(state.Index, !temp.Parsed);

        return(state);
    }
Esempio n. 12
0
 /// <summary> Sets the handler for parsing of the appropriate Message ID. </summary>
 /// <param name="MessageID"> Message ID for parsing. </param>
 /// <param name="ParseMethod"> Method used when incoming packet of <c>MessageID</c> is received. </param>
 public static void SetParseHandler(byte MessageID, ParseMethod ParseMethod)
 {
     if (ParsingHandlers.ContainsKey(MessageID))
     {
         Log.Output(Log.Severity.WARNING, Log.Source.NETWORK, "Parse Method for Packet ID 0x" + MessageID.ToString("X4") + " overridden.");
     }
     ParsingHandlers[MessageID] = ParseMethod;
 }
Esempio n. 13
0
        public Compiler(Grammar grammar, ParseMethod parseMethod)
        {
            var builder = new Construction.LanguageDataBuilder(grammar);

            builder.Build(parseMethod);
            this.Language = builder.Language;
            Parser        = new Parser(Language);
        }
        public ActionResult SearchOnScholar(string Query)
        {
            ParseMethod  parsing = new ParseMethod();
            ListsOfStuff lists   = new ListsOfStuff();

            lists.ScholarArt = parsing.GetScholarArticlesByQuery(Query);
            return(View("SearchOnScholar", lists));
        }
Esempio n. 15
0
 /// <summary> Add a base type to SUCC serialization. It is recommended that you call this method in a static constructor. </summary>
 public static void AddBaseType <T>(SerializeMethod <T> serializeMethod, ParseMethod <T> parseMethod)
 {
     AddBaseType
     (
         typeof(T),
         (object obj) => serializeMethod((T)obj),
         (string text) => parseMethod.Invoke(text)
     );
 }
Esempio n. 16
0
        /// <summary>
        /// Transforme un objet dans le type attendu
        /// </summary>
        /// <typeparam name="T">Type attendu</typeparam>
        /// <param name="readerValue">objet source</param>
        /// <param name="p_oMethod">Méthode de conversion à utiliser</param>
        /// <returns>object convertit</returns>
        public static T To <T>(object readerValue, ParseMethod <T> p_oMethod)
        {
            if (readerValue == DBNull.Value)
            {
                return(default(T));
            }

            return(p_oMethod(readerValue.ToString()));
        }
Esempio n. 17
0
        private static void AddBaseType(Type type, SerializeMethod serializeMethod, ParseMethod parseMethod)
        {
            if (IsBaseType(type))
            {
                throw new Exception($"Type {type} is already a supported base type. You cannot re-add it.");
            }

            BaseSerializeMethods.Add(type, serializeMethod);
            BaseParseMethods.Add(type, parseMethod);
        }
        public void Init()
        {
            intParseMethod  = new ParseMethod <int>(int.Parse);
            intParseWrapper = new ParseMethodWrapper <int>(intParseMethod);

            intValues = new int[] { -4, 78900, 0, 555 };
            string[] intsAsStrs = Array.ConvertAll(intValues,
                                                   new Converter <int, string>(Convert.ToString));
            intValuesAsStr = string.Join(" ", intsAsStrs);
        }
Esempio n. 19
0
        //---------------------------------------------------------------------

        static InputParametersParser()
        {
            // FIXME: Hack to ensure that Percentage is registered with InputValues
            Edu.Wisc.Forest.Flel.Util.Percentage p = new Edu.Wisc.Forest.Flel.Util.Percentage();

            //  Register the local method for parsing a cohort age or age range.
            InputValues.Register <AgeRange>(ParseAgeOrRange);
            Type.SetDescription <AgeRange>("cohort age or age range");
            uShortParse = InputValues.GetParseMethod <ushort>();
        }
Esempio n. 20
0
 public MethodDescriptor(string n, uint i, ParseMethod parseMethod)
 {
     this.name          = n;
     this.id            = i;
     this.m_parseMethod = parseMethod;
     if (this.m_parseMethod == null)
     {
         BattleNet.Log.LogError("MethodDescriptor called with a null method type!");
     }
 }
        public void Init()
        {
            intParseMethod = new ParseMethod<int>(int.Parse);
            intParseWrapper = new ParseMethodWrapper<int>(intParseMethod);

            intValues = new int[] { -4, 78900, 0, 555 };
            string[] intsAsStrs = Array.ConvertAll(intValues,
                                                   new Converter<int, string>(Convert.ToString));
            intValuesAsStr = string.Join(" ", intsAsStrs);
        }
Esempio n. 22
0
 private static T[] CastArgsToArray <T>(string[] args, ParseMethod <T> method)
 {
     T[] values = new T[args.Length];
     for (int i = 0; i < args.Length; i++)
     {
         try {
             values[i] = method(args[i]);
         } catch (System.Exception) {
             throw new System.Exception("Argument " + args[i] + " Cannot be converted to " + typeof(T));
         }
     }
     return(values);
 }
Esempio n. 23
0
        // columns by name
        public Boolean ReadXY <T>(String filename, ref T[] dataX, ref T[] dataY, ref String fileheader, String colXname, String colYname)
        {
            filename = ValidFileOpen(filename);
            if (filename == null)
            {
                return(false);
            }

            try
            {
                TryParseMethod <T> TTryParse = FindTryParse <T>();
                ParseMethod <T>    TParse    = FindParse <T>();

                String[] strData = File.ReadAllLines(filename);
                Int32    firstData; Int32 lastData;

                fileheader = ReadHeaderAndFooter(strData, 2, out firstData, out lastData);
                String[] tmpStr = fileheader.Split(saDelimeters, StringSplitOptions.RemoveEmptyEntries);
                Int32    colX   = Array.IndexOf <String>(tmpStr, colXname) + 1;
                if (colX == 0)
                {
                    throw new ArgumentException("Column \"" + colXname + "\" not found");
                }
                Int32 colY = Array.IndexOf <String>(tmpStr, colYname) + 1;
                if (colY == 0)
                {
                    throw new ArgumentException("Column \"" + colYname + "\" not found");
                }

                T[,] dataXY = ReadDataMany <T>(ref strData, new Int32[] { colX, colY }, TParse, firstData, lastData);

                dataX = new T[dataXY.GetLength(0)];
                dataY = new T[dataXY.GetLength(0)];
                for (Int32 i = 0; i < dataXY.GetLength(0); i++)
                {
                    dataX[i] = dataXY[i, 0];
                }
                for (Int32 i = 0; i < dataXY.GetLength(0); i++)
                {
                    dataY[i] = dataXY[i, 1];
                }
            }

            catch (Exception e)
            {
                MessageBox.Show("Error in " + this.ToString() + ":\n" + e.Message + "\nIn file: " + filename,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
        IWpfTextView CreateTextView(ITextBuffer textBuffer, string navCode, ParseMethod parseMethod) {

            var buffer= _textBufferFactoryService.CreateTextBuffer(navCode, textBuffer.ContentType);

            ParserService.SetParseMethod(buffer, parseMethod);

            var roles = _textEditorFactoryService.CreateTextViewRoleSet(CodeContentTextViewRole);
            var view  = _textEditorFactory.CreateTextView(buffer, roles);

            view.Background = Brushes.Transparent;
            view.ZoomLevel *= 0.75;

            view.SizeToFit();

            return view;
        }
Esempio n. 25
0
        IWpfTextView CreateTextView(ITextBuffer textBuffer, string navCode, ParseMethod parseMethod)
        {
            var buffer = _textBufferFactoryService.CreateTextBuffer(navCode, textBuffer.ContentType);

            ParserService.ParserService.SetParseMethod(buffer, parseMethod);

            var roles = _textEditorFactoryService.CreateTextViewRoleSet(CodeContentTextViewRole);
            var view  = _textEditorFactory.CreateTextView(buffer, roles);

            view.Background = Brushes.Transparent;
            view.ZoomLevel *= 0.75;

            view.PrepareSizeToFit();

            return(view);
        }
Esempio n. 26
0
    public static void Parse(TextAsset asset, ParseMethod parseCellValue)
    {
        if (asset != null)
        {
            var rows = asset.text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            for (int y = 0; y < rows.Length; y++)
            {
                var cellValues = rows[y].Split(new char[] { ',', '\t' }, StringSplitOptions.RemoveEmptyEntries);

                for (int x = 0; x < cellValues.Length; x++)
                {
                    parseCellValue(cellValues[x].Trim(), x, y);
                }
            }
        }
    }
 public void Build(ParseMethod method) {
   if (_grammar.Root == null) {
     Language.Errors.Add("Root property of the grammar is not set.");
     return;
   }
   var gbld = new GrammarDataBuilder(Language);
   gbld.Build();
   //Just in case grammar author wants to customize something...
   _grammar.OnGrammarDataConstructed(Language);
   var sbld = new ScannerDataBuilder(Language);
   sbld.Build();
   var pbld = new ParserDataBuilder(Language);
   pbld.Build(method);
   Validate(); 
   //call grammar method, a chance to tweak the automaton
   _grammar.OnParserDataConstructed(Language); 
 }
        public ActionResult DownloadBibTeX(string title, string info, string reference)
        {
            ParseMethod parser = new ParseMethod();
            string      path   = @"c:\bibFiles";
            //string path = directory + "\\BibFiles";
            string bibDescr = parser.FormBibTeX(info, title, reference);
            string name     = parser.FormBibTeXName(info, title);

            Directory.CreateDirectory(path);
            path += "\\" + name + ".bib";
            if (!System.IO.File.Exists(path))
            {
                using (StreamWriter sw = System.IO.File.CreateText(path))
                    sw.WriteLine(bibDescr);
            }

            return(Redirect("/Home/Finish"));
        }
        public ActionResult AddArticle(string title, string info, string reference, string username)
        {
            ParseMethod parser    = new ParseMethod();
            string      authors   = parser.GetAuthors(info);
            string      year      = parser.GetYear(info);
            string      journal   = parser.GetJournal(info);
            string      publisher = parser.GetPublisher(info);

            Article art = new Article {
                title = title, author = authors, year = year, journal = journal, publisher = publisher
            };

            art.Type     = "Article";
            art.UserName = username;
            db.Articles.Add(art);
            db.SaveChanges();

            return(Redirect("/Home/Finish"));
        }
        public void Build(ParseMethod method)
        {
            _stateHash.Clear();
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var i1 = sw.ElapsedMilliseconds;

            Data = _language.ParserData = new ParserData(_language.Grammar, method);
            CheckPrecedenceSettings(_language.GrammarData, method);
            var i2 = sw.ElapsedMilliseconds;
            var i3 = sw.ElapsedMilliseconds;

            CreateLalrParserStates();
            var i4 = sw.ElapsedMilliseconds;
            //TODO: move all the following to a single method
            //ComputeTransitionIncludesAndItemLookbacks();  //5 ms
            var i5 = sw.ElapsedMilliseconds;

            PropagateTransitionsIncludes(0);         //220 ms
            var i6 = sw.ElapsedMilliseconds;
            //ComputeTransitionsSources(0);
            var i7 = sw.ElapsedMilliseconds;

            ComputeLookaheads();
            var i8 = sw.ElapsedMilliseconds;
            var i9 = sw.ElapsedMilliseconds;

            ComputeAndResolveConflicts();
            var i10 = sw.ElapsedMilliseconds;
            var i11 = sw.ElapsedMilliseconds;
            var i12 = sw.ElapsedMilliseconds;

            if (Data.ParseMethod == ParseMethod.Nlalr)
            {
                SwitchConflictingStatesToNonCanonicalLookaheads();
            }
            var i13 = sw.ElapsedMilliseconds;

            ReportAndSetDefaultActionsForRemainingConflicts();
            CreateReduceActions();
            ComputeStateExpectedLists();
        }//method
Esempio n. 31
0
    private void CheckPrecedenceSettings(GrammarData data, ParseMethod method) {
      if(!_grammar.UsePrecedenceRestricted) {
        // All terms registered with RegisterOperator method already have IsOperator and UsePrecedence flags set. 
        // What we need to do is detect non-terminals (like BinOp) that also should be treated as operators 
        // in the parser input, and set the UsePrecedence flag on them.
        // We find all non-terminals having all productions either empty or consisting of a single term which is operator
        // It will cover situations when we define non-terminal like 'BinOp.Rule = "+" | "-" | "*" | "/";'
        //  After reducing lookaheads in NLALR BinOp may become a lookahead, and it must be treated as operator
        foreach (NonTerminal nt in data.NonTerminals) {
          var isOp = true;
          foreach (var prod in nt.Productions) {
            isOp &= prod.RValues.Count == 0 || prod.RValues.Count == 1 && prod.RValues[0].IsSet(TermOptions.IsOperator);
            if (!isOp) break;
          }//foreac prod
          if (isOp)
            nt.SetOption(TermOptions.UsePrecedence);
        }//foreach 

      }//else
    }//method
Esempio n. 32
0
        // columns by number
        public Boolean ReadXY <T>(String filename, ref T[] dataX, ref T[] dataY, ref String fileheader, Int32 colX, Int32 colY)
        {
            filename = ValidFileOpen(filename);
            if (filename == null)
            {
                return(false);
            }

            try
            {
                TryParseMethod <T> TTryParse = FindTryParse <T>();
                ParseMethod <T>    TParse    = FindParse <T>();

                String[] strData = File.ReadAllLines(filename);
                Int32    firstData; Int32 lastData;

                fileheader = ReadHeaderAndFooter(strData, colY, out firstData, out lastData);

                T[,] dataXY = ReadDataMany <T>(ref strData, new Int32[] { colX, colY }, TParse, firstData, lastData);

                dataX = new T[dataXY.GetLength(0)];
                dataY = new T[dataXY.GetLength(0)];
                for (Int32 i = 0; i < dataXY.GetLength(0); i++)
                {
                    dataX[i] = dataXY[i, 0];
                }
                for (Int32 i = 0; i < dataXY.GetLength(0); i++)
                {
                    dataY[i] = dataXY[i, 1];
                }
            }

            catch (Exception e)
            {
                MessageBox.Show("Error in " + this.ToString() + ":\n" + e.Message + "\nIn file: " + filename,
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Esempio n. 33
0
        public void Build(ParseMethod method)
        {
            if (_grammar.Root == null)
            {
                Language.Errors.Add("Root property of the grammar is not set.");
                return;
            }
            var gbld = new GrammarDataBuilder(Language);

            gbld.Build();
            //Just in case grammar author wants to customize something...
            _grammar.OnGrammarDataConstructed(Language);
            var sbld = new ScannerDataBuilder(Language);

            sbld.Build();
            var pbld = new ParserDataBuilder(Language);

            pbld.Build(method);
            Validate();
            //call grammar method, a chance to tweak the automaton
            _grammar.OnParserDataConstructed(Language);
        }
Esempio n. 34
0
        public static IEnumerable <string[]> ParseData(string Data, ParseMethod ParsingMethod)
        {
            switch (ParsingMethod)
            {
            default:
            case ParseMethod.CSV:
                foreach (string[] s in ParseCSV(Data))
                {
                    yield return(s);
                }
                break;

            case ParseMethod.TSV:
                foreach (string line in IterateLines(Data))
                {
                    yield return((from Match m
                                  in Regex.Matches(line, TSV_REGEX, RegexOptions.ExplicitCapture)
                                  select m.Groups[1].Value
                                  ).Select(s => s.Replace("\"\"", "\"")).ToArray());
                }
                break;
            }
        }
Esempio n. 35
0
        // read one column
        private T[] ReadDataOne <T>(ref String[] strData, Int32 colY,
                                    ParseMethod <T> TParse, Int32 firstDataLine, Int32 lastdataline)
        {
            T[] dataY = new T[lastdataline - firstDataLine + 1];
            colY--;

            Int32 i0 = 0; Int32 i1; Int32 k;

            for (Int32 i = firstDataLine; i <= lastdataline; i++)
            {
                for (k = 0; k < colY; k++)
                {
                    i0 = strData[i].IndexOfAny(saDelimeters, 0);
                }
                i1 = strData[i].IndexOfAny(saDelimeters, i0 + 1);
                if (i1 == -1)
                {
                    i1 = strData[i].Length;
                }
                dataY[i - firstDataLine] = TParse(strData[i].Substring(i0, i1 - i0));
            }
            return(dataY);
        }
Esempio n. 36
0
        // read all columns
        private T[,] ReadDataAll <T>(ref String[] strData,
                                     ParseMethod <T> TParse, Int32 firstDataLine, Int32 lastdataline)
        {
            Int32 colNmax = strData[firstDataLine].Split(saDelimeters, StringSplitOptions.RemoveEmptyEntries).Length - 1;

            T[,] dataZ = new T[lastdataline - firstDataLine + 1, colNmax + 1];

            Int32 k = 0;

            Int32[] si = new Int32[colNmax + 2]; si[0] = 0;
            for (Int32 i = firstDataLine; i <= lastdataline; i++)
            {
                for (k = 1; k <= colNmax; k++)
                {
                    si[k] = strData[i].IndexOfAny(saDelimeters, si[k - 1] + 1);
                }
                si[colNmax + 1] = strData[i].Length;
                for (k = 0; k <= colNmax; k++)
                {
                    dataZ[i - firstDataLine, k] = TParse(strData[i].Substring(si[k], si[k + 1] - si[k]));
                }
            }
            return(dataZ);
        }
Esempio n. 37
0
 private void OnLostFocus(TextBox textBox, ParseMethod parseMethod)
 {
     return;
     if (String.IsNullOrEmpty(textBox.Text))
     {
         return;
     }
     string message;
     if (parseMethod(out message))
     {
         return;
     }
     //Guide.BeginShowMessageBox(" ", message, new[] { "ok" }, 0, MessageBoxIcon.Error, new AsyncCallback(OnMessageBoxAction), null);
     Dispatcher.BeginInvoke(() =>
         MessageBox.Show(message)
         //textBox.Focus();
     );
 }
 public static void SetParseMethod(ITextBuffer textBuffer, ParseMethod parseMethod) {
     textBuffer.Properties.AddProperty(ParseMethodKey, parseMethod);
 }
 //---------------------------------------------------------------------
 static InputValidation()
 {
     parseInt = InputValues.GetParseMethod<int>();
 }
 public ContentControl CreateContentControlForQuickInfo(ITextBuffer textBuffer, string navCode, ParseMethod parseMethod) {
     return new CodePreviewControl(() => CreateTextView(textBuffer, navCode, parseMethod));
 }