Пример #1
0
 public Parser(IParserEventListener eventListener, bool isFw40, IAspxSource source)
 {
     this.eventListener = eventListener;
     this.source        = source;
     text     = source.Text;
     tagRegex = isFw40 ? tagRegex40 : tagRegex35;
 }
Пример #2
0
        public AspxParseResult Parse(IAspxSource source)
        {
            currentFiles.Clear();
            errors.Clear();
            var rootNode = new AspxNode.Root();

            Parse(source, rootNode);
            return(new AspxParseResult(rootNode, errors.ToImmutable()));
        }
Пример #3
0
        public bool TryParseDirective(IAspxSource source, out AspxNode.AspxDirective directive)
        {
            currentFiles.Clear();
            errors.Clear();
            var parser = new Parser(this, isFw40, source);
            var result = parser.TryParseDirective();

            if (result != null)
            {
                directive = new AspxNode.AspxDirective(result.Item2, result.Item3, result.Item1);
                return(true);
            }
            directive = null;
            return(false);
        }
Пример #4
0
        private void Parse(IAspxSource source, AspxNode root)
        {
            if (currentFiles.Add(source.Name))
            {
                var previousCurrentNode = currentNode;
                currentNode = root;

                var parser = new Parser(this, isFw40, source);
                parser.Parse();

                currentNode = previousCurrentNode;
                currentFiles.Remove(source.Name);
            }
            else
            {
                AddError(new Location(source, 0, 0), "Circular file include.");
            }
        }
Пример #5
0
        public Location(IAspxSource source, int start, int end)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (start < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(start));
            }

            if (start > end)
            {
                throw new ArgumentOutOfRangeException(nameof(end));
            }

            Start       = start;
            Length      = end - start;
            this.source = source;
        }