Skip to content

Commit

Permalink
fix #487
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed Oct 15, 2024
1 parent 4e01010 commit cca2219
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/samples/ParserExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1629,10 +1629,14 @@ private static void TestLexerPostProcessEBNF()

private static void TestIssue487()
{
string source = "@calc1 >> toconvert: @calc2";
string source = "@g_capcalc >> EtnRef: @appcapcalc.bankcapconfigid";
var lexBuild = LexerBuilder.BuildLexer<Issue487Token>();

Check.That(lexBuild).IsOk();

var lexer = lexBuild.Result;
var lexer487 = lexer as GenericLexer<Issue487Token>;
var gviz = lexer487.FSMBuilder.Fsm.ToGraphViz();
var lexed = lexer.Tokenize(source);
if (lexed.IsOk)
{
Expand Down
3 changes: 2 additions & 1 deletion src/sly/lexer/GenericLexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,10 @@ public void AddKeyWord(IN token, string keyword, bool isPop, bool isPush, bool i

AddLexeme(GenericToken.Identifier, result, token, isPop, isPush, mode, keyword);
var node = FSMBuilder.GetNode(in_identifier);
FSMBuilder.GoTo(in_identifier);
if (!FSMBuilder.Fsm.HasCallback(node.Id))
{
FSMBuilder.GoTo(in_identifier).CallBack(callback);
FSMBuilder.CallBack(callback);
}
}

Expand Down
18 changes: 9 additions & 9 deletions tests/ParserTests/Issue487/TestIssue487.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public void TestIssue487()
var lexer = lexBuild.Result;
var lexed = lexer.Tokenize(source);
Check.That(lexed).IsOkLexing();
Check.That(lexed.Tokens.Take(lexed.Tokens.Count-1).Extracting(x => (x.TokenID, x.Value)).ToList())
.IsEqualTo(new List<(Issue487Token, string)>()
Check.That(lexed.Tokens.Take(lexed.Tokens.Count-1).Extracting(x => (x.TokenID, x.Value, x.Position.Mode)).ToList())
.IsEqualTo(new List<(Issue487Token, string, string)>()
{
(Issue487Token.START_D, "@"),
(Issue487Token.OPS, "dmode1"),
(Issue487Token.INSTALL, ">>"),
(Issue487Token.CONVERT, "convert"),
(Issue487Token.COLON, ":"),
(Issue487Token.START_D, "@"),
(Issue487Token.OPS, "dmode2")
(Issue487Token.START_D, "@","dmode"),
(Issue487Token.OPS, "dmode1","dmode"),
(Issue487Token.INSTALL, ">>","default"),
(Issue487Token.CONVERT, "convert","convert"),
(Issue487Token.COLON, ":","convert"),
(Issue487Token.START_D, "@","dmode"),
(Issue487Token.OPS, "dmode2","dmode")
});
}
}

0 comments on commit cca2219

Please sign in to comment.