Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Syntax coloring seems to ignore custom lexer
Syntax coloring seems to ignore custom lexer [message #772060] Wed, 28 December 2011 22:55 Go to next message
Adam Missing name is currently offline Adam Missing nameFriend
Messages: 12
Registered: December 2011
Junior Member
I have a grammar with a custom, external lexer (which extends the generated antlr lexer). I'm trying to do some syntax coloring. For this, I created AntlrTokenToAttributeIdMapper which gets bound in the UI module. My problem is that syntax coloring uses a TokenScanner which seems to ignore my custom lexer and to use the terminals from the grammar file directly. I understand the two scanners are not doing quite the same thing. Is it possible to configure syntax coloring to make use of my custom lexer, or shall I implement a syntaxcoloring TokenScanner, too?
Re: Syntax coloring seems to ignore custom lexer [message #772067 is a reply to message #772060] Wed, 28 December 2011 23:17 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

are you sure you added the correct bindings for the lexer

	public Class<? extends org.eclipse.xtext.parser.antlr.Lexer> bindLexer() {
		return org.xtext.example.mydsl.parser.antlr.internal.InternalMyDslLexer.class;
	}


	public void configureRuntimeLexer(com.google.inject.Binder binder) {
		binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME)).to(org.xtext.example.mydsl.parser.antlr.internal.InternalMyDslLexer.class);
	}


	public void configureHighlightingLexer(com.google.inject.Binder binder) {
		binder.bind(org.eclipse.xtext.parser.antlr.Lexer.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.ui.LexerUIBindings.HIGHLIGHTING)).to(org.xtext.example.mydsl.parser.antlr.internal.InternalMyDslLexer.class);
	}


	public void configureContentAssistLexer(com.google.inject.Binder binder) {
		binder.bind(org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.ui.LexerUIBindings.CONTENT_ASSIST)).to(org.xtext.example.mydsl.ui.contentassist.antlr.internal.InternalMyDslLexer.class);
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Context sensitive parsing with XText?
Next Topic:How to customize the serialization and parsing of xtext
Goto Forum:
  


Current Time: Thu Apr 25 01:06:34 GMT 2024

Powered by FUDForum. Page generated in 0.02750 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top