MmlSourceLineSet ProcessMacroLine(MmlLine line) { if (in_comment_mode) return null; var mms = new MmlMacroSource (); mms.Lines.Add (line); result.Macros.Add (mms); return mms; }
void ParseMacroLines(MmlMacroSource src) { //Util.DebugWriter.WriteLine ("Parsing Macro: " + src.Name); foreach (var line in src.Lines) foreach (var entry in aliases) line.Text = line.Text.Replace (entry.Key, entry.Value); source.Lexer.SetCurrentInput (src); int [] range = null; var ch = source.Lexer.Line.PeekChar (); if (ch == '#' || source.Lexer.IsNumber ((char) ch)) { range = source.Lexer.ReadRange ().ToArray (); source.Lexer.SkipWhitespaces (true); } // get identifier var identifier = source.Lexer.ReadNewIdentifier (); source.Lexer.SkipWhitespaces (true); src.ParsedName = identifier; var m = new MmlMacroDefinition (identifier, range, src.Lines [0].Location); source.CurrentMacroDefinition = m; if (m.Tokens.Count == 0) { // get args source.Lexer.NewIdentifierMode = true; source.Lexer.Advance (); ParseVariableList (m.Arguments, false); } source.Lexer.NewIdentifierMode = false; while (source.Lexer.Advance ()) m.Tokens.Add (source.Lexer.CreateParsedToken ()); if (m.Tokens.Count == 0 || m.Tokens [m.Tokens.Count - 1].TokenType != MmlTokenType.CloseCurly) source.Lexer.LexerError (String.Format ("'{{' is expected at the end of macro definition for '{0}'", identifier)); m.Tokens.RemoveAt (m.Tokens.Count - 1); result.Macros.Add (m); source.CurrentMacroDefinition = null; }