This works, but it gives me one token containing "12:34:56". I still need to parse the hh,mm,ss values. What is the best way to do that?<br><br>It seems that I want the parser to be able to tell the lexer "normally you can consider INT:INT:INT as a STRING. But right now, return tokens for each piece." Isn't that what a semantic predicate does? Or am I really missing something? <br>
<br><div class="gmail_quote">On Tue, Feb 24, 2009 at 3:32 PM, Gavin Lambert <span dir="ltr"><<a href="mailto:antlr@mirality.co.nz">antlr@mirality.co.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">At 08:52 25/02/2009, Rick Schumeyer wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If the input string is "12:34:45", then of course antlr returns a STRING token. I understand why it does that (I think) but I'm not really sure how to fix that. I'm fuzzy on the difference between a semantic and syntactic predicate, and whether one of those is what I need.<br>
<br>
grammar STest;<br>
<br>
line : timestamp;<br>
<br>
timestamp<br>
: INT ':' INT ':' INT<br>
;<br>
<br>
INT : ('0'..'9')+;<br>
<br>
STRING : ('!'..'+' | '-'..'~')+; /* anything but ws or comma */<br>
</blockquote>
<br></div>
fragment TIMESTAMP: INT ':' INT ':' INT ;<br>
<br>
INT : ('0'..'9')+ ;<br>
<br>
STRING<br>
: (TIMESTAMP) => TIMESTAMP { $type = TIMESTAMP; }<div class="Ih2E3d"><br>
| ('!'..'+' | '-'..'~')+; /* anything but ws or comma */<br></div>
;<br>
<br>
</blockquote></div><br>