Skip to content

Commit

Permalink
code coverage and dead code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b00 committed May 2, 2024
1 parent fe66990 commit 911c802
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/sly/lexer/LexerResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace sly.lexer
{
public class LexerResult<IN> where IN : struct
Expand Down Expand Up @@ -29,6 +31,7 @@ public LexerResult(LexicalError error, List<Token<IN>> tokens)
SetTokens(tokens);
}

[ExcludeFromCodeCoverage]
public override string ToString()
{
if (IsOk)
Expand Down
2 changes: 2 additions & 0 deletions src/sly/lexer/TokenChannels.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace sly.lexer
Expand Down Expand Up @@ -116,6 +117,7 @@ IEnumerator IEnumerable.GetEnumerator()
return Tokens.GetEnumerator();
}

[ExcludeFromCodeCoverage]
public override string ToString()
{
return string.Join("\n", _tokenChannels.Values.Select(x => x.ToString()).ToArray());
Expand Down
15 changes: 2 additions & 13 deletions src/sly/parser/syntax/grammar/Rule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -33,19 +34,6 @@ public Rule()

public string RuleString { get; set; }

public string Key
{
get
{
var key = string.Join("_", Clauses.Select(c => c.ToString()));

if (Clauses.Count == 1)
key += "_";

return IsExpressionRule ? key.Replace(" | ", "_") : key;
}
}

public List<IClause<IN>> Clauses { get; set; }
public List<LeadingToken<IN>> PossibleLeadingTokens { get; set; }

Expand Down Expand Up @@ -171,6 +159,7 @@ public bool Match<OUT>(IList<Token<IN>> tokens, int position, ParserConfiguratio
return PossibleLeadingTokens.Exists(x => x.Match(tokens[position])) || MayBeEmpty;
}

[ExcludeFromCodeCoverage]
public string Dump()
{
StringBuilder builder = new StringBuilder();
Expand Down

0 comments on commit 911c802

Please sign in to comment.