[antlr-interest] Reg Multi-line comments
Gavin Lambert
antlr at mirality.co.nz
Thu Jul 16 12:58:13 PDT 2009
At 00:34 17/07/2009, Michael wrote:
>> MLB : '/*' ( options { greedy = false; } : .* )
>> ( '*/' | { print error message }
>> { skip(); }
>> ;
>>
>> You might need EOF rather just empty alt.
>
>I tried that too and it gives an error:
The problem here is that with the end text potentially empty the
wildcard will consume all input. You need to use Jim's suggested
replacement for the wildcard as well in order to limit the scope.
Or another alternative replacement:
MLB : '/*' (~'*' | '*' ~'/')*
( '*/' | { print error message }
{ skip(); }
;
You *might* need to change ~'*' above to ~('*' | EOF), but I think
it's ok as is.
More information about the antlr-interest
mailing list