private void ProcessInstruction(string instructionLine) { int dummy; if (instructionLine.StartsWith("#define ")) { string variableName = ParseInstructionVariable(instructionLine, 8, out dummy); if (variableName == null) { RaiseError("Missing variable following the '#define' instruction."); } if (_definedVariables.ContainsKey(variableName)) { RaiseError("Duplicate definition of variable '" + variableName + "'."); } _definedVariables[variableName] = String.Empty; } else if (instructionLine.StartsWith("#undefine ")) { string variableName = ParseInstructionVariable(instructionLine, 10, out dummy); if (variableName == null) { RaiseError("Missing variable following the '#undefine' instruction."); } if (_definedVariables.ContainsKey(variableName) == false) { RaiseError("The variable '" + variableName + "' has not been defined yet."); } _definedVariables.Remove(variableName); } else if (instructionLine.StartsWith("#if ")) { string variableName = ParseInstructionVariable(instructionLine, 4, out dummy); if (variableName == null) { RaiseError("Missing variable following the '#if' instruction."); } Instruction instruction = new Instruction(); _activeInstructions.Push(instruction); instruction.AddVariable(variableName, _definedVariables); } else if (instructionLine.StartsWith("#elseif ") || instructionLine.StartsWith("#elif ")) { string variableName = ParseInstructionVariable(instructionLine, 8, out dummy); if (variableName == null) { RaiseError("Missing variable following the '#elif' instruction."); } if (_activeInstructions.Count == 0) { RaiseError("Unexpected '#elif' instruction."); } Instruction currentInstruction = _activeInstructions.Peek(); bool added = currentInstruction.AddVariable(variableName, _definedVariables); if (added == false) { RaiseError("The specified '" + variableName + "' has already been used, or an '#else' instruction has already been specified."); } } else if (instructionLine.StartsWith("#else")) { if (_activeInstructions.Count == 0) { RaiseError("Unexpected '#else' instruction."); } Instruction currentInstruction = _activeInstructions.Peek(); bool added = currentInstruction.AddVariable(null, _definedVariables); if (added == false) { RaiseError("Only a single '#else' instruction is allowed for a given '#if' instruction."); } } else if (instructionLine.StartsWith("#endif")) { if (_activeInstructions.Count == 0) { RaiseError("Unexpected '#endif' instruction."); } _activeInstructions.Pop(); } }