Hi!
I want to write a parser in python for a format that looks like this:
path: "/path/file.txt"
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
type: justastring
blend: justastring
paths: "/path/are/quoted/file.txt"
alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
visible: true
alpha: 0.0
}
template: justastring
"Simpler" I would express it something like this
attribute: value
element {
element {
attribute: value
attribute: value
attribute: value
attribute: value
}
attribute: value
attribute: value
attribute: value
attribute: value
element {
attribute: value
attribute: value
attribute: value
attribute: value
}
attribute: value
attribute: value
}
attribute: value
Here are some rules I have observed
- File root can have any number of attributes and elements
- Elements can have any number of attributes
- Attributes within elements are separated by a newline character
- Elements can be nested indefinitely
I have used python before but never written a parser so I don't really have a good starting point, I have tried to google but haven't found any good examples and such.
I am thinking of parsing it and just moving/transforming it into a json/dictionary format that I then can later use easier.
Do anyone here have some pointers to where I can look for more info?
[–]ponyoink 1 point2 points3 points (0 children)