Esempio n. 1
0
        public void RunFile(string fileName)
        {
            var reader      = CharReader.File(fileName);
            var tokenReader = new TokenizerContext(reader, tokenizers);

            analyzer
            .Analyze(new ParserContext(ParserRules, tokenReader).Parse())
            .WriteTo(vmw);

            vmw.Run();
        }
Esempio n. 2
0
        /// <summary>
        /// Turns the given string into a token. The string is added to a list of
        /// custom symbols, in case it's not covered by any of the tokenizers,
        /// to ensure it's parsed as a whole token.
        /// </summary>
        public Token GetToken(string str)
        {
            var tokenizer = new TokenizerContext(CharReader.String(str), tokenizers);

            if (tokenizer.Next())
            {
                var token = tokenizer.Current;
                if (!tokenizer.Next())
                {
                    return(token);
                }
            }

            symbols.Add(str);
            symbols.Sort((a, b) => b.Length - a.Length);
            return(new Token(str, CustomTokenizer));
        }