Esempio n. 1
0
        // [DebuggerStepThrough]
        public void Parse(string s)
        {
            // replace disturbing chars
            string src = s.Replace("\n", "");

            src = src.Replace("\t", "");
            src = Regex.Replace(src, "~.+~", ""); // remove comments

            // transform source
            string[] cmdss = src.Split(Convert.ToChar("{"));
            src = src.Remove(0, cmdss[0].Length + 1);
            src = src.Remove(src.Length - 2, 2);
            src = src.Replace("}", "\n");

            UseStatementParser.Parse(cmdss[0], this);

            //parsing commands
            foreach (string cm in src.Split(Convert.ToChar("\n")))
            {
                var sh = BlockHeaderParser.Parse(cm.Split(Convert.ToChar("{"))[0]);

                var cmd = new Section {
                    Header = { Name = sh.Name }
                };

                VarDefParser.Parse(DataTypes, cm, cmd);
                FunctionCallParser.Parse(cm, cmd, this);
                VarSetParser.Parse(DataTypes, cm, cmd);
                ClassParser.Parse(cm, this);

                Sections.Add(cmd);
            }
        }
Esempio n. 2
0
    public void InvalidPatterns(string expression)
    {
        var sut    = new VarSetParser();
        var result = sut.Parse(expression);

        result.Should().BeNull();
    }
Esempio n. 3
0
    public void ValidIntegerIncrement(params string[] args)
    {
        var expression = args[0];
        var expected   = args.Length > 1 ? args[1] : expression;

        var sut    = new VarSetParser();
        var result = sut.Parse(expression);

        result.Should().BeOfType <IntegerIncrement>()
        .Which.ToString().Should().Be(expected);
    }