//========================================================================================= internal StateParser(StateScanner scanner) : this() { this.Scanner = scanner; this.Spec = new ParserSpecification(); this.Settings = new NonSyntaxSettings(); }
//========================================================================================= public StateParser(SyntaxSettings settings, int tabsize) : this() { this.Settings = settings; ScannerSpecification oScannerSpec = this.Settings.CreateScannerSpecification(); this.Scanner = new StateScanner(oScannerSpec, tabsize); this.Spec = this.Settings.CreateParserSpecification(oScannerSpec); }
//========================================================================================= internal override ParserSpecification CreateParserSpecification(ScannerSpecification scannerSpecification) { var oSpec = new ParserSpecification(); oSpec.AddRule("Tag", "lt?separator? id?tagName? {id?attribute? eq?separator? attrValue?attributeValue?} gt?separator?"); oSpec.AddRule("Comment", "comment?comments?"); oSpec.AddRule("Cdata", "cdata?cdata?"); return oSpec; }
//========================================================================================= internal virtual ParserSpecification CreateParserSpecification(ScannerSpecification scannerSpecification) { ///Создание спецификации для парсера ПО УМОЛЧАНИЮ. ///По умолчанию все правила состоят из одного токена. var oSpec = new ParserSpecification(); Dictionary<string, string> ruleNames = new Dictionary<string, string>(); ///Найдем все упоминающиеся имена токенов и включим foreach (var oState in scannerSpecification.States) { string sTokenName = oState.ResultTokenName; if (!string.IsNullOrEmpty(sTokenName) && !ruleNames.ContainsKey(sTokenName)) { oSpec.AddRule(sTokenName, sTokenName); ruleNames.Add(sTokenName, sTokenName); } } return oSpec; }
//========================================================================================= private StateParser() { this.Errors = new List<string>(); this.TokenPool = new Queue<Token>(); this.Spec = new ParserSpecification(); }
//========================================================================================= private StateParser() { this.Errors = new List <string>(); this.TokenPool = new Queue <Token>(); this.Spec = new ParserSpecification(); }