Skip to content

Commit

Permalink
discussion #468
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Aug 1, 2024
1 parent f34c262 commit ab0e2c4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/ParserTests/Discussion468/Discussion468Lexer.cs
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

}
}
52 changes: 52 additions & 0 deletions tests/ParserTests/Discussion468/Discussion468Tests.cs
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);

}


}
}

0 comments on commit ab0e2c4

Please sign in to comment.