-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
90 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using NFluent; | ||
using sly.lexer; | ||
using sly.parser; | ||
using Xunit; | ||
|
||
namespace ParserTests.Issue501; | ||
|
||
public class Issue501Tests | ||
{ | ||
[Fact] | ||
public void TestIssue501() | ||
{ | ||
var build = LexerBuilder.BuildLexer<Issue501Token>(); | ||
Check.That(build).IsOk(); | ||
Check.That(build.Result).IsNotNull(); | ||
Check.That(build.Result).IsInstanceOf<GenericLexer<Issue501Token>>(); | ||
var lexer = build.Result as GenericLexer<Issue501Token>; | ||
var source = @"test = 3"; | ||
var lexed = lexer.Tokenize(source); | ||
Check.That(lexed).IsOkLexing(); | ||
var tokens = lexed.Tokens; | ||
Check.That(tokens).IsNotNull(); | ||
var mainTokens = tokens.MainTokens(); | ||
Check.That(mainTokens).CountIs(4); | ||
Check.That(mainTokens.Last().IsEOS).IsTrue(); | ||
Check.That(mainTokens.Take(3).Select(x => x.TokenID)).IsEquivalentTo(new List<Issue501Token>() | ||
{ Issue501Token.Identifier, Issue501Token.Assign, Issue501Token.Number }); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserTests.Issue501; | ||
|
||
public enum Issue501Token | ||
{ | ||
[Keyword("import")] | ||
[Push("importMode")] | ||
ImportKeyword, | ||
[UpTo(";")] | ||
[Mode("importMode")] | ||
ImportContent, | ||
[Sugar(";")] | ||
[Mode("importMode")] | ||
[Pop] | ||
EndImport, | ||
|
||
[AlphaNumDashId] | ||
Identifier, | ||
[Int] | ||
Number, | ||
[Sugar("=")] | ||
Assign | ||
} |