Пример #1
0
 public Token(CCompiler_Pre.Tokens id, object value)
 {
     m_id           = id;
     m_value        = value;
     m_newlineCount = CCompiler_Pre.Scanner.NewlineCount;
     CCompiler_Pre.Scanner.NewlineCount = 0;
 }
        private List <Token> Scan(string text)
        {
            byte[]       byteArray    = Encoding.ASCII.GetBytes(text);
            MemoryStream memoryStream = new MemoryStream(byteArray);

            CCompiler_Pre.Scanner scanner   = new CCompiler_Pre.Scanner(memoryStream);
            List <Token>          tokenList = new List <Token>();

            while (true)
            {
                CCompiler_Pre.Tokens tokenId = (CCompiler_Pre.Tokens)scanner.yylex();
                tokenList.Add(new Token(tokenId, scanner.yylval.name));

                if (tokenId == CCompiler_Pre.Tokens.EOF)
                {
                    break;
                }
            }

            /*do {
             * tokenId = (CCompiler_Pre.Tokens) scanner.yylex();
             * tokenList.Add(new Token(tokenId, scanner.yylval.name));
             * } while (tokenId != CCompiler_Pre.Tokens.EOF);*/

            memoryStream.Close();
            return(tokenList);
        }
Пример #3
0
 public Token(CCompiler_Pre.Tokens id, object value, int newlineCount)
 {
     m_id           = id;
     m_value        = value;
     m_newlineCount = newlineCount;
 }