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); }
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; }
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); }