public int Parse(string music, StaccatoParserContext context)
 {
     if (music[0] == LyricChar || music[0] == MarkerChar)
     {
         string lyricOrMarker = null;
         int    posNext       = 0;
         if (music[1] == '(')
         {
             posNext = music.FindNextOrEnd(')');
         }
         else
         {
             posNext = music.FindNextOrEnd(' ');
         }
         int startPos = music[1] == '(' ? 2 : 1;
         lyricOrMarker = music.Substring(startPos, posNext - startPos);
         lyricOrMarker = ParenSpacesPreprocessor.Unprocess(lyricOrMarker);
         if (music[0] == LyricChar)
         {
             context.Parser.OnLyricParsed(lyricOrMarker);
         }
         else
         {
             context.Parser.OnTrackBeatTimeBookmarked(lyricOrMarker);
             context.Parser.OnMarkerParsed(lyricOrMarker);
         }
         return(Math.Max(1, Math.Min(posNext + 1, music.Length)));
     }
     return(0);
 }
Example #2
0
        public int Parse(string music, StaccatoParserContext context)
        {
            if (music[0] != FunctionChar)
            {
                return(0);
            }
            int    posOpenParen  = music.FindNextOrEnd('(');
            int    posCloseParen = music.FindNextOrEnd(')', posOpenParen);
            string functionName  = music.Substring(1, posOpenParen - 1);
            string parameters    = music.Substring(posOpenParen + 1, posCloseParen - posOpenParen - 1);

            parameters = ParenSpacesPreprocessor.Unprocess(parameters);
            var function = FunctionManager.Instance.GetSubparserFunction(functionName);

            if (function != null)
            {
                context.Parser.OnFunctionParsed(functionName, parameters);
                function.Apply(parameters, context);
            }
            return(Math.Min(posCloseParen + 1, music.Length));
        }
        public void Test_unprocess()
        {
            string output = ParenSpacesPreprocessor.Unprocess("(1,_2,_3)");

            output.Should().Be("(1, 2, 3)");
        }