0

I'm tring to build up a parser reading a tree strutured file format that we are using in c# in order to modify it with a VSTO Excel interface. (Hence the C# choose otherwise I would have used Python beeing a beginer in C#...)

The format is defined as such:

environment type=Environment
  uservar_section type=UserVariableSection name=General
    def ExSize=2;
    var var1="something";
    var var2="2" comment="some comments";
  end uservar_section; /* General:UserVariableSection */ 
  uservar_section type=UserVariableSection name=SectionName
    def ExSize=5;
    var var1="(2*pi)";
    var var2="(pi)";
    var var3="max(var1,var2)";
    var var4="0";
    var var5="2*var3";
  end uservar_section; 
  model type=SModel name=""
      uservar_section type=UserVariableSection name=SectionName
        def ExSize=5;
        var var1="(2*pi)";
        var var2="(pi)";
        var var3="max(var1,var2)";
        var var4="0";
        var var5="2*var3";
      end uservar_section; 
  end model; 
end environment;  

To be honest I don't know where to start in C# to read this type of file. I've looked at OMeta but I'm not sure it is a good idea. Would you have some general recomandation from where to start? Does anybody here have already done such program?

Thank you!!

  • Do you already have objects that you want to load this data in to? How is Excel related to this? – David Apr 11 '16 at 17:45
  • Yes I have data to load in that format. Excel is not yet related, it will just be used as user interface to replace the old fortran interface we are currently using. – alexandre aury Apr 11 '16 at 17:49
  • A couple of options - [read the file line by line](https://msdn.microsoft.com/en-us/library/aa287535(v=vs.71).aspx), parse it into some model classes and apply whatever business logic you need to get at the bits you are interested in. Or you could use a [regular expression](http://www.regular-expressions.info/) to do something similar. – NightOwl888 Apr 11 '16 at 23:43

0 Answers0