Пример #1
0
        public void GetCharacterTest()
        {
            const string inputFileName  = "input.txt";
            const string outputFileName = "output.txt";
            var          inputText      = string.Join(Environment.NewLine, new[] { "ab1", "qwe2", "asdf4" });

            File.WriteAllText(inputFileName, inputText);

            var inputOutputModule = new IoManager.IoManager(inputFileName, outputFileName);
            var stringBuilder     = new StringBuilder();

            while (!inputOutputModule.IsEndOfFile)
            {
                stringBuilder.Append(inputOutputModule.GetNextCharacter());
            }

            inputOutputModule.Dispose();
        }
Пример #2
0
        public void ScannerTest()
        {
            const string inputFileName  = "input.txt";
            const string outputFileName = "output.txt";
            //var inputText = "*  /  =  ,  ;  :  .  ^  (  )  [  ]  {  }  <  >  <=  >=  <>  +  -  //  (*  *)  :=  .. &";
            var inputText =
//@"function Even(x: integer): boolean;
//begin
//  Result := x mod 2 = 0
//end;

//begin
//  writeln(Even(3.0));
//  writeln(Even(4));
//  writeln(Even(7777777777777777));
//end.";
                @"// comment
(* comments 
 comments 
*)
while";

            File.WriteAllText(inputFileName, inputText);

            var inputOutputModule = new IoManager.IoManager(inputFileName, outputFileName);

            var scanner = new Tokenizer.Tokenizer(inputOutputModule);
            var tokens  = new List <Token>();

            while (!scanner.IsEndOfTokens)
            {
                tokens.Add(scanner.GetNextToken());
            }

            inputOutputModule.OutputStream.WriteLine();

            foreach (var token in tokens)
            {
                inputOutputModule.OutputStream.WriteLine(token.ToString());
            }

            inputOutputModule.Dispose();
        }