I need to parse a textfile with about 10000 groupings like this
group "C_BatTemp" -- block-group
{
block: "Constant"
flags: BLOCK|COLLAPSED
}
-- Skipping output Out1
p_untitled_P_real_T_0[1]
{
type: flt(64,IEEE)*
alias: "Value"
flags: PARAM
}
endgroup -- block-group "C_BatTemp"
The desired objects I expect the parser to fill look like this
string Varname = "C_BatTemp";
string GroupType = "Constant";
string BaseAdressName = "p_untitled_P_real_T_0";
int AdressOffset = 1; // number in parenthesis p_untitled_P_real_T_0[1]<----
string VarType = "flt(64, IEEE)";
bool IsPointer = true; // true if VarType is "flt(64, IEEE)*" ,
//false if "flt(64, IEEE)"
string VarAlias = "Value";
What is the best way of parsing this ??
How sould I start ?
One solution might be using a regular expression. I quickly made up one, but it might require some additional tuning to fit your exact needs. It works for your example, but might fail for other inputs. The expression is very much tailored to the given example especially in respect to line breaks and comments.
CODE
OUTPUT