using System.Collections.Generic; namespace Rokojori; public class LexerPhase:ParserPhase { public LexerPhase( Lexer lexer ) { this.lexer = lexer; } public Lexer lexer; public bool outputDebugInfo = false; public override void Process( Parser parser ) { parser.lexerEvents = lexer.LexToList( parser.source ); if ( lexer.hasError ) { hasStopError = true; return; } parser.lexerEvents.Pop(); lexer.GrabMatches( parser.lexerEvents, parser.source ); var root = parser.root; parser.root.children.AddRange( parser.lexerEvents.Map( le => Token.Create( le, root ) ) ); if ( outputDebugInfo ) { var index = 0; RJLog.Log( "Lexer Info:", "\n" + parser.lexerEvents.Map( le => "["+ ( index++ ) + "] '" + ( le.type == "Break" ? "\\n" : le.match ) + "' : " + le.type + " ("+ le.offset +")" ).Join( "\n" ) ); } } }