示例#1
0
        /// <summary>
        /// Initializes this lexer reflection
        /// </summary>
        /// <param name="lexerType">The lexer's type</param>
        public LexerReflection(System.Type lexerType)
        {
            ConstructorInfo ctor  = lexerType.GetConstructor(new [] { typeof(string) });
            BaseLexer       lexer = ctor.Invoke(new object[] { "" }) as BaseLexer;

            string[] resources = lexerType.Assembly.GetManifestResourceNames();
            Stream   stream    = null;

            foreach (string existing in resources)
            {
                if (existing.EndsWith(lexerType.Name + ".bin"))
                {
                    stream = lexerType.Assembly.GetManifestResourceStream(existing);
                    break;
                }
            }

            BinaryReader reader    = new BinaryReader(stream);
            Automaton    automaton = new Automaton(reader);

            reader.Close();

            LoadTerminals(lexer);
            LoadDFA(automaton);
        }
示例#2
0
        /// <summary>
        /// Loads the terminals from the specified lexers
        /// </summary>
        /// <param name="lexer">The lexer to investigate</param>
        private void LoadTerminals(BaseLexer lexer)
        {
            terminals = new List <Terminal>();
            terminals.Add(Epsilon.Instance);
            terminals.Add(Dollar.Instance);
            ROList <Hime.Redist.Symbol> spec = lexer.Terminals;

            for (int i = 2; i != spec.Count; i++)
            {
                Hime.Redist.Symbol symbol = spec[i];
                terminals.Add(new Terminal(symbol.ID, symbol.Name, "", null, 0));
            }
        }