using System.Collections;

namespace QC.QTMScriptKernel;

public class ScriptParser
{
	private const string PARAMETER_IDENTIFIER_STRING = ".";

	private const char PARAMETER_IDENTIFIER_CHAR = '.';

	private string inputString = "";

	private Hashtable parameterList = new Hashtable();

	private string outputString = "";

	public string InputString
	{
		get
		{
			return inputString;
		}
		set
		{
			inputString = value;
			parameterList = new Hashtable();
			outputString = "";
		}
	}

	public Hashtable ParameterList => parameterList;

	public string OutputString => outputString;

	public ScriptParser()
	{
		parameterList = new Hashtable();
		outputString = "";
	}

	public ScriptParser(string inputString)
	{
		this.inputString = inputString;
		parameterList = new Hashtable();
		outputString = "";
	}

	public bool Parse()
	{
		try
		{
			if (inputString.Trim().Length == 0)
			{
				return false;
			}
			string[] array = inputString.Split('\n');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string text2 = text.Trim();
				if (text2.StartsWith("."))
				{
					int num = text2.IndexOf('.', 1);
					string[] array3 = text2.Split('.');
					if (array3.Length > 2)
					{
						parameterList[array3[1].Trim().ToUpper()] = text2.Substring(num + 1);
					}
				}
				else
				{
					outputString = outputString + text2 + "\r\n";
				}
			}
		}
		catch
		{
		}
		return true;
	}
}
