Parsing a simple language for title formatting
<p>I'm writing an audio player using java, and I want a title formatter similar to foobar2000. Examples are:</p>

<pre><code>$if($strcmp(%album artist%,%artist%),%artist%,$if2(%album%,Unknown))
</code></pre>

<p>or</p>

<pre><code>[%album%][ '('CD $ifgreater(%totaldiscs%,1,%discnumber%,)')']
</code></pre>

<p>first example returns a string, and if it is same for sequential tracks in a playlist, they are grouped, second example formats album name and adds a cd number if it exists. Full reference is <a href="http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Titleformat%5FReference#Additional%5FReading" rel="nofollow">here</a></p>

<p>I do not need everything but at least some of the functionality.</p>

<p>How difficult is it to write a parser for such a language. Are there any compiler compilers for java?</p>

<p>Would it be easier to use java's javascript engine? How fast will it be (processing several thousand tracks)?</p>
