Пример #1
0
 private MarkdownParsingResult <INode> ParseAnyTokenAsText(ITokenizer <IMdToken> tokenizer)
 {
     if (tokenizer.AtEnd)
     {
         return(tokenizer.Fail <INode>());
     }
     return(tokenizer.Advance().SuccessWith <INode>(new TextNode(tokenizer.CurrentToken.Text)));
 }
 public static MarkdownParsingResult <IMdToken> Match(this ITokenizer <IMdToken> tokenizer,
                                                      Predicate <IMdToken> predicate)
 {
     if (tokenizer.AtEnd || !predicate(tokenizer.CurrentToken))
     {
         return(tokenizer.Fail <IMdToken>());
     }
     return(tokenizer.Advance().SuccessWith(tokenizer.CurrentToken));
 }
Пример #3
0
        private MarkdownParsingResult <INode> ParseAnyTokenAsEscaped(ITokenizer <IMdToken> tokenizer)
        {
            if (tokenizer.AtEnd)
            {
                return(tokenizer.Fail <INode>());
            }
            var underlyingText = tokenizer.CurrentToken.UnderlyingText;

            return(tokenizer.Advance().SuccessWith <INode>(new EscapedTextNode(underlyingText)));
        }
        public static MarkdownParsingResult <List <IMdToken> > UntilMatch(this ITokenizer <IMdToken> tokenizer,
                                                                          Predicate <IMdToken> predicate)
        {
            var tokens = new List <IMdToken>();

            while (!tokenizer.AtEnd)
            {
                var token = tokenizer.CurrentToken;
                if (!predicate(token))
                {
                    return(tokenizer.SuccessWith(tokens));
                }
                tokenizer = tokenizer.Advance();
                tokens.Add(token);
            }
            return(tokenizer.SuccessWith(tokens));
        }
Пример #5
0
 private MarkdownParsingResult <IMdToken> SkipSingleToken(ITokenizer <IMdToken> tokenizer)
 {
     return(tokenizer.Advance().SuccessWith(tokenizer.CurrentToken));
 }