/// <summary> Create a new remark node.</summary> /// <param name="page">The page the node is on. /// </param> /// <param name="start">The beginning position of the remark. /// </param> /// <param name="end">The ending position of the remark. /// </param> /// <returns> A remark node comprising the indicated characters from the page. /// </returns> public virtual IRemark CreateRemarkNode(Page page, int start, int end) { IRemark ret; try { ret = (IRemark)(RemarkPrototype.Clone()); ret.Page = page; ret.StartPosition = start; ret.EndPosition = end; } catch { ret = new RemarkNode(page, start, end); } return(ret); }
private void ReadIndex() { string text = File.ReadAllText(indexPath); Lexer lexer = new Lexer(text); Parser parser = new Parser(lexer); NodeList htmlNodes = parser.Parse(new OrFilter(new NodeClassFilter(typeof(RemarkNode)), new NodeClassFilter(typeof(ScriptTag)))); MergeJSData mergeJSData = null; for (int i = 0; i < htmlNodes.Count; i++) { var node = htmlNodes[i]; ScriptTag script = node as ScriptTag; RemarkNode remark = node as RemarkNode; if (remark != null) { string remarkText = remark.GetText(); if (remarkText.StartsWith("MergeJSBegin")) { mergeJSData = new MergeJSData(); mergeJSData.name = remarkText.Split(":")[1].Trim(); list.Add(mergeJSData); } else if (remarkText.StartsWith("MergeJSEnd")) { mergeJSData = null; } } if (script != null) { if (mergeJSData != null) { mergeJSData.AddPath(script.GetAttribute("src")); } } } }
/// <summary> Create a new remark node.</summary> /// <param name="page">The page the node is on. /// </param> /// <param name="start">The beginning position of the remark. /// </param> /// <param name="end">The ending position of the remark. /// </param> /// <returns> A remark node comprising the indicated characters from the page. /// </returns> public virtual IRemark CreateRemarkNode(Page page, int start, int end) { IRemark ret; try { ret = (IRemark) (RemarkPrototype.Clone()); ret.Page = page; ret.StartPosition = start; ret.EndPosition = end; } catch { ret = new RemarkNode(page, start, end); } return (ret); }
private Node ParseParagraph() { Token <TokenType> t = PeekNextToken(); ParaNode node = new ParaNode(); while (!t.End) { switch (t.TokenType) { case TokenType.If: node.ParamNodes.Add(ParseIfBlock()); break; case TokenType.For: node.ParamNodes.Add(ParseForBlock()); break; case TokenType.Let: LetNode let = new LetNode(GetNextToken()); node.ParamNodes.Add(let); break; case TokenType.Remark: RemarkNode rem = new RemarkNode(GetNextToken()); node.ParamNodes.Add(rem); break; case TokenType.Expression: case TokenType.Text: SimpleNode sNode = new SimpleNode(GetNextToken()); node.ParamNodes.Add(sNode); break; case TokenType.Include: IncludeNode include = new IncludeNode(GetNextToken()); node.ParamNodes.Add(include); break; case TokenType.Else: //Note: if next token is else, then the trueNode of if is finished. case TokenType.End: if (node.ParamNodes.Count == 1) { return(node.ParamNodes[0]); } else { return(node); } case TokenType.Break: GetNextToken(); node.ParamNodes.Add(new BreakNode()); break; case TokenType.Continue: GetNextToken(); node.ParamNodes.Add(new ContinueNode()); break; } t = PeekNextToken(); } if (node.ParamNodes.Count == 1) { return(node.ParamNodes[0]); } else { return(node); } }