using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Rokojori
{  
  public class CSharpLexer:Lexer
  {
    public static List<LexerEvent> Lex( string source )
    {
      var lexer = new CSharpLexer();
      var events = lexer.LexToList( source );      

      if ( lexer.hasError )
      {
        return null;
      }

      events.ForEach( ev => { ev.GrabMatch( source ); } );
      return events;
    }

    public CSharpLexer()
    {
      AddAllMatchers(
        LexerMatcherLibrary.SingleLineCommentMatcher,
        LexerMatcherLibrary.MultiLineCommentMatcher,
        LexerMatcherLibrary.DoubleQuotedStringMatcher,
        LexerMatcherLibrary.SingleQuotedStringMatcher,
        LexerMatcherLibrary.CInstructionMatcher,
        LexerMatcherLibrary.NumberMatcher,
        LexerMatcherLibrary.NullMatcher,
        LexerMatcherLibrary.BoolMatcher,
        LexerMatcherLibrary.BreakMatcher,
        LexerMatcherLibrary.WhiteSpaceMatcher,
        LexerMatcherLibrary.LogicMatcher,
        LexerMatcherLibrary.BracketMatcher,
        LexerMatcherLibrary.AccessModifierMatcher,
        LexerMatcherLibrary.ClassMatcher,
        LexerMatcherLibrary.OperatorMatcher,
        LexerMatcherLibrary.CFunctionMatcher,
        LexerMatcherLibrary.CwordMatcher,
        LexerMatcherLibrary.AnySymbolMatcher
      );
    }
  }
}