-
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.
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using sly.lexer; | ||
|
||
namespace ParserTests.Discussion468 | ||
{ | ||
public enum Discussion468Lexer | ||
{ | ||
[CustomId("_.:a-zA-Z","_.:0-9a-zA-Z")] | ||
INDENTIFIER | ||
|
||
} | ||
} |
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,52 @@ | ||
using System.Linq; | ||
using expressionparser; | ||
using NFluent; | ||
using simpleExpressionParser; | ||
using sly.lexer; | ||
using sly.parser; | ||
using sly.parser.generator; | ||
using Xunit; | ||
|
||
namespace ParserTests.Discussion468 | ||
{ | ||
public class Discussion468Tests | ||
{ | ||
|
||
|
||
|
||
private static void CheckId(ILexer<Discussion468Lexer> lexer,string source, bool isOk) | ||
{ | ||
|
||
var lexingResult = lexer.Tokenize(source); | ||
if (isOk) | ||
{ | ||
Check.That(lexingResult).IsOkLexing(); | ||
var tokens = lexingResult.Tokens; | ||
Check.That(tokens).IsNotNull(); | ||
Check.That(tokens).CountIs(2); | ||
var idToken = tokens[0]; | ||
Check.That(idToken.TokenID).IsEqualTo(Discussion468Lexer.INDENTIFIER); | ||
Check.That(idToken.Value).IsEqualTo(source); | ||
} | ||
else | ||
{ | ||
Check.That(lexingResult).Not.IsOkLexing(); | ||
} | ||
} | ||
|
||
[Fact] | ||
public static void Test468() | ||
{ | ||
var buildResult = LexerBuilder.BuildLexer<Discussion468Lexer>(); | ||
Check.That(buildResult).IsOk(); | ||
var lexer = buildResult.Result; | ||
Check.That(lexer).IsNotNull(); | ||
CheckId(lexer,"_:word1234",true); | ||
CheckId(lexer,"word_1234.otherword",true); | ||
CheckId(lexer,"1_:word1234",false); | ||
|
||
} | ||
|
||
|
||
} | ||
} |