I want to parse a text file format that has slightly fancy syntax. Here are some valid lines:
<region>sample=piano C3.wav key=48 ampeg_release=0.7 // a comment here <region>key = 49 sample = piano Db3.wav <region> group=1 key = 48 sample = piano D3.ogg
I think it would be too difficult for me to come up with a regular expression that makes sense, but I wonder if there is a good way to tokenize this type of input without writing my own parser? ie I would like something that reads the above input and splashes out the stream of "tokens", for example, the output for starting my example format would be something like this:
new Region(), new Sample("piano C3.wav"), new Key("48"), new AmpegRelease("0.7"), new Region()
Is there a good library / tutorial that would point me in the right direction for an elegant way to implement this?
Update: I tried this with Irony , but the quirks of the syntax I need to parse (in particular, the fact that the data following the pattern = can take place in it) made me better write my own code in based on String.Split. See discussion here .
source share