示例#1
0
        private static void CallMacroHandler(Match lineReg)
        {
            string macroName = lineReg.Groups["label"].Value;
            string value     = lineReg.Groups["value"].Value;

            if (!macros.ContainsKey(macroName))
            {
                AddError(Errors.MACRO_NOT_EXISTS);
                return;
            }
            MacroDef macroDef = macros[macroName];

            if (!string.IsNullOrEmpty(value))
            {
                string[] paramValues = Regex.Replace(value, @"\s+", "").Split(',');
                foreach (string line in macroDef.lines)
                {
                    string finalLine = line;
                    for (int i = 0; i < paramValues.Length; i++)
                    {
                        string paramValue = paramValues[i];
                        string paramName  = macroDef.listParam[i];
                        finalLine = finalLine.Replace(paramName, paramValue);
                    }
                    ParseLine(finalLine, finalLine);
                }
            }
            else
            {
                if (macroDef.listParam.Length > 0)
                {
                    AddError(Errors.MACRO_CALL_WITHOUT_PARAMS);
                    return;
                }
                foreach (string line in macroDef.lines)
                {
                    ParseLine(line, line);
                }
            }
        }
示例#2
0
        private static void StartMacroDefHandler(string value)
        {
            Match    mReg      = Regex.Match(value, CPUDef.macroReg);
            string   macroName = currentMacro = mReg.Groups["label"].Value;
            string   defParts  = mReg.Groups["value"].Value;
            MacroDef macroDef  = new MacroDef();

            macroDef.lines = new List <string>();

            startMacroDef = true;
            if (!string.IsNullOrEmpty(defParts))
            {
                macroDef.listParam = Regex.Replace(defParts, @"\s+", "").Split(',');
            }
            if (macros.ContainsKey(macroName))
            {
                AddError(Errors.MACRO_EXISTS);
            }
            else
            {
                macros.Add(macroName, macroDef);
            }
        }