Skip to content

Commit

Permalink
Added Matcher Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ddwightx committed Apr 21, 2022
1 parent 70f50be commit 956dfc0
Show file tree
Hide file tree
Showing 60 changed files with 11,185 additions and 7,341 deletions.
2,360 changes: 1,177 additions & 1,183 deletions src/Matcher.Interop.Ebnf/CharacterClassMatchEngine.cs

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions src/Matcher.Interop.Ebnf/EbnfConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ public class EbnfConverter
private Dictionary<string, ValueTuple<FragmentMatcher, FragmentMatchData>> _fragmentMatcherMap;
private string _ebnfText = null;

public bool IgnoreWhitespace
{
get;
set;
}

public List<FragmentMatcher> DefaultFragments
{
get;
Expand All @@ -29,14 +35,22 @@ public LanguageMatcher Convert(string name, string ebnfText)
_ebnfText = ebnfText;
_patternMatcherMap = new Dictionary<string, PatternMatcher>(StringComparer.Ordinal);
_fragmentMatcherMap = new Dictionary<string, ValueTuple<FragmentMatcher, FragmentMatchData>>(StringComparer.Ordinal);

_languageMatcher = new LanguageMatcher()
{
Name = name,
Patterns = new List<PatternMatcher>(),
Fragments = new List<FragmentMatcher>()

};

if (IgnoreWhitespace)
{

PatternMatcher whitepacePattern = PatternReader.Parse(-2, "IgnoredWhitespace", "\\s+");
whitepacePattern.IsNoise = true;
_languageMatcher.Patterns.Add(whitepacePattern);
}

MatcherResult matcherResult = _ebnfMatchEngine.Match(ebnfText);

if (!matcherResult.Success)
Expand All @@ -51,7 +65,7 @@ public LanguageMatcher Convert(string name, string ebnfText)

AddRules((FragmentMatchData)matcherResult.MatchData);

_languageMatcher.IndexingMode = IndexingMode.Lazy;
_languageMatcher.IndexingMode = IndexingMode.Eager;
_languageMatcher.StartingFragment = _languageMatcher.Fragments.FirstOrDefault();

return _languageMatcher;
Expand Down
Loading

0 comments on commit 956dfc0

Please sign in to comment.