Beispiel #1
0
 private static ILexerRule CreateWhitespaceLexerRule()
 {
     var whitespaceTerminal = new WhitespaceTerminal();
     var startWhitespace = new DfaState();
     var finalWhitespace = new DfaState(true);
     startWhitespace.AddEdge(new DfaEdge(whitespaceTerminal, finalWhitespace));
     finalWhitespace.AddEdge(new DfaEdge(whitespaceTerminal, finalWhitespace));
     var whitespace = new DfaLexerRule(startWhitespace, new TokenType("whitespace"));
     return whitespace;
 }
Beispiel #2
0
 private static ILexerRule CreateRuleNameLexerRule()
 {
     var ruleNameState = new DfaState();
     var zeroOrMoreLetterOrDigit = new DfaState(true);
     ruleNameState.AddEdge(
         new DfaEdge(
             new CharacterClassTerminal(
                 new RangeTerminal('a', 'z'),
                 new RangeTerminal('A', 'Z')),
             zeroOrMoreLetterOrDigit));
     zeroOrMoreLetterOrDigit.AddEdge(
         new DfaEdge(
             new CharacterClassTerminal(
                 new RangeTerminal('a', 'z'),
                 new RangeTerminal('A', 'Z'),
                 new DigitTerminal(),
                 new SetTerminal('-', '_')),
             zeroOrMoreLetterOrDigit));
     var ruleName = new DfaLexerRule(ruleNameState, new TokenType("rule-name"));
     return ruleName;
 }