Beispiel #1
0
        public Ruleset Parse(string input, string fileName)
        {
            Tokenizer.SetupInput(input);
            ParsingException parsingException = null;
            Ruleset          root             = null;

            try
            {
                Tokenizer.SetupInput(input);

                var parsers = new Parsers(NodeProvider);
                root = new Root(parsers.Primary(this), e => GenerateParserError(e, fileName));
            }
            catch (ParsingException e)
            {
                parsingException = e;
            }

            if (Tokenizer.HasCompletedParsing() && parsingException == null)
            {
                return(root);
            }

            throw GenerateParserError(parsingException, fileName);
        }
Beispiel #2
0
        public Ruleset Parse(string input, string fileName)
        {
            Ruleset root;

            FileName = fileName;

            try
            {
                Tokenizer.SetupInput(input, fileName);

                var parsers = new Parsers(NodeProvider);
                root = new Root(parsers.Primary(this), GenerateParserError);
            }
            catch (ParsingException e)
            {
                throw GenerateParserError(e);
            }

            if (!Tokenizer.HasCompletedParsing())
            {
                throw GenerateParserError(new ParsingException("Content after finishing parsing (missing opening bracket?)", Tokenizer.GetNodeLocation(Tokenizer.Location.Index)));
            }

            return(root);
        }
Beispiel #3
0
        public Ruleset Parse(string input, string fileName)
        {
            Ruleset root;
            FileName = fileName;

            try
            {
                Tokenizer.SetupInput(input, fileName);

                var parsers = new Parsers(NodeProvider);
                root = new Root(parsers.Primary(this), GenerateParserError);
            }
            catch (ParsingException e)
            {
                throw GenerateParserError(e);
            }

            if (!Tokenizer.HasCompletedParsing())
                throw GenerateParserError(new ParsingException("Content after finishing parsing (missing opening bracket?)", Tokenizer.GetNodeLocation(Tokenizer.Location.Index)));

            return root;
        }
Beispiel #4
0
        public Ruleset Parse(string input,  string fileName)
        {
            Tokenizer.SetupInput(input);
            ParsingException parsingException = null;
            Ruleset root = null;

            try
            {
                Tokenizer.SetupInput(input);

                var parsers = new Parsers(NodeProvider);
                root = new Root(parsers.Primary(this), e => GenerateParserError(e, fileName));
            }
            catch (ParsingException e)
            {
                parsingException = e;
            }

            if (Tokenizer.HasCompletedParsing() && parsingException == null)
                return root;

            throw GenerateParserError(parsingException, fileName);
        }
Beispiel #5
0
        public Ruleset Parse(string input, string fileName)
        {
            var cacheKey = input.GetHashCode() ^ fileName.GetHashCode();

            Ruleset cached;
            if (!NoCache && Cached.TryGetValue(cacheKey, out cached))
            {
                var ret = (Ruleset)cached.Copy();
                return ret;
            }

            Tokenizer.SetupInput(input);
            ParsingException parsingException = null;
            Ruleset root = null;

            try
            {
                Tokenizer.SetupInput(input);

                var parsers = new Parsers(new DefaultNodeProvider());
                root = new Root(parsers.Primary(this), e => GenerateParserError(e, fileName));
            }
            catch (ParsingException e)
            {
                parsingException = e;
            }

            if (Tokenizer.HasCompletedParsing() && parsingException == null)
            {
                Cached.TryAdd(cacheKey, root);

                var ret = (Ruleset)root.Copy();

                return ret;
            }

            throw GenerateParserError(parsingException, fileName);
        }