Example #1
0
        public ParseContext(ParseContext parent, Parser parser)
            : this(parent.Input, -1)
        {
            Parent = parent;
            Parser = parser;

            WhitespacePolicy = parent.WhitespacePolicy;

            var wsRule = parser as WhitespaceRuleParser;
            if (wsRule != null)
            {
                _whitespaceParsers = new HashSet<Parser>(parent._whitespaceParsers ?? Enumerable.Empty<Parser>())
                {
                    wsRule.WhitespaceParser
                };
            }
            else
            {
                _whitespaceParsers = parent._whitespaceParsers;
            }

            var policy = parser as WhitespacePolicyParser;
            if (policy != null) WhitespacePolicy = policy.Policy;

            InitialOffset = Offset = parent.WhitespacePolicy == WhitespacePolicy.Ignore
                ? SkipWhitespace(parent.Input, parent.Offset) : parent.Offset;
        }
        public ParseContext(ParseContext parent, Parser parser)
            : this(parent.Input, parent.WhitespacePolicy == WhitespacePolicy.Ignore
                ? SkipWhitespace(parent.Input, parent.Offset) : parent.Offset)
        {
            Parent = parent;
            Parser = parser;

            WhitespacePolicy = parent.WhitespacePolicy;

            var policy = parser as WhitespacePolicyParser;
            if (policy != null) WhitespacePolicy = policy.Policy;
        }
 public bool IsUnique(ParseContext ctx)
 {
     if (Parser == ctx.Parser && InitialOffset == ctx.InitialOffset) return false;
     return Parent == null || Parent.IsUnique(ctx);
 }