Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [Dltk-dev] heredoc scanner help



On Wed, May 16, 2012 at 6:40 PM, Jae Gangemi <jgangemi@xxxxxxxxx> wrote:

  actually, i just went and re-read the wiki page, shouldn't this be simple for D?

  you'd just need multiple multi-line rules that look something like this (not sure if there is an escape char):

    new MultiLineRule("q(", ")\n", token, (char) 0, true);
    new MultiLineRule("q{", "}\n", token, (char) 0, true);

  no?


Actually, there's another bug here, and it's a tricky one, so heads up in case you might run to into in similar code on own work: If you use different rules to match the same token, the partitioner can at some times (especially for multi-line rules) try to resume scanning (look only for the end of the partition starting from the middle of it) using a rule different from the one that started the partition. So code like this:

q(
blah
}

might be scanned correctly as a partition of that token type, because one rule would start it, but another rule might end the scanning successfully. I mentioned this in more detail in this Eclipse bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=346723


--
Bruno Medeiros

Back to the top