EatComments() private method

Eat all comments from the matches, so we get a clean list wihtout any comments. Put the whole comment into one token.
private EatComments ( ) : void
return void
Exemplo n.º 1
0
        public void BlockComment_In_One_Line()
        {
            const string text = " asdölfkj asdfj asdölkjfas  asdflj /* asöldkfjasdfölkjhas dfhööhasdf */ hö\r\nas dlfjhas dflasd fasdlkfh ";

              var lex = new Lexer(text) {Matches = Helper.SplitText(text) };

              lex.EatComments();

              Assert.AreEqual(1, lex.Tokens.Count);
              Assert.AreEqual(0, lex.Errors.Count);
              Assert.AreEqual(0, lex.Index);
              Assert.AreEqual(10, lex.Matches.Count);

              Assert.AreEqual(35, lex.Tokens[0].Position);
              Assert.AreEqual(36, lex.Tokens[0].Length);
              Assert.AreEqual(0, lex.Line);
        }
Exemplo n.º 2
0
        public void LineComment_until_EOF()
        {
            const string text = "  option farz = true;  // this is a comment until EOF";

              var lex = new Lexer(text) {Matches = Helper.SplitText(text) };

              lex.EatComments();

              Assert.AreEqual(1, lex.Tokens.Count);
              Assert.AreEqual(0, lex.Errors.Count);
              Assert.AreEqual(0, lex.Index);
              Assert.AreEqual(5, lex.Matches.Count);

              Assert.AreEqual(23, lex.Tokens[0].Position);
              Assert.AreEqual(30, lex.Tokens[0].Length);
              Assert.AreEqual(0, lex.Line);
        }
Exemplo n.º 3
0
        public void LineComment_without_EOF2()
        {
            const string text = " option farz = true;  // this is a comment until end of line\r\n message...";

              var lex = new Lexer(text) { Matches = Helper.SplitText(text) };

              lex.EatComments();

              Assert.AreEqual(1, lex.Tokens.Count);
              Assert.AreEqual(0, lex.Errors.Count);
              Assert.AreEqual(0, lex.Index);
              Assert.AreEqual(10, lex.Matches.Count);

              Assert.AreEqual(22, lex.Tokens[0].Position);
              Assert.AreEqual(38, lex.Tokens[0].Length);
              Assert.AreEqual(0, lex.Line);
        }
Exemplo n.º 4
0
        public void BlockComment_Over_Multiple_Lines_Until_EOF_Missing_EndComment()
        {
            const string text = " asdölfkj asdfj asdölkjfas  asdflj /* asöldkfjasdfölkjhas\r\n dfhöö \r\nhasdf";

              var lex = new Lexer(text) {Matches = Helper.SplitText(text) };

              lex.EatComments();

              Assert.AreEqual(1, lex.Tokens.Count);
              Assert.AreEqual(1, lex.Errors.Count);
              Assert.AreEqual(0, lex.Index);
              Assert.AreEqual(4, lex.Matches.Count);

              Assert.AreEqual(35, lex.Tokens[0].Position);
              Assert.AreEqual(38, lex.Tokens[0].Length);

              Assert.AreEqual(0, lex.Errors[0].Line);
              Assert.AreEqual(1, lex.Errors[0].Length);
              Assert.AreEqual(73, lex.Errors[0].Position);

              Assert.AreEqual(0, lex.Line);
        }