How to handle complex file format in Delphi? (Not CSV, XML, etc.)

It has been several years since I had to parse files that were more complicated than CSV or XML, so I went out of practice. I was given the task of parsing the NeXus file format in a Delphi application.

The problem is that I just don’t know where to start, do I use a tokenizer, regular expression, etc.? Perhaps even a textbook may be what I need at this moment.

+5
source share
4 answers

Take a look at the GOLD Parser . It is a meta-syntax system that allows you to define formal grammar for a language / file format. It creates a parsing rule file that you submit to the tokenizer along with your input file, and it creates a syntax tree in memory.

Delphi has a tokenizer function available on the website. This simplifies the analysis, as vocabulary and tokenization have already taken care of you, and all you need to worry about is to identify markers in the formal grammar and then interpret them after analyzing them.

+7
source

Check it out, it's commercial, but it looks like a fun toy:

http://dpg.zenithlab.com/

But, in fact: for communication you do not need a complex parser.

, , .

:

  • TStringList.
  • , , .
    .
  • ​​ #nexus.
  • ( )
  • begin - .
  • DOS . , .

, , , - , :

function GetToken (var inputString: String; outputToken: String; const : TStrings; : TStrings; ParenFlag: Boolean): Boolean;

GetToken true, inputString, , . - , .
ParenFlag: True , , , . (((a, b), (c, d), (e, f))), , /.

, BNF , BNF, . , .

, /? , json xml, ?

+3

. Delphi , , , - PageProducer.

, HTML , , .. , PageProducer ( Nexus), , .

+2

Could not find the test format, but the state machine will not understand. Add to recursion to align the nests in the trees. They are an easily written relatively fast parsing engine that can be created for almost any text to text file. Often easier than using a scripting language to load. I have custom ones written for HTML, XML, HL7 and various medical EDI formats.

+2
source

All Articles