using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Rokojori { public class GodotTextSceneLexer:Lexer { public static List Lex( string source ) { var lexer = new GodotTextSceneLexer(); var events = lexer.LexToList( source ); if ( lexer.hasError ) { return null; } events.ForEach( ev => { ev.GrabMatch( source ); } ); return events; } public static readonly LexerMatcher HeaderMatcher = LexerMatcher.CreateExtended( "Header", "\\[.+\\]" ); public static readonly LexerMatcher SeperatorMatcher = LexerMatcher.CreateExtended( "Seperator", "\\l\\l" ); // ((?:\w|_|\/)+) = .+?(\r\n|\r|\n) // ((?:\\w|_|\\/)+) = .+?(\\r\\n|\\r|\\n) public static readonly LexerMatcher MemberMatcher = LexerMatcher.CreateExtended( "Member", "(?:\\w|_|\\/)+ = .+?" ); // ".+?"\: .+?,(\r\n|\r|\n) // \".+?\"\\: .+?,\\l public static readonly LexerMatcher SubMemberMatcher = LexerMatcher.CreateExtended( "SubMember", "\".+?\"\\: .+?" ); public static readonly LexerMatcher SubMemberStartMatcher = LexerMatcher.CreateExtended( "SubMemberStart", ".+\\[\\{" ); public static readonly LexerMatcher SubMemberEndMatcher = LexerMatcher.CreateExtended( "SubMemberEnd", "\\}\\]" ); public GodotTextSceneLexer() { AddAllMatchers( GodotTextSceneLexer.HeaderMatcher, GodotTextSceneLexer.SeperatorMatcher, GodotTextSceneLexer.SubMemberStartMatcher, GodotTextSceneLexer.SubMemberEndMatcher, GodotTextSceneLexer.SubMemberMatcher, GodotTextSceneLexer.MemberMatcher, LexerMatcherLibrary.AnySymbolMatcher ); } } }