Skip to content

Commit

Permalink
Merge 84dba0e into 28275f5
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Jun 7, 2019
2 parents 28275f5 + 84dba0e commit 292947b
Show file tree
Hide file tree
Showing 17 changed files with 324 additions and 196 deletions.
23 changes: 16 additions & 7 deletions ParserTests/comments/CommentsTestAlternative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public void NotEndingMultiComment()
2 /* not ending
comment";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(4, tokens.Count);

Expand Down Expand Up @@ -73,7 +75,9 @@ public void TestGenericMultiLineComment()
2 /* multi line
comment on 2 lines */ 3.0";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down Expand Up @@ -111,9 +115,11 @@ public void TestGenericSingleLineComment()

var dump = lexer.ToString();

var tokens = lexer.Tokenize(@"1
var r = lexer.Tokenize(@"1
2 // single line comment
3.0").ToList();
3.0");
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down Expand Up @@ -154,7 +160,9 @@ public void TestInnerMultiComment()
4
";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(6, tokens.Count);

Expand Down Expand Up @@ -199,8 +207,9 @@ public void TestMixedEOLComment()

var dump = lexer.ToString();
var code = "1\n2\r\n/* multi line \rcomment on 2 lines */ 3.0";
List<Token<CommentsTokenAlternative>> tokens = null;
tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down
24 changes: 17 additions & 7 deletions ParserTests/comments/CommentsTestGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public void NotEndingMultiComment()
2 /* not ending
comment";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(4, tokens.Count);

Expand Down Expand Up @@ -72,7 +74,9 @@ public void TestGenericMultiLineComment()
2 /* multi line
comment on 2 lines */ 3.0";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down Expand Up @@ -111,9 +115,11 @@ public void TestGenericSingleLineComment()
var dump = lexer.ToString();


var tokens = lexer.Tokenize(@"1
var r = lexer.Tokenize(@"1
2 // single line comment
3.0").ToList();
3.0");
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down Expand Up @@ -156,7 +162,9 @@ public void TestInnerMultiComment()
4
";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(6, tokens.Count);

Expand Down Expand Up @@ -203,8 +211,10 @@ public void TestMixedEOLComment()

var dump = lexer.ToString();
var code = "1\n2\r\n/* multi line \rcomment on 2 lines */ 3.0";
List<Token<CommentsToken>> tokens = null;
tokens = lexer.Tokenize(code).ToList();

var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down
27 changes: 16 additions & 11 deletions ParserTests/comments/MultiLineCommentsTest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using sly.buildresult;
Expand Down Expand Up @@ -33,7 +34,9 @@ public void NotEndingMultiComment()
2 /* not ending
comment";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(4, tokens.Count);

Expand Down Expand Up @@ -72,7 +75,9 @@ public void TestGenericMultiLineComment()
2 /* multi line
comment on 2 lines */ 3.0";

var tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down Expand Up @@ -110,13 +115,11 @@ public void TestGenericSingleLineComment()

var dump = lexer.ToString();

var error = Assert.Throws<LexerException>(() =>
{
lexer.Tokenize(@"1
var r = lexer.Tokenize(@"1
2 // single line comment
3.0");
});
Assert.Equal('/', error.Error.UnexpectedChar);
Assert.True(r.IsError);
Assert.Equal('/', r.Error.UnexpectedChar);
}

[Fact]
Expand All @@ -133,8 +136,9 @@ public void TestInnerMultiComment()
4
";

var tokens = lexer.Tokenize(code).ToList();

var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;
Assert.Equal(6, tokens.Count);

var token1 = tokens[0];
Expand Down Expand Up @@ -178,8 +182,9 @@ public void TestMixedEOLComment()

var dump = lexer.ToString();
var code = "1\n2\r\n/* multi line \rcomment on 2 lines */ 3.0";
List<Token<MultiLineCommentsToken>> tokens = null;
tokens = lexer.Tokenize(code).ToList();
var r = lexer.Tokenize(code);
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down
17 changes: 9 additions & 8 deletions ParserTests/comments/SingleLineCommentsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ public void TestGenericMultiLineCommentWithSingleLineComment()

var dump = lexer.ToString();

var error = Assert.Throws<LexerException>(() =>
{
lexer?.Tokenize(@"1
var r =lexer?.Tokenize(@"1
2 /* multi line
comment on 2 lines */ 3.0").ToList();
});
Assert.Equal('*', error.Error.UnexpectedChar);
comment on 2 lines */ 3.0");
Assert.True(r.IsError);
var tokens = r.Tokens;
Assert.Equal('*', r.Error.UnexpectedChar);
}

[Fact]
Expand All @@ -48,9 +47,11 @@ public void TestGenericSingleLineComment()

var dump = lexer.ToString();

var tokens = lexer.Tokenize(@"1
var r = lexer.Tokenize(@"1
2 // single line comment
3.0").ToList();
3.0");
Assert.True(r.IsOk);
var tokens = r.Tokens;

Assert.Equal(5, tokens.Count);

Expand Down
Loading

0 comments on commit 292947b

Please sign in to comment.