예제 #1
0
파일: Terms.cs 프로젝트: leontius/Ragnarok
        /// <summary> gets a Parser object to parse TokenQuoted.</summary>
        /// <param name="fc">the mapping to map the quoted string to an object returned by the parser.
        /// </param>
        /// <returns> the parser
        /// </returns>
        public static Parser <T> OnQuotedWord <T>(FromRange <string, string, string, T> fc)
        {
            FromToken <T> recognizer = delegate(Tok tok, ref T result)
            {
                object obj = tok.Token;
                if (obj is TokenQuoted)
                {
                    TokenQuoted quoted = obj as TokenQuoted;
                    result = fc(tok.Index, tok.Length, quoted.Open, quoted.Quoted, quoted.Close);
                    return(true);
                }
                else
                {
                    return(false);
                }
            };

            return(Parsers.FromToken(recognizer));
        }
예제 #2
0
 public bool Equals(TokenQuoted other)
 {
     return(open.Equals(other.open) && close.Equals(other.close) && quoted.Equals(other.quoted));
 }
예제 #3
0
 /// <summary> creates a Tokenizer instance that can parse a string quoted by open and close.</summary>
 /// <param name="open">the opening quote
 /// </param>
 /// <param name="close">the closeing quote
 /// </param>
 /// <returns> the tokenizer.
 /// </returns>
 public static Tokenizer ForQuotedString(string open, string close)
 {
     return(TokenQuoted.GetTokenizer(open, close));
 }
예제 #4
0
 /// <summary> creates a Tokenizer instance that can parse a string quoted by open and close.</summary>
 /// <param name="open">the open quote
 /// </param>
 /// <param name="close">the close quote
 /// </param>
 /// <returns> the tokenizer.
 /// </returns>
 public static Tokenizer ForQuotedString(char open, char close)
 {
     return(TokenQuoted.GetTokenizer(open, close));
 }