Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HowTo parse this (see description) text file in Pharo Smalltalk

I want to parse a textfile in Pharo Smalltalk, that has the structure outlined below into a Smalltalk object called TestResults, that has instance variables for all the data elements:

Properties:

Name: Value
Name: Value
...

Settings:

Category
    SubCategory
        Name=Value
    SubCategory
        Name=Value
        Name=Value
...

Column1 Column2 Column3 ...
Value Value Value...
...

I thought about using NeoCSV for the tab-separated-value part at the end of the file, but i do not know how to parse the beginning of the file and how to combine this (if this approach is possible) with NeoCSV.

like image 883
Helene Bilbo Avatar asked Feb 20 '23 18:02

Helene Bilbo


1 Answers

I advise you to have a look at PetitParser. See http://pharobooks.gforge.inria.fr/PharoByExampleTwo-Eng/latest/PetitParser.pdf and http://www.themoosebook.org/book/internals/petit-parser. Don't hesitate to create more questions on stackoverflow about this if you need help writing your parser.

like image 108
Damien Cassou Avatar answered Feb 22 '23 06:02

Damien Cassou