parser question

Daniel Schüle uval at rz.uni-karlsruhe.de
Wed Oct 19 16:32:21 CEST 2005


Hello *,

I have one format with this structure

A {
        x=1
        y=3
        B {
            z  = "something here"
        }
    }

C {
    }

A {
        x=0
        y=0
        B {
            z  = "other"
        }
    }

are there parsers for this kind of structure?
specially I am interested in all A blocks

just now, I am trying to solve it with re,

pattern = re.compile(r"^\s*A\s*{.*}\s*", re.MULTILINE | re.DOTALL)

A_blocks = pattern.findall( file("myFile").read() )

but since there might be subblocks it will fail finding the closing "}" 
character

Regards, Daniel





More information about the Python-list mailing list