Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string line = "=============================================================";
            IFileReader r = new TextReader("input.txt");
            List<string> listSentences = new List<string>();
            IParser<Text> parser = new TextParser();
            listSentences = r.Read();
            var text = parser.Parse(listSentences);

            ///1 Вывести все предложения заданного текста в порядке возрастания количества слов в каждом из них.
            foreach (var item in text.SortSentences())
            {
                Console.WriteLine(item);
            }
            Console.WriteLine(line);

            ///2 Во всех вопросительных предложениях текста найти и напечатать без повторений слова заданной длины.
            text.FindWordsOfPredeterminedLenght(text, 7);
            Console.WriteLine(line);

            ///3 Из текста удалить все слова заданной длины, начинающиеся на согласную букву.
            text.RemoveWords(7);
            Console.WriteLine(text);
            Console.WriteLine(line);

            ///4 В некотором предложении текста слова заданной длины заменить указанной подстрокой,
            ///длина которой может не совпадать с длиной слова.
            text.ReplaceWords(0, 5, "Vasya");
            Console.WriteLine(text);
            Console.WriteLine(line);

            Console.ReadKey();
        }
Exemplo n.º 2
0
    private static void Main(string[] args)
    {
        if (args.Length != 2)
        {
            Console.WriteLine("Incorrect command line parameters.");
        }
        else
        {
            try
            {
                var allLinesFromText = File.ReadAllLines(args[0]);
                var allLinesFromQueries = File.ReadAllLines(args[1]);

                var textParser = new TextParser(allLinesFromText);
                textParser.ParseText();

                var queries = new Queries(allLinesFromQueries, textParser);
                queries.ProcessAllRequests();
                queries.AllReplies.Print();
            }
            catch (FileNotFoundException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
    }
Exemplo n.º 3
0
        public override void parse(string curLine)
        {
            TextParser tp = new TextParser();
            List<string> words = tp.seperateWords(curLine);

            actor = words[1];

            if (words.Count == 4)
            {
                text = words[2].Substring(1, words[2].Length - 2);
            }

            else
            {

            for (int i = 2; i < words.Count; i++)
            {
                if (words[i].EndsWith(")"))
                {
                    text += words[i].Substring(0, words[i].Length - 1);
                    break;
                }

                if (words[i].StartsWith("("))
                    text += words[i].Substring(1) + " ";

                else
                    text += words[i] + " ";
            }
            }

            animation = words[words.Count - 1];
            actionType = ActionType.Speak;
        }
Exemplo n.º 4
0
 public void Does_GeneratTestFile_When_LineStartsWithGiven()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual(1, p.Tests.Count);
 }
Exemplo n.º 5
0
        public override void parse(string curLine)
        {
            TextParser tp = new TextParser();
            actionType = ActionType.Fade;

            color = ColorUtils.colorFromHexString(curLine.Substring(6, 6));
            color.A = 0;
            time = int.Parse(tp.seperateWords(curLine)[2]);
            Console.WriteLine("Parsed a fade! Color " + color.ToString());
            elapsed = 0;
        }
Exemplo n.º 6
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			ShaderTechnique shader = new ShaderTechnique(this.resourceManager);
			shader.Name = defaultName;
			shader.BasePath = parser.BasePath;

			parser.Consume("CIwGxShaderTechnique");
			parser.Consume("{");
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					shader.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "param")
				{
					this.ParseParam(parser, shader);
					continue;
				}
				if (attribute == "shader")
				{
					parser.Consume();
					attribute = parser.Lexem;
					if (attribute == "vertex")
					{
						this.ParseVertexShader(parser, shader);
					}
					else if (attribute == "fragment")
					{
						this.ParseFragmentShader(parser, shader);
					}
					else
					{
						parser.UnknownLexemError();
					}
					continue;
				}
				parser.UnknownLexemError();
			}
			return shader;
		}
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            string fileName = string.Empty;
            string outputPath = string.Empty;
            ParseArguments(args, out fileName, out outputPath);

            List<string> textSpec = File.ReadAllLines(fileName).ToList();
            TextParser p = new TextParser();
            p.Parse(textSpec);
            foreach (var test in p.Tests)
            {
                string outputFile = Path.Combine(outputPath, String.Format(@"{0}_{1}.cs", test.Given, test.When));
                File.WriteAllText(outputFile, test.ToTestClass());
            }
        }
Exemplo n.º 8
0
        public void Does_GiveTestFileExpectAState_When_ExpectLineEndsWithAState()
        {
            //Arragne
            TextParser p = new TextParser();
            List<string> text = new List<string>() { "subject: subject" };
            text.Add("Given a state");
            text.Add("When an action");
            text.Add("Expect a state");
            text.Add("Expect an action");

            //Act
            p.Parse(text);
            //Assert
            Assert.AreEqual("a_state", p.Tests[0].Expects[0]);
        }
Exemplo n.º 9
0
 public void Does_Create2TestFiles_When_TextContainsMoreLinesStartingWithGiven()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("Expect an action");
     text.Add("Given a state2");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("Expect an action");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual(2, p.Tests.Count);
 }
Exemplo n.º 10
0
 public void Does_GiveFirstTestOnly1Expect_When_ItHasOnlyOneExpect()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("");
     text.Add("Given a state2");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("Expect an action");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual(1, p.Tests.First().Expects.Count);
 }
Exemplo n.º 11
0
        public Scene parseCSL(FileStream location)
        {
            StreamReader file = new StreamReader(location);
            seperator = new TextParser();

            string id;
            string englishName;
            Background background;
            List<Actor> actors;
            List<Event> events = new List<Event>();

            extractHeader(file, out id, out englishName);
            extractActorsAndBackground(file, out background, out actors);
            extractEvents(file, ref events);
            Console.WriteLine("Found all events at parseCSL method! There are " + events.Count);

            return new Scene(id, englishName, events, actors, background);
        }
Exemplo n.º 12
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			AnimSkin skin = this.context.Resolve<AnimSkin>();
			skin.Name = defaultName;
			parser.Consume("CIwAnimSkin");
			parser.Consume("{");

			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					skin.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "skeleton")
				{
					parser.Consume();
					parser.ConsumeResourceReference(skin.Skeleton);
					continue;
				}
				if (attribute == "model")
				{
					parser.Consume();
					parser.ConsumeResourceReference(skin.SkeletonModel);
					continue;
				}
				if (attribute == "CIwAnimSkinSet")
				{
					parser.Consume();
					ParseAnimSkinSet(parser, skin);
					continue;
				}

				parser.UnknownLexemError();
			}
			return skin;
		}
Exemplo n.º 13
0
		private void ParseKeyFrame(TextParser parser, Anim mesh)
		{
			var frame = this.context.Resolve<AnimKeyFrame>();
			parser.Consume("CIwAnimKeyFrame");
			parser.Consume("{");

			AnimBone bone = null;
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "time")
				{
					parser.Consume();
					frame.Time = parser.ConsumeFloat();
					continue;
				}
				if (attribute == "bone")
				{
					parser.Consume();
					bone = frame.Bones[frame.Bones.EnsureItem(parser.ConsumeString())];
					continue;
				}
				if (attribute == "pos")
				{
					parser.Consume();
					bone.BindingPos = parser.ConsumeVector3();
					continue;
				}
				if (attribute == "rot")
				{
					parser.Consume();
					bone.BindingRot = parser.ConsumeQuaternion();
					continue;
				}
				parser.UnknownLexemError();
			}
			mesh.AddFrame(frame);
		}
Exemplo n.º 14
0
        protected void CreateResultsTable()
        {
            string results_table_name;

            try
            {
                if (Method.ToLower() == "disk" || Method.ToLower() == "stream")
                {
                    // Parse the destination table name for commands.
                    results_table_name = TextParser.Parse(DestinationDataTable.Name, DrivingData, SharedData, ModuleCommands);

                    // Check to see if the destination table has already been created and added to the global dataset.
                    if (!SharedData.Data.Contains(results_table_name))
                    {
                        // Make sure the memory management column exist in the destination table.
                        if (!DestinationDataTable.CacheColumnCollection.Contains("_Memory_Management_"))
                        {
                            DestinationDataTable.CacheColumnCollection.Add("_Memory_Management_", "STRING", Method.ToLower());
                        }

                        // If We are streaming the report from memory, make sure the raw report column exists in the destination table.
                        if (Method.ToLower() == "stream" && !DestinationDataTable.CacheColumnCollection.Contains("_Raw_Report_"))
                        {
                            DestinationDataTable.CacheColumnCollection.Add("_Raw_Report_", "BYTE()", "%RawReport%");
                        }

                        // Add the destination table to the cache.
                        SharedData.Add(results_table_name, DestinationDataTable);
                    }
                }
                else
                {
                    throw new Exception("Method[" + Method + "] is not recognized.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void RunBagOfWords(Random rnd, int vectorLength, string wordsPath,
                                         ApproximationType approximation,
                                         string resultDir,
                                         Func <int, bool> isLeft, string[] textFilesPathes)
        {
            var numOfNodes         = textFilesPathes.Length;
            var windowSize         = 20000;
            var amountOfIterations = 2000;
            var stepSize           = 1000;
            var halfVectorLength   = vectorLength / 2;
            var optionalWords      = File.ReadLines(wordsPath).Take(halfVectorLength).ToArray();
            var optionalStrings    = new SortedSet <string>(optionalWords, StringComparer.OrdinalIgnoreCase);
            var resultPath         =
                PathBuilder.Create(resultDir, "InnerProduct")
                .AddProperty("Dataset", "BagOfWords")
                .AddProperty("Nodes", numOfNodes.ToString())
                .AddProperty("VectorLength", vectorLength.ToString())
                .AddProperty("Window", windowSize.ToString())
                .AddProperty("Iterations", amountOfIterations.ToString())
                .AddProperty("Approximation", approximation.AsString())
                .ToPath("csv");

            using (var resultCsvFile = AutoFlushedTextFile.Create(resultPath, AccumaltedResult.Header(numOfNodes)))
                using (var stringDataParser =
                           TextParser <string> .Init(StreamReaderUtils.EnumarateWords, windowSize, optionalStrings,
                                                     textFilesPathes))
                {
                    var innerProduct = new InnerProductFunction(vectorLength);
                    var initVectors  = stringDataParser.Histograms.Map(h => h.CountVector())
                                       .PadWithZeros(halfVectorLength, isLeft);
                    var multiRunner = MultiRunner.InitAll(initVectors, numOfNodes, vectorLength,
                                                          approximation, innerProduct.MonitoredFunction);
                    var changes = stringDataParser.AllCountVectors(stepSize)
                                  .Select(ch => ch.PadWithZeros(halfVectorLength, isLeft))
                                  .Take(amountOfIterations);
                    multiRunner.RunAll(changes, rnd, true)
                    .Select(r => r.AsCsvString())
                    .ForEach((Action <string>)resultCsvFile.WriteLine);
                }
        }
        public void AnotherParserTest()
        {
            var text           = @" 
Uif!Ofx!Zpsl!Ujnft!Cftu!Tfmmfs!Mjtu!
This November 16, 1931 Last Weeks 
Week Non-Fiction Week On List 
    
1 ELLEN TERRY AND BERNARD SHAW: A CORRESPONDENCE, by Ellen Terry -- 2 
and Bernard Shaw. (Putnam.) 
    
2 EPIC OF AMERICA, by James Truslow Adams. (Little, Brown.) -- 2 
    
3 WASHINGTON MERRY-GO-ROUND, by Anonymous. (Drew Pearson and Robert -- 2 
Allen.) (Liveright.) 
    
4 NEWTON D. BAKER, by Frederic Palmer. (Dodd, Mead.) -- 1 
    
5 MOURNING BECOMES ELECTRA, by Eugene O’Neill. (Liveright.) -- 1 
 
Hawes Publications  www.hawes.com ";
            var bestSellerList = TextParser.Parse(text);

            bestSellerList.Genre.Should().Be(Genre.NonFiction);
            bestSellerList.Entries.Count.Should().Be(5);
            bestSellerList.Entries[0].Title.Should().Be("ELLEN TERRY AND BERNARD SHAW: A CORRESPONDENCE, by Ellen Terry and Bernard Shaw.");
            bestSellerList.Entries[1].Title.Should().Be("EPIC OF AMERICA, by James Truslow Adams.");
            bestSellerList.Entries[2].Title.Should().Be("WASHINGTON MERRY-GO-ROUND, by Anonymous.");
            bestSellerList.Entries[3].Title.Should().Be("NEWTON D. BAKER, by Frederic Palmer.");
            bestSellerList.Entries[4].Title.Should().Be("MOURNING BECOMES ELECTRA, by Eugene O’Neill.");
            bestSellerList.Entries[0].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[1].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[2].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[3].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[4].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[0].WeeksOnList.Should().Be(2);
            bestSellerList.Entries[1].WeeksOnList.Should().Be(2);
            bestSellerList.Entries[2].WeeksOnList.Should().Be(2);
            bestSellerList.Entries[3].WeeksOnList.Should().Be(1);
            bestSellerList.Entries[4].WeeksOnList.Should().Be(1);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Parse hexadecimal field
        /// </summary>
        protected bool ParseHexadecimal(TextParser input, FormatSpecifier spec)
        {
            // Skip any whitespace
            input.MovePastWhitespace();

            // Parse 0x prefix
            int start = input.Position;

            if (input.Peek() == '0' && input.Peek(1) == 'x')
            {
                input.MoveAhead(2);
            }

            // Parse digits
            while (IsValidDigit(input.Peek(), 16))
            {
                input.MoveAhead();
            }

            // Don't exceed field width
            if (spec.Width > 0)
            {
                int count = input.Position - start;
                if (spec.Width < count)
                {
                    input.MoveAhead(spec.Width - count);
                }
            }

            // Extract token
            if (input.Position > start)
            {
                if (!spec.NoResult)
                {
                    AddUnsigned(input.Extract(start, input.Position), spec.Modifier, 16);
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 18
0
    public void TypingText(AutoTypeEvent eventdata)
    {
        if (typing != null)
        {
            StopCoroutine(typing);
            typing = null;
        }
        message              = eventdata.text;
        Text.text            = "";
        PauseSpeedMultiplier = Game.current.Progress.GetFloatValue("TextSpeed");
        letterPause          = 1 / (DefaultPauseSpeed * PauseSpeedMultiplier);
        UpdateSpeed          = TextParser.ExtractTextSpeed(ref message);

        if (!Paused)
        {
            typing = StartCoroutine(TypeText(0));
        }
        else
        {
            Text.maxVisibleCharacters = 0;
        }
    }
Exemplo n.º 19
0
 public static Eod ParseEod(string line, string symbol)
 {
     if (line.StartsWith("Date", StringComparison.InvariantCultureIgnoreCase))
     {
         return(null);
     }
     string[] sa = line.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
     if (sa.Count() == 7)
     {
         return(new Eod
         {
             Symbol = symbol,
             Date = DateTime.Parse(sa[0]),
             Open = TextParser.ParseFloat(sa[1]),
             High = TextParser.ParseFloat(sa[2]),
             Low = TextParser.ParseFloat(sa[3]),
             Close = TextParser.ParseFloat(sa[4]),
             Volume = TextParser.ParseDecimal(sa[5].Replace(",", string.Empty))
         });
     }
     return(null);
 }
Exemplo n.º 20
0
            private string ResolveEntities(string text)
            {
                var tp = new TextParser(text);
                var sb = new StringBuilder(text.Length);

                while (!tp.EndOfText)
                {
                    var c = tp.Peek();
                    switch (c)
                    {
                    case '&':
                        EntityConverter.Convert(tp, sb);
                        break;

                    default:
                        sb.Append(c);
                        tp.MoveAhead();
                        break;
                    }
                }
                return(sb.ToString());
            }
Exemplo n.º 21
0
        private void ParseAndValue(string text, string culture, SearchManagerImportance importance,
                                   Dictionary <string, int> scoredParts, int maxWordsToParse)
        {
            var parts = TextParser.ParseText(text, culture, true, maxWordsToParse);

            if (parts == null)
            {
                return;
            }

            foreach (var s in parts)
            {
                if (scoredParts.ContainsKey(s))
                {
                    scoredParts[s] += (int)importance;
                }
                else
                {
                    scoredParts.Add(s, (int)importance);
                }
            }
        }
        public void ReplaceWordsWithSubstring(int length, string substring)
        {
            TextParser textParser  = new TextParser();
            var        newElements = SentenceElements.ToList();

            string value = "";

            foreach (var element in SentenceElements)
            {
                if (element is IWord && element.Chars.Length == length)
                {
                    var indexToReplace = newElements.IndexOf(element);
                    newElements[indexToReplace].Chars = substring;
                }
            }
            foreach (var el in newElements)
            {
                value += el.ToString();
            }

            SentenceElements = textParser.Parse(value);
        }
Exemplo n.º 23
0
        public static void initialize(string path)
        {
            StreamReader reader = new StreamReader(path);
            string key = "";
            string value = "";
            globals = new Dictionary<string, string>();
            string curLine;
            TextParser tp = new TextParser();

            while (!(reader.EndOfStream))
            {
                curLine = reader.ReadLine();
                if (tp.seperateWords(curLine).Count < 2)
                    break;
                key = tp.seperateWords(curLine)[0];
                value = tp.seperateWords(curLine)[1];

                globals.Add(key, value);
                Console.WriteLine("Added key " + key + " with value " + value);

            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            string     pBook      = ConfigurationManager.AppSettings.Get("programmingBook");
            string     ansBook    = ConfigurationManager.AppSettings.Get("answerBook");
            string     concBook   = ConfigurationManager.AppSettings.Get("concordanceBook");
            IOF        iOF        = new IOF();
            string     txt        = iOF.ReadPBook(pBook);
            TextParser textParser = new TextParser();
            Text       text       = textParser.Parse(txt);

            text.DeleteEmptySentences();
            using (StreamWriter writeToAnswerTXT = new StreamWriter(ansBook))
            {
                //Вывести все предложения заданного текста в порядке возрастания количества
                //слов в каждом из них
                text.SortedByWordCount();

                int len = 5, numOfSentences = 2;
                // Во всех вопросительных предложениях текста найти и напечатать без
                //повторений слова заданной длины
                text.PrintWordsInInterrogativeWithoutRepetitions(writeToAnswerTXT, len);
                //Из текста удалить все слова заданной длины, начинающиеся на согласную букву
                text.DeleteWordsBegWithConsonant(len);
                text.DeleteEmptySentences();
                //В некотором предложении текста слова заданной длины заменить указанной
                //подстрокой, длина которойможет не совпадать с длиной слова
                string sub = "hello";
                text.WordsReplaceWithSubstring(numOfSentences, len, sub);

                writeToAnswerTXT.Close();
            };
            using (StreamWriter writeToConcordanceTXT = new StreamWriter(concBook))
            {
                //отобразить соответствие
                int countSentencePerPage = 5;
                text.Concordance(writeToConcordanceTXT, countSentencePerPage);
                writeToConcordanceTXT.Close();
            };
        }
Exemplo n.º 25
0
		private static void ParseBone(TextParser parser, AnimSkel mesh)
		{
			parser.Consume("{");
			AnimBone bone = null;
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					bone = mesh.Bones[mesh.EnsureBone(parser.ConsumeString())];
					continue;
				}
				if (attribute == "parent")
				{
					parser.Consume();
					bone.Parent = mesh.EnsureBone(parser.ConsumeString());
					continue;
				}
				if (attribute == "pos")
				{
					parser.Consume();
					bone.BindingPos = parser.ConsumeVector3();
					continue;
				}
				if (attribute == "rot")
				{
					parser.Consume();
					bone.BindingRot = parser.ConsumeQuaternion();
					continue;
				}
				parser.UnknownLexemError();
			}
		}
        /// <summary>
        /// Construct a parser that fails with error message <paramref name="errorMessage"/> when <paramref name="parser"/> fails.
        /// </summary>
        /// <typeparam name="T">The type of value being parsed.</typeparam>
        /// <param name="parser">The parser.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns>The resulting parser.</returns>
        public static TextParser <T> Message <T>(this TextParser <T> parser, string errorMessage)
        {
            if (parser == null)
            {
                throw new ArgumentNullException(nameof(parser));
            }
            if (errorMessage == null)
            {
                throw new ArgumentNullException(nameof(errorMessage));
            }

            return(input =>
            {
                var result = parser(input);
                if (result.HasValue)
                {
                    return result;
                }

                return Result.Empty <T>(result.Remainder, errorMessage);
            });
        }
        /// <summary>
        /// Construct a parser that returns <paramref name="name"/> as its "expectation" if <paramref name="parser"/> fails.
        /// </summary>
        /// <typeparam name="T">The type of value being parsed.</typeparam>
        /// <param name="parser">The parser.</param>
        /// <param name="name">The name given to <paramref name="parser"/>.</param>
        /// <returns>The resulting parser.</returns>
        public static TextParser <T> Named <T>(this TextParser <T> parser, string name)
        {
            if (parser == null)
            {
                throw new ArgumentNullException(nameof(parser));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(input =>
            {
                var result = parser(input);
                if (result.HasValue || result.Remainder != input)
                {
                    return result;
                }

                return Result.Empty <T>(result.Remainder, new[] { name });
            });
        }
Exemplo n.º 28
0
        public void read_steps_in_a_section_without_an_id()
        {
            var spec = TextParser.Parse(@"
Name: My spec
=> Math
* Adding: x=1, y=2, sum=3
* StartWith: x=5
");

            var section = spec.Children[0].As <Section>();
            var step1   = section.Children[0].As <Step>();

            step1.Key.ShouldBe("Adding");
            step1.Values["x"].ShouldBe("1");
            step1.Values["y"].ShouldBe("2");
            step1.Values["sum"].ShouldBe("3");

            var step2 = section.Children[1].As <Step>();

            step2.Key.ShouldBe("StartWith");
            step2.Values["x"].ShouldBe("5");
        }
Exemplo n.º 29
0
        private void BuildColumns()
        {
            int countColumn = 24;

            GridColumn column     = null;
            int        columnTime = 0;

            for (int i = 0; i < countColumn; i++, columnTime += 60)
            {
                column     = gridView.Columns.Add();
                column.Tag = i;

                column.Caption = TextParser.TimeToString(columnTime);
                column.OptionsColumn.ReadOnly  = true;
                column.OptionsColumn.AllowEdit = false;
                column.OptionsColumn.ShowInCustomizationForm = false;
                column.OptionsColumn.AllowMove = false;
                column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
                column.UnboundType             = DevExpress.Data.UnboundColumnType.String;
                //column.ColumnEdit = repositoryItemMemoEdit1;
                column.FieldName = "i" + i;
                column.MinWidth  = 50;
                column.Width     = 50;
                column.Visible   = true;
                column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                column.AppearanceCell.TextOptions.HAlignment   = DevExpress.Utils.HorzAlignment.Center;
                column.AppearanceCell.TextOptions.VAlignment   = DevExpress.Utils.VertAlignment.Center;
                //column.AppearanceCell.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Millimeter);
            }

            if ((column = FindColumnByFieldName("i8")) != null)
            {
                gridView.MakeColumnVisible(column);
            }
            if ((column = FindColumnByFieldName("i18")) != null)
            {
                gridView.MakeColumnVisible(column);
            }
        }
Exemplo n.º 30
0
    void Awake()
    {
        System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultures(System.Globalization.CultureTypes.NeutralCultures)[0];

        appPath = Application.streamingAssetsPath;

        dialogueLine = new List <int>(1)
        {
            0
        };

        parser        = new TextParser(this);
        choiceManager = new ChoiceManager();
        charManager   = new CharacterManager(startingCast);

        themeConstructor = new ThemeConstructor(this);

        uiConstructor = new UIConstructor();
        uiManager     = new UIManager(this, uiConstructor.ConstructText(Color.black), uiConstructor.ConstructGroup(1, false, Color.gray), uiConstructor.ConstructCanvas(), uiConstructor.ConstructButton(Color.black, Color.black), uiConstructor.ConstructGroup(0, false, Color.gray), uiConstructor.ConstructLayoutGroup());

        varManager      = new VariableManager();
        functionManager = new FunctionManager(this);

        //Base starting values
        if (startWithExposition)
        {
            varManager.SetVar(new string[] { "charVisible=0" });
        }
        else
        {
            varManager.SetVar(new string[] { "charVisible=1" });
        }
        varManager.SetVar(new string[] { "typeRate=" + startingTextSpeed });
        varManager.SetVar(new string[] { "buildV=" + version });
        varManager.SetVar(new string[] { "pitch=1" });

        thes      = new Thesaurus("Default");
        uiManager = themeConstructor.ConstructTheme("Default");
    }
Exemplo n.º 31
0
        private void LoadData()
        {
            int[] count = this.GetCounts(this.fontsize);
            this.chapter           = this.book.Chapters[this.currentChapter];
            this.chapter.PageCount = count[0];
            string  content = AtFile.GetContent(OkrBookContext.Current.Config.Data + "/" + this.chapter.FileName + ".txt", 4);
            Chapter chapter = null;

            if (content != null)
            {
                chapter = TextParser.GetChapter(content, count);
            }
            this.chapter.PageList = chapter.PageList;
            this.chapter.PageNum  = chapter.PageNum;
            this.chapter.Pages    = chapter.Pages;
            this.GetThisPage();
            this.ChangeMarkContent();
            this.title1.Text = this.chapter.Title;
            this.title2.Text = this.chapter.Title;
            OKr.MXReader.Client.Core.Data.Page page = this.chapter.Pages[this.index];
            this.text_text1.Text = "";
            this.text_text2.Text = "";
            for (int i = 0; i < page.Row.Count; i++)
            {
                if (Regex.IsMatch(page.Row[i], @"[\r\n]"))
                {
                    this.text_text1.Text = this.text_text1.Text + page.Row[i];
                    this.text_text2.Text = this.text_text2.Text + page.Row[i];
                }
                else
                {
                    this.text_text1.Text = this.text_text1.Text + page.Row[i] + "\n";
                    this.text_text2.Text = this.text_text2.Text + page.Row[i] + "\n";
                }
            }
            this.pageno1.Text = string.Concat(new object[] { this.index + 1, "/", this.chapter.PageNum, OkrConstant.PAGE });
            this.pageno2.Text = string.Concat(new object[] { this.index + 1, "/", this.chapter.PageNum, OkrConstant.PAGE });
            this.ShowMark();
        }
Exemplo n.º 32
0
        public override void parse(string curLine)
        {
            TextParser    tp    = new TextParser();
            List <string> words = tp.seperateWords(curLine);

            actor = words[1];


            if (words.Count == 4)
            {
                text = words[2].Substring(1, words[2].Length - 2);
            }

            else
            {
                for (int i = 2; i < words.Count; i++)
                {
                    if (words[i].EndsWith(")"))
                    {
                        text += words[i].Substring(0, words[i].Length - 1);
                        break;
                    }

                    if (words[i].StartsWith("("))
                    {
                        text += words[i].Substring(1) + " ";
                    }

                    else
                    {
                        text += words[i] + " ";
                    }
                }
            }

            animation  = words[words.Count - 1];
            actionType = ActionType.Speak;
        }
Exemplo n.º 33
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			var skel = this.context.Resolve<AnimSkel>();
			skel.Name = defaultName;
			parser.Consume("CIwAnimSkel");
			parser.Consume("{");

			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					skel.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "numBones")
				{
					parser.Consume();
					skel.Bones.Capacity = parser.ConsumeInt();
					continue;
				}

				if (attribute == "CIwAnimBone")
				{
					parser.Consume();
					ParseBone(parser, skel);
					continue;
				}
				parser.UnknownLexemError();
			}
			return skel;
		}
        public void InitialTest()
        {
            var text           = @" 
Uif!Ofx!Zpsl!Ujnft!Cftu!Tfmmfs!Mjtu!
This October 12, 1931 Last Weeks 
Week Fiction Week On List 
    
1 THE TEN COMMANDMENTS, by Warwick Deeping. (Knopf.) -- 1 
    
2 FINCHE'S FORTUNE, by Mazo de la Roche. (Little, Brown.) -- 1 
    
3 THE GOOD EARTH, by Pearl S. Buck. (John Day.) -- 1 
    
4 SHADOWS ON THE ROCK, by Willa Cather. (Knopf.) -- 1 
    
5 SCARMOUCHE THE KING MAKER, by Rafael Sabatini. (Houghton, Mifflin.) -- 1 
 
Hawes Publications  www.hawes.com ";
            var bestSellerList = TextParser.Parse(text);

            bestSellerList.Genre.Should().Be(Genre.Fiction);
            bestSellerList.Entries.Count.Should().Be(5);
            bestSellerList.Entries[0].Title.Should().Be("THE TEN COMMANDMENTS, by Warwick Deeping.");
            bestSellerList.Entries[1].Title.Should().Be("FINCHE'S FORTUNE, by Mazo de la Roche.");
            bestSellerList.Entries[2].Title.Should().Be("THE GOOD EARTH, by Pearl S. Buck.");
            bestSellerList.Entries[3].Title.Should().Be("SHADOWS ON THE ROCK, by Willa Cather.");
            bestSellerList.Entries[4].Title.Should().Be("SCARMOUCHE THE KING MAKER, by Rafael Sabatini.");
            bestSellerList.Entries[0].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[1].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[2].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[3].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[4].LastWeek.Should().NotHaveValue();
            bestSellerList.Entries[0].WeeksOnList.Should().Be(1);
            bestSellerList.Entries[1].WeeksOnList.Should().Be(1);
            bestSellerList.Entries[2].WeeksOnList.Should().Be(1);
            bestSellerList.Entries[3].WeeksOnList.Should().Be(1);
            bestSellerList.Entries[4].WeeksOnList.Should().Be(1);
        }
Exemplo n.º 35
0
        private void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            // store the new data.
            if (Page.IsValid)
            {
                int?supportQueueID         = null;
                int selectedSupportQueueID = Convert.ToInt32(cbxSupportQueues.SelectedItem.Value);
                if (selectedSupportQueueID > 0)
                {
                    supportQueueID = selectedSupportQueueID;
                }

                string newThreadWelcomeText       = null;
                string newThreadWelcomeTextAsHTML = null;
                if (tbxNewThreadWelcomeText.Text.Trim().Length > 0)
                {
                    // has specified welcome text, convert to HTML
                    newThreadWelcomeText = tbxNewThreadWelcomeText.Text.Trim();
                    string parserLog, textAsXML;
                    bool   errorsOccured;
                    newThreadWelcomeTextAsHTML = TextParser.TransformUBBMessageStringToHTML(newThreadWelcomeText, ApplicationAdapter.GetParserData(),
                                                                                            out parserLog, out errorsOccured, out textAsXML);
                }

                // page is valid, store the forum.
                if (ForumManager.ModifyForum(_forumID, HnDGeneralUtils.TryConvertToInt(cbxSections.SelectedItem.Value), tbxForumName.Value,
                                             tbxForumDescription.Text, chkHasRSSFeed.Checked, supportQueueID, HnDGeneralUtils.TryConvertToInt(cbxThreadListInterval.SelectedValue),
                                             HnDGeneralUtils.TryConvertToShort(tbxOrderNo.Text), HnDGeneralUtils.TryConvertToInt(tbxMaxAttachmentSize.Text),
                                             HnDGeneralUtils.TryConvertToShort(tbxMaxNoOfAttachmentsPerMessage.Text), newThreadWelcomeText, newThreadWelcomeTextAsHTML))
                {
                    // went ok!
                    // invalidate cache
                    CacheManager.InvalidateCachedItem(CacheManager.ProduceCacheKey(CacheKeys.SingleForum, _forumID));
                    // done
                    Response.Redirect("ModifyDeleteForum.aspx", true);
                }
            }
        }
Exemplo n.º 36
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			var model = this.context.Resolve<Model>();
			model.Name = defaultName;

			if (parser.Lexem == "CMesh")
			{
				model.Meshes.Add(this.ParseMesh(parser));
				return model;
			}

			parser.Consume("CIwModel");
			parser.Consume("{");

			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					model.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "CMesh")
				{
					model.Meshes.Add(this.ParseMesh(parser));
					continue;
				}
				parser.UnknownLexemError();
			}

			return model;
		}
        private void txtSend_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.LeftShift | e.Key == Key.RightShift)
            {
                isShiftDown = false;
            }

            if (e.Key == Key.Enter & !isShiftDown)
            {
                string txtSendChat = TextParser.GetPlainText(txtSend.Document);

                if (txtSendChat.Length == 0 || txtSendChat.Trim() == "")
                {
                    return;
                }

                AddChatMessage(Personal.USER_INFO.name, txtSendChat);

                Network.Client.SendMessage(new Message(contactUserInfo.id, txtSendChat));

                txtSend.Document.Blocks.Clear();
            }
        }
Exemplo n.º 38
0
 public static Company ParseCompany(string line, string exchange)
 {
     char[] trimCompany = new char[] { '"' };
     if (line.StartsWith("\"Symbol\"", StringComparison.InvariantCultureIgnoreCase))
     {
         return(null);
     }
     string[] sa = line.Split(new string[] { "\"," }, StringSplitOptions.RemoveEmptyEntries);
     if (sa.Count() >= 8)
     {
         return(new Company
         {
             Symbol = sa[0].Trim(trimCompany),
             Name = sa[1].Trim(trimCompany).Replace(',', ' '),
             LastSale = TextParser.ParseFloat(sa[2].Trim(trimCompany)),
             MarketCap = TextParser.ParseDecimal(sa[3].Trim(trimCompany)),
             Sector = sa[6].Trim(trimCompany).Replace(',', ' '),
             Industry = sa[7].Trim(trimCompany).Replace(',', ' '),
             Exchange = exchange
         });
     }
     return(null);
 }
        public ExcelReader(Cache shared_data, ExcelReader configuration)
            : base(shared_data, configuration)
        {
            if (!string.IsNullOrEmpty(configuration.PageIndex))
            {
                if (configuration.PageIndex.StartsWith("%"))
                {
                    PageIndex = TextParser.Parse(configuration.PageIndex, DrivingData, SharedData, ModuleCommands);
                }
                else
                {
                    PageIndex = configuration.PageIndex;
                }
            }
            else
            {
                PageIndex = "0";
            }

            FontStripStrikethrough = configuration.FontStripStrikethrough;

            Close += OnClose;
        }
        public void TestMethod_Date_Time()
        {
            DateTime now = DateTime.Now;
            DateTime dateRemind = new DateTime(2012, 01, 06, 15, 20, 0);
            DateTime date; string leftText;

            Assert.IsTrue(TextParser.Parse("Susitikimas 01/06/2012 15:20", out date, out leftText));
            CheckByShortDateTimeStrings(dateRemind, date, leftText);
            Assert.AreEqual("Susitikimas", leftText);

            dateRemind = new DateTime(2013, 04, 2, 15, 20, 10);
            Assert.IsTrue(TextParser.Parse("Susitikimas 4/2/2013 15:20", out date, out leftText));
            CheckByShortDateTimeStrings(dateRemind, date, leftText);
            Assert.AreEqual("Susitikimas", leftText);

            dateRemind = new DateTime(2012, 01, 06, 15, 20, 10);
            Assert.IsTrue(TextParser.Parse("Susitikimas 01-06-2012 15:20:10", out date, out leftText));
            CheckByShortDateTimeStrings(dateRemind, date, leftText);
            Assert.AreEqual("Susitikimas", leftText);

            dateRemind = new DateTime(2012, 02, 06, 15, 20, 10);
            Assert.IsTrue(TextParser.Parse("Susitikimas 02/06 15:20:10", out date, out leftText));
        }
Exemplo n.º 41
0
        public override void parse(string curLine)
        {
            TextParser tp = new TextParser();
            List<string> words = tp.seperateWords(curLine);

            actor = words[1];

            string actorXPos = "";
            Vector2 curActorPos = Vector2.Zero;
            string actorYPos = "";

            actorXPos = words[2];
            actorXPos = actorXPos.Substring(1, actorXPos.Length - 2);
            actorYPos = words[3];
            actorYPos = actorYPos.Substring(0, actorYPos.Length - 1);

            target = new Vector2(float.Parse(actorXPos), float.Parse(actorYPos));

            animation = words[4];
            time = int.Parse(words[5]);

            actionType = ActionType.Move;
        }
Exemplo n.º 42
0
        public void TestMethod_Date_Time()
        {
            DateTime now = DateTime.Now;
            DateTime dateRemind = new DateTime(2012, 06, 01, 15, 20, 0);
            DateTime date; string leftText;

            Assert.IsTrue(TextParser.Parse("Susitikimas 2012.06.01 15:20", out date, out leftText));
            Assert.AreEqual(dateRemind.ToShortDateString(), date.ToShortDateString());
            Assert.AreEqual(dateRemind.ToShortTimeString(), date.ToShortTimeString());
            Assert.AreEqual("Susitikimas", leftText);

            dateRemind = new DateTime(2012, 06, 01, 15, 20, 10);
            Assert.IsTrue(TextParser.Parse("Susitikimas 2012-06-01 15:20:10", out date, out leftText));
            Assert.AreEqual(dateRemind.ToShortDateString(), date.ToShortDateString());
            Assert.AreEqual(dateRemind.ToShortTimeString(), date.ToShortTimeString());
            Assert.AreEqual("Susitikimas", leftText);

            dateRemind = new DateTime(m_now.Year, 06, 02, 15, 20, 10);
            Assert.IsTrue(TextParser.Parse("Susitikimas 06.02 15:20:10", out date, out leftText));
            Assert.AreEqual(dateRemind.ToShortDateString(), date.ToShortDateString());
            Assert.AreEqual(dateRemind.ToShortTimeString(), date.ToShortTimeString());
            Assert.AreEqual("Susitikimas", leftText);
        }
        /// <summary>
        /// Construct a parser that succeeds only if the source is at the end of input.
        /// </summary>
        /// <typeparam name="T">The type of value being parsed.</typeparam>
        /// <param name="parser">The parser.</param>
        /// <returns>The resulting parser.</returns>
        public static TextParser <T> AtEnd <T>(this TextParser <T> parser)
        {
            if (parser == null)
            {
                throw new ArgumentNullException(nameof(parser));
            }

            return(input =>
            {
                var result = parser(input);
                if (!result.HasValue)
                {
                    return result;
                }

                if (result.Remainder.IsAtEnd)
                {
                    return result;
                }

                return Result.Empty <T>(result.Remainder);
            });
        }
Exemplo n.º 44
0
        void TurnMapOn(DefaultEvent Eventdata)
        {
            if (!Active)
            {
                return;
            }

            Active = false;
            //print("here");
            //Game.current.AlterTime();

            //psudo code time!
            //grab the transitions script, and put it on the map object.
            //call it here, to pull the map and stats onto the screen.
            MapRooms.DispatchEvent(Events.Translate, new TransformEvent(Vector3.zero, MapTransitionDuration));
            SocialStats.DispatchEvent(Events.Translate, new TransformEvent(Vector3.zero, MapTransitionDuration));

            //gameObject.SetActive(true);
            ChoicesAvalible   = TimelineSystem.Current.GetOptionsAvalible(Game.current.Day, Game.current.Hour);
            AllowTimeDilation = Game.current.Progress.GetBoolValue("Depression Time Dilation");

            StartCoroutine(TextParser.FrameDelay(Events.UpdateMap));
        }
Exemplo n.º 45
0
        public override void parse(string curLine)
        {
            TextParser    tp    = new TextParser();
            List <string> words = tp.seperateWords(curLine);

            actor = words[1];

            string  actorXPos   = "";
            Vector2 curActorPos = Vector2.Zero;
            string  actorYPos   = "";

            actorXPos = words[2];
            actorXPos = actorXPos.Substring(1, actorXPos.Length - 2);
            actorYPos = words[3];
            actorYPos = actorYPos.Substring(0, actorYPos.Length - 1);

            target = new Vector2(float.Parse(actorXPos), float.Parse(actorYPos));

            animation = words[4];
            time      = int.Parse(words[5]);

            actionType = ActionType.Move;
        }
        private string _ParseKey(TextParser parser)
        {
            var builder = new StringBuilder();

            parser.SkipWhitespace();
            while (!parser.EndOfStream)
            {
                if (parser.Peek() == '>')
                {
                    break;
                }
                if (char.IsWhiteSpace((char)parser.Peek()))
                {
                    break;
                }
                if (parser.Peek() == '=')
                {
                    break;
                }
                builder.Append((char)parser.Read());
            }
            return(builder.ToString().ToLower());
        }
Exemplo n.º 47
0
        static void Main(string[] args)
        {
            TextParser textParser = new TextParser(ConfigurationManager.AppSettings["TextFile"]);

            string line;

            try
            {
                using (StreamReader sr = new StreamReader(ConfigurationManager.AppSettings["TextFile"]))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(line);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadLine();
        }
Exemplo n.º 48
0
 static TextParser <T> ChainRightOperatorRest <T, TOperator>(
     T lastOperand,
     TextParser <TOperator> @operator,
     TextParser <T> operand,
     Func <TOperator, T, T, T> apply)
 {
     if (@operator == null)
     {
         throw new ArgumentNullException(nameof(@operator));
     }
     if (operand == null)
     {
         throw new ArgumentNullException(nameof(operand));
     }
     if (apply == null)
     {
         throw new ArgumentNullException(nameof(apply));
     }
     return(@operator.Then(opvalue =>
                           operand.Then(operandValue =>
                                        ChainRightOperatorRest(operandValue, @operator, operand, apply)).Then(r => Return(apply(opvalue, lastOperand, r))))
            .Or(Return(lastOperand)));
 }
Exemplo n.º 49
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			Anim mesh = this.context.Resolve<Anim>();
			mesh.Name = defaultName;
			parser.Consume("CIwAnim");
			parser.Consume("{");

			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					mesh.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "skeleton")
				{
					parser.Consume();
					parser.ConsumeResourceReference(mesh.Skeleton);
					continue;
				}
				if (attribute == "CIwAnimKeyFrame")
				{
					this.ParseKeyFrame(parser, mesh);
					continue;
				}
				parser.UnknownLexemError();
			}
			return mesh;
		}
 public void GivenIHaveATextParser()
 {
     _textParser = new TextParser();
 }
Exemplo n.º 51
0
	public static FGParser Create(FGTextBuffer textBuffer, string path)
	{
		Type parserType;
		FGParser parser;
		var extension = Path.GetExtension(path) ?? String.Empty;
		if (!path.StartsWith("assets/webplayertemplates/", StringComparison.OrdinalIgnoreCase)
			&& parserTypes.TryGetValue(extension, out parserType))
		{
			parser = (FGParser) Activator.CreateInstance(parserType);
		}
		else
		{
			parser = new TextParser();
		}
		
		parser.textBuffer = textBuffer;
		parser.assetPath = path;
		return parser;
	}
Exemplo n.º 52
0
 public void Does_GiveTestFileWhenAnAction_When_WHenLineEndsWithAnAction()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     text.Add("When an action");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual("an_action", p.Tests[0].When);
 }
Exemplo n.º 53
0
		public Managed Parse(TextParser parser, string defaultName)
		{
			ResGroup group = new ResGroup(this.context.Resolve<IResourceManager>(), parser.ResourceFile, this.context)
				{ BasePath = parser.BasePath };
			group.Name = defaultName;
			parser.Consume("CIwResGroup");
			parser.Consume("{");
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "name")
				{
					parser.Consume();
					group.Name = parser.ConsumeString();
					continue;
				}
				if (attribute == "shared")
				{
					parser.Consume();
					group.IsShared = parser.ConsumeBool();
					continue;
				}
				if (attribute == "useTemplate")
				{
					//TODO: make a template handler
					parser.Consume();
					var ext = parser.ConsumeString();
					var name = parser.ConsumeString();
					continue;
				}

				var relPath = attribute.Replace('/', Path.DirectorySeparatorChar);
				if (relPath.Length > 2 && relPath[0] == '.' && relPath[1] == Path.DirectorySeparatorChar)
				{
					relPath = relPath.Substring(2);
				}
				string fullPath;
				if (relPath[0] == Path.DirectorySeparatorChar)
				{
					var searchPath = parser.BasePath;
					do
					{
						var subpath = relPath.Substring(1);
						fullPath = Path.Combine(searchPath, subpath);
						if (File.Exists(fullPath))
						{
							ParseFileReference(parser, @group, fullPath);
							continue;
						}
						searchPath = Path.GetDirectoryName(searchPath);
					}
					while (!string.IsNullOrEmpty(searchPath));

					//fullPath = Path.Combine(searchPath, parser.BasePath);
					//ParseFileReference(parser, @group, fullPath);
					//continue;
				}
				else
				{
					fullPath = Path.Combine(parser.BasePath, relPath);
					//if (File.Exists(fullPath))
					{
						ParseFileReference(parser, @group, fullPath);
						continue;
					}
				}
				parser.UnknownLexemError();
			}
			return group;
		}
Exemplo n.º 54
0
		private static void ParseFileReference(TextParser parser, ResGroup @group, string fullPath)
		{
			@group.AddFile(fullPath);
			parser.ConsumeString();
			if (parser.Lexem == "{")
			{
				//TODO: make a block handler
				parser.ConsumeBlock();
			}
		}
Exemplo n.º 55
0
 public void Does_IgnoreEmpty_When_TextContainsEmptyLines()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("");
     text.Add("Given a state2");
     text.Add("When an action");
     text.Add("Expect a state");
     text.Add("Expect an action");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual(2, p.Tests.Count);
 }
Exemplo n.º 56
0
 public void Does_NotGeneratTestFile_When_NoLinesAndSubject()
 {
     //Arragne
     TextParser p = new TextParser();
     //Act
     p.Parse(new List<string>() { "subject: subject"});
     //Assert
     Assert.AreEqual(0, p.Tests.Count);
 }
Exemplo n.º 57
0
 public void Does_ThrowException_When_FirstLineDoesNotStartWithSubject()
 {
     //Arragne
     TextParser p = new TextParser();
     //Act
     p.Parse(new List<string>(){ "Given a state" });
 }
Exemplo n.º 58
0
 public void Does_GiveTestFileGivenAState_When_GivenLineEndsWithAState()
 {
     //Arragne
     TextParser p = new TextParser();
     List<string> text = new List<string>() { "subject: subject" };
     text.Add("Given a state");
     //Act
     p.Parse(text);
     //Assert
     Assert.AreEqual("a_state", p.Tests[0].Given);
 }
Exemplo n.º 59
0
		private static void ParseVertWeights(TextParser parser, List<int> bones, AnimSkin mesh)
		{
			parser.Consume("{");
			var bone = parser.ConsumeInt();
			mesh.Weights.EnsureAt(bone);
			parser.Skip(",");
			VertexWeights w = VertexWeights.Empty;
			if (bones.Count > 0)
			{
				w.Bone0 = new VertexWeight { BoneIndex = bones[0], Weight = parser.ConsumeFloat() };
				parser.Skip(",");
				if (bones.Count > 1)
				{
					w.Bone1 = new VertexWeight { BoneIndex = bones[1], Weight = parser.ConsumeFloat() };
					parser.Skip(",");
					if (bones.Count > 2)
					{
						w.Bone2 = new VertexWeight { BoneIndex = bones[2], Weight = parser.ConsumeFloat() };
						parser.Skip(",");
						if (bones.Count > 3)
						{
							w.Bone3 = new VertexWeight { BoneIndex = bones[3], Weight = parser.ConsumeFloat() };
							parser.Skip(",");
							if (bones.Count > 4)
							{
								throw new TextParserException("max 4 bones supported");
							}
						}
					}
				}
			}
			parser.Consume("}");
		}
Exemplo n.º 60
0
		private static void ParseAnimSkinSet(TextParser parser, AnimSkin mesh)
		{
			List<int> bones = new List<int>(4);
			parser.Consume("{");
			for (;;)
			{
				var attribute = parser.Lexem;
				if (attribute == "}")
				{
					parser.Consume();
					break;
				}
				if (attribute == "useBones")
				{
					parser.Consume();
					parser.Consume("{");
					for (;;)
					{
						attribute = parser.Lexem;
						if (attribute == "}")
						{
							parser.Consume();
							break;
						}
						bones.Add(mesh.EnsureBone(parser.ConsumeString()));
						parser.Skip(",");
					}
					continue;
				}
				if (attribute == "numVerts")
				{
					parser.Consume();
					parser.ConsumeInt();
					continue;
				}
				if (attribute == "vertWeights")
				{
					parser.Consume();
					ParseVertWeights(parser, bones, mesh);
					continue;
				}
				parser.UnknownLexemError();
			}
		}