Helene Bilbo
Helene Bilbo

Reputation: 1142

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.

Upvotes: 4

Views: 797

Answers (1)

Damien Cassou
Damien Cassou

Reputation: 2589

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.

Upvotes: 8

Related Questions