示例#1
0
        MmlSourceLineSet ProcessTrackLine(MmlLine line)
        {
            if (in_comment_mode)
                return null;
            result.Lexer.SetCurrentInput (line);

            string section = previous_section;
            int [] range = previous_range;
            if (result.Lexer.IsWhitespace (line.PeekChar ()))
                result.Lexer.SkipWhitespaces (true);
            else {
                if (result.Lexer.IsIdentifier (line.PeekChar (), true)) {
                    section = result.Lexer.ReadNewIdentifier ();
                    result.Lexer.SkipWhitespaces (false);
                }
                if (result.Lexer.IsNumber (line.PeekChar ())) {
                    range = result.Lexer.ReadRange ().ToArray ();
                    result.Lexer.SkipWhitespaces (true);
                }
            }
            if (range == null)
                throw new MmlException ("Current line indicates no track number, and there was no indicated tracks previously.", line.Location);

            previous_section = section;
            previous_range = range;
            result.Lexer.SkipWhitespaces (false);
            var ts = new MmlTrackSource (section, range);
            ts.Lines.Add (line);
            result.Tracks.Add (ts);
            return ts;
        }
示例#2
0
 void ParseTrackLines(MmlTrackSource src)
 {
     var tokens = new List<MmlToken> ();
     foreach (var line in src.Lines)
         foreach (var entry in aliases)
             line.Text = line.Text.Replace (entry.Key, entry.Value);
     source.Lexer.SetCurrentInput (src);
     while (source.Lexer.Advance ())
             tokens.Add (source.Lexer.CreateParsedToken ());
     // Compilation conditionals are actually handled here.
     if (!result.Conditional.ShouldCompileBlock (src.BlockName))
         return;
     foreach (var t in src.Tracks) {
         if (result.Conditional.ShouldCompileTrack (t))
             result.GetTrack (t).Tokens.AddRange (tokens);
     }
 }