Esempio n. 1
0
        internal static WordsData instance(string[] names)
        {
            Hashtable operators = new Hashtable();

            string[] ops = sort(names);
            Lexer[]  lxs = new Lexer[ops.Length];
            for (int i = 0; i < ops.Length; i++)
            {
                string  s       = ops[i];
                Scanner scanner = s.Length == 1 ? Scanners.IsChar(s[0]) : Scanners.IsString(s);
                object  tok     = Tokens.CreateReservedWordToken(s);
                operators[s] = tok;
                Lexer lx = Lexers.Lex(scanner, Tokenizers.ForValue(tok));
                lxs[i] = lx;
            }
            return(new WordsData(Functors.AsMap <string, object>(operators), lxs));
        }
Esempio n. 2
0
 /// <summary> Create a lexer that parsers a string literal quoted by open and close,
 /// and then converts it to a String token instance.
 /// </summary>
 /// <param name="open">the opening character.
 /// </param>
 /// <param name="close">the closing character.
 /// </param>
 /// <returns> the lexer.
 /// </returns>
 public static Lexer LexQuotedString(char open, char close)
 {
     return(Lex(Scanners.IsQuotedBy(open, close),
                Tokenizers.ForQuotedString(open, close)).Rename("quoted string literal"));
 }