Exemplo n.º 1
0
        public static ExprLogic Parse(string exprText)
        {
            var exprSchema = DeclareSchema();
            var refPointer = exprSchema[0];

            var resultLogic  = ExprLogic.CreateGroup(null);
            var currentGroup = resultLogic;

            var i           = 0;
            var exprTextLen = exprText.Length;

            while (i < exprTextLen)
            {
                var(pos, exprGrp, schemaNode) = HandleNode(refPointer, currentGroup, i, exprText);

                refPointer   = schemaNode;
                currentGroup = exprGrp;
                i            = pos;
            }

            if (currentGroup.Parent != null)
            {
                throw new KeywordParserException("Open and close brackets mismatch!");
            }

            return(resultLogic);
        }
Exemplo n.º 2
0
        static (bool, int, ExprLogic) OpenGroup(int pos, string source, ExprLogic currectGrp)
        {
            // open group
            var       res      = false;
            ExprLogic newGroup = null;

            if (source[pos] == OpenGrp)
            {
                pos++;  res = true;
            }

            if (res)
            {
                newGroup = currectGrp.AddGroup(ExprLogic.CreateGroup(currectGrp));

                currectGrp.ChildEntryLogic = Logic.None;
            }

            return(res, pos, res ? newGroup : currectGrp);
        }