Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Dynamic Languages Toolkit (DLTK) » Question regarding syntax coloring (+a question on launch configurations)
Question regarding syntax coloring (+a question on launch configurations) [message #499764] Mon, 23 November 2009 20:38 Go to next message
Eclipse User
Originally posted by: a0309169.unet.univie.ac.at

Hello,

I'm taking another stab at using DLTK. I've followed the tutorial up to
the end of Part 2. More specifically, to test syntax highlighting, I've
created a simple RuleBasedPartitionScanner that scans for one specific
type of keyword and emits the token for that. I have implemented the
SingleTokenScriptScanner etc. However, the problem I encounter is that,
when I create a DamagerRepairer in getPresentationReconciler(), either
the whole text is selected (if I set it to
IDocument.DEFAULT_CONTENT_TYPE), or none of the text is selected (if I
set to the keyword's token type). I feel I'm not understanding some very
basic thing here and missing something out.
Does anybody know what the problem may be?


--------
My second question is about launch configurations. As far as I can see,
they're not included into the tutorial, but judging from the Ruby plugin
one can facilitate them by hooking up to the appropriate Eclipse core
extension point and using a subclass of
org.eclipse.dltk.launching.AbstractScriptLaunchConfiguration Delegate as
the delegate. Is this correct?

Thanks in advance for any help.

Cheers,
Mikołaj Koziarkiewicz
Re: Question regarding syntax coloring (+a question on launch configurations) [message #500091 is a reply to message #499764] Tue, 24 November 2009 17:23 Go to previous messageGo to next message
Eclipse User
Originally posted by: a0309169.unet.univie.ac.at

Please disregard the second question, I've found the HOWTO on launch
configurations (after of course basic it on the Ruby plugin - that will
teach me to RTFM).

The first question still stands - any help would be much appreciated.

Cheers!

Mikołaj

> Hello,
>
> I'm taking another stab at using DLTK. I've followed the tutorial up to
> the end of Part 2. More specifically, to test syntax highlighting, I've
> created a simple RuleBasedPartitionScanner that scans for one specific
> type of keyword and emits the token for that. I have implemented the
> SingleTokenScriptScanner etc. However, the problem I encounter is that,
> when I create a DamagerRepairer in getPresentationReconciler(), either
> the whole text is selected (if I set it to
> IDocument.DEFAULT_CONTENT_TYPE), or none of the text is selected (if I
> set to the keyword's token type). I feel I'm not understanding some very
> basic thing here and missing something out.
> Does anybody know what the problem may be?
>
>
> --------
> My second question is about launch configurations. As far as I can see,
> they're not included into the tutorial, but judging from the Ruby plugin
> one can facilitate them by hooking up to the appropriate Eclipse core
> extension point and using a subclass of
> org.eclipse.dltk.launching.AbstractScriptLaunchConfiguration Delegate as
> the delegate. Is this correct?
>
> Thanks in advance for any help.
>
> Cheers,
> Mikołaj Koziarkiewicz
Re: Question regarding syntax coloring (+a question on launch configurations) [message #500142 is a reply to message #499764] Wed, 25 November 2009 03:04 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
Hi Mikolaj,

PartitionScanner is used to split document into partitions, i.e. regions
where different formatting rules should be applied. E.g., keyword
"class" should be highlighted in the code partition, and should not be
highlighted in comments. That's why the partitions are used. The common
examples of partitions are code, strings and comments.

The next step is to specify syntax rules for each partition type.

For example in Ruby implementation there are RubyPartitionScanner,
RubyCodeScanner (for code partition) and scanners for other partitions.

Does it answer you question?

Regards,
Alex
Re: Question regarding syntax coloring (+a question on launch configurations) [message #506558 is a reply to message #500142] Thu, 07 January 2010 18:59 Go to previous messageGo to next message
Eclipse User
Originally posted by: a0309169.unet.univie.ac.at

Hi Alex,

sorry for the very late reply, and thank you for your answer. My error
was the assumption partitions are a DLTK-specific concepts, whereas
there origins lye deeper, within the core Eclipse framework itself.
After I've found some more general tutorials on the matter I've manage
to solve the problems at hand.

By the way, I've noticed that, despite some of the plugins' usage of
ANTLR, none utilize generated lexers or parsers for partition/token
scanning. This I find weird, since it is quite easy to plug in an ANTLR
lexer for a token scanner. Is this a performance issue, or something else?

Cheers,
Mikołaj


> Hi Mikolaj,
>
> PartitionScanner is used to split document into partitions, i.e. regions
> where different formatting rules should be applied. E.g., keyword
> "class" should be highlighted in the code partition, and should not be
> highlighted in comments. That's why the partitions are used. The common
> examples of partitions are code, strings and comments.
>
> The next step is to specify syntax rules for each partition type.
>
> For example in Ruby implementation there are RubyPartitionScanner,
> RubyCodeScanner (for code partition) and scanners for other partitions.
>
> Does it answer you question?
>
> Regards,
> Alex
Re: Question regarding syntax coloring (+a question on launch configurations) [message #506748 is a reply to message #506558] Sat, 09 January 2010 07:01 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
Hi Mikołaj,

Syntax highlighting works well enough based on predicate rules, most of the rules looks pretty simple, so I don't think it requires external dependencies like ANTLR (not sure of the performance, but in most cases syntax highlighting is not the most critical part of the system).
And complex syntax highlighting (e.g. JDT highlights static method calls) is done based on AST (after content is fully parsed) anyway.

Regards,
Alex
Re: Question regarding syntax coloring (+a question on launch configurations) [message #507337 is a reply to message #506748] Tue, 12 January 2010 19:05 Go to previous messageGo to next message
Eclipse User
Originally posted by: a0309169.unet.univie.ac.at

Hi Alex,

of course, for simple syntax highlighting alone, ANTLR is an overkill*.
I was talking about a situation where you have to provide a grammar
specification anyway (say, for syntax checking). In this case, you get a
lexer essentially for free, and creating separate rules for that purpose
seems like duplicating one's own work. Hence the question.

Regards,
Mikołaj

*If you acknowledge the existence of such a thing ;)...

> Hi Mikołaj,
>
> Syntax highlighting works well enough based on predicate rules, most of
> the rules looks pretty simple, so I don't think it requires external
> dependencies like ANTLR (not sure of the performance, but in most cases
> syntax highlighting is not the most critical part of the system).
> And complex syntax highlighting (e.g. JDT highlights static method
> calls) is done based on AST (after content is fully parsed) anyway.
>
> Regards,
> Alex
Re: Question regarding syntax coloring (+a question on launch configurations) [message #534639 is a reply to message #507337] Wed, 19 May 2010 13:33 Go to previous messageGo to next message
Alex Panchenko is currently offline Alex Panchenko
Messages: 342
Registered: July 2009
Senior Member
(Resurrecting some old topic Smile

Hi Mikołaj,

Highlighting based on ANTLR parser is possible - just don't provide rules and report everything as semantic highlighting.

The drawback of this approach is the recovery on syntax errors - in some cases it requires a lot work. This is the reason why simple rules to highlight numbers, strings and keywords are useful.

Regards,
Alex
Re: Question regarding syntax coloring (+a question on launch configurations) [message #551906 is a reply to message #534639] Tue, 10 August 2010 02:54 Go to previous message
Eclipse User
Originally posted by: a0309169.unet.univie.ac.at

Hi Alex,

(funnily enough, I searched the group today looking for something else
and found this :) )

I've used a somewhat different approach - there's a separate lexer for
syntax coloring, and a lexer/parser pair for discovery of syntax errors
(which communicates directly with the Problem Reporter). Not very
efficient, I know - but since the programs in question are definitely on
the small side, the overhead shouldn't be noticeable - and so far, it
hasn't been.

I'll link to the project once I'm (finally!) done with it, which should
be in the space of circa two months.

Cheers,
Mikołaj


> (Resurrecting some old topic :)
>
> Hi Mikołaj,
>
> Highlighting based on ANTLR parser is possible - just don't provide
> rules and report everything as semantic highlighting.
>
> The drawback of this approach is the recovery on syntax errors - in some
> cases it requires a lot work. This is the reason why simple rules to
> highlight numbers, strings and keywords are useful.
>
> Regards,
> Alex
Previous Topic:[BUILD] I-I201008060543-201008060543
Next Topic:Debugging with ruby 1.9.1
Goto Forum:
  


Current Time: Tue Sep 02 10:02:57 EDT 2014

Powered by FUDForum. Page generated in 0.02936 seconds