/// <summary> /// Get NextToken and verify if it exists /// </summary> /// <param name="name">Name of expected token</param> /// <param name="syntax">Syntax of expected token</param> /// <returns>True if new token found, otherwise false</returns> protected bool NextToken(String name, String syntax) { if (TokenStream.HasNext()) { CurrentToken = TokenStream.NextToken(); return(true); } else { //Unexpected token throw new UnexpectedToken("Unexpected token found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine()); } }
/// <summary> /// Parser for TextTail /// </summary> /// <returns>Parsed TextTail</returns> public TextTail ParseTextTail() { TextTail textTail = null; //Skip > token NextToken(">", "> embedding tailsymbol", '>'); //Parse text first to make type determination possible String parsedText = ParseTextChars(); //Determine TextTail type if (EmbeddingTokenStream.HasNext() && EmbeddingTokenStream.Peek(1).GetValue().ToString() == "\"") { //PostTextTail //Set PostText PostText postText = new PostText(); postText.SetText(parsedText); //Create PostTextTail and fill it PostTextTail postTextTail = new PostTextTail(); postTextTail.SetPostText(postText); //Skip Closing " NextToken("\"", "\"", '\"'); textTail = postTextTail; } else { //MidTextTail //Skip closing < tag of PreText NextToken("<", "< closing PreText", '<'); //Set MidText MidText midText = new MidText(); midText.SetText(parsedText); //Create MidTextTail object and fill it MidTextTail midTextTail = new MidTextTail(); midTextTail.SetMidText(midText); midTextTail.SetEmbed(ParseEmbed()); midTextTail.SetTextTail(ParseTextTail()); textTail = midTextTail; } return(textTail); }