<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>that's the issue. I would slowly go through the string and parse down every command, if I knew how to grab numbers and things between one command and the next. For example, c8.c8<br>
</p>
<br>
<div class="moz-cite-prefix">On 9/7/2016 7:44 PM, Spencer Salazar wrote:<br>
</div>
<blockquote cite="mid:CA&#43;ezOE4X0ULiatzQ16=97OzRrO-3vPbhnav5Cvqi-&#43;vfRZWpRQ@mail.gmail.com" type="cite">
<div dir="ltr">
<div>I dont think you can use regex to match a whole expression like that but you can use it to pick off bits and pieces. Just make a regex that matches all of the possible commands &#43; options and run that through, advancing the string position each time. Eg</div>
<div><br>
</div>
<div>
<div>&quot;<span style="font-size:12.8px">o4l8cdefg</span>&quot; =&gt; string code;</div>
<div>string matches[0];</div>
<div>&quot;((o)([0-9]&#43;)|([abcdefg])(1|2|<wbr>4|8|16)?|(l)([0-9]&#43;))&quot; =&gt; string pattern;</div>
<div><br>
</div>
<div>for(0 =&gt; int i; i &lt; code.length(); )</div>
<div>{</div>
<div>&nbsp; &nbsp; if(RegEx.match(pattern, code.substring(i), matches))</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; if(matches[2] == &quot;o&quot;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&lt; &quot;octave:&quot;, matches[3] &gt;&gt;&gt;;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; else if(matches[4] == &quot;a&quot;)</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&lt; &quot;a&quot; &gt;&gt;&gt;;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; // etc.</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; matches[0].length() &#43;=&gt; i;</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; else</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;&lt;&lt; &quot;invalid code&quot; &gt;&gt;&gt;;</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; break;</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
</div>
<div><br>
</div>
<div>I dont know anything about MML so I dont know what the final regex would look like.&nbsp;</div>
<div><br>
</div>
<div>Another option is to just go through the string iteratively and look at each character one at a time. If whitespace is undesirable StringTokenizer might be hurting more than helping here.&nbsp;</div>
<div><br>
</div>
<div>
<div>for(0 =&gt; int i; i &lt; code.length(); )</div>
<div>{</div>
</div>
<div>&nbsp; &nbsp; int c = code.charAt(i);</div>
<div>&nbsp; &nbsp; if(c == 'o')</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// look for number</div>
<div>&nbsp; &nbsp; }</div>
<div>&nbsp; &nbsp; else if(c == 'a' || c == 'b' || ... )</div>
<div>&nbsp; &nbsp; {</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// see if number follows</div>
<div>&nbsp; &nbsp; }</div>
<div>}</div>
<div><br>
</div>
<div>spencer</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Sep 6, 2016 at 6:32 PM, Colton Hill <span dir="ltr">
&lt;<a moz-do-not-send="true" href="mailto:colton-hill2014@hotmail.com" target="_blank">colton-hill2014@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
I also want to make sure I have a customizable play function that will<br>
handle my playing. Here's the code I've been using for my current mml<br>
parser in chuck, actually does take a code string and a play function,<br>
and operates well. Only issue is including doesn't work... So have a test.<br>
<div class="HOEnZb">
<div class="h5"><br>
<br>
On 9/6/2016 3:33 AM, Hans Åberg wrote:<br>
&gt;&gt; On 5 Sep 2016, at 23:16, Colton Hill &lt;<a moz-do-not-send="true" href="mailto:colton-hill2014@hotmail.com">colton-hill2014@hotmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I know regular expressions syntax, but I really don't know how I would<br>
&gt;&gt; manage to make an mml parser that actually works. Turn o4l8cdefg into<br>
&gt;&gt; octave 4, length 8, and c d e f g notes with an 8th note length since no<br>
&gt;&gt; length is specified. Then there's c4., which is c4^c8... Just bla…<br>
&gt; There are free MML parsers in C out there. Linking to ChucK, which is written in C&#43;&#43;, might be a way.<br>
&gt;<br>
&gt;<br>
&gt; ______________________________<wbr>_________________<br>
&gt; chuck-users mailing list<br>
&gt; <a moz-do-not-send="true" href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.<wbr>princeton.edu</a><br>
&gt; <a moz-do-not-send="true" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">
https://lists.cs.princeton.<wbr>edu/mailman/listinfo/chuck-<wbr>users</a><br>
<br>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
chuck-users mailing list<br>
<a moz-do-not-send="true" href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.<wbr>princeton.edu</a><br>
<a moz-do-not-send="true" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" rel="noreferrer" target="_blank">https://lists.cs.princeton.<wbr>edu/mailman/listinfo/chuck-<wbr>users</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div style="font-family:arial;font-size:small">
<div>Spencer Salazar<br>
</div>
<div>Doctoral Candidate</div>
<div>Center for Computer Research in Music and Acoustics</div>
<div>Stanford University</div>
<div><br>
</div>
<div><a moz-do-not-send="true" href="mailto:spencer@ccrma.stanford.edu" target="_blank">spencer@ccrma.stanford.edu</a></div>
<div>&#43;1 831.277.4654<br>
</div>
<div><a moz-do-not-send="true" href="https://ccrma.stanford.edu/%7Espencer/" style="color:rgb(17,85,204)" target="_blank">https://ccrma.stanford.edu/~spencer/</a><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> <br>
<pre wrap="">_______________________________________________
chuck-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:chuck-users@lists.cs.princeton.edu">chuck-users@lists.cs.princeton.edu</a>
<a class="moz-txt-link-freetext" href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a>
</pre>
</blockquote>
<br>
</body>
</html>