Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Custom External Lexer xText 2.10
Custom External Lexer xText 2.10 [message #1736592] Thu, 30 June 2016 13:40 Go to next message
yanick servant is currently offline yanick servantFriend
Messages: 1
Registered: June 2016
Junior Member
Hi !

First of all : sorry for my poor English...

I have a 2.4 xtext project which I'm trying to migrate to a maven 2.10 xtext project. Everything seems to work except one thing...

I had an external custom lexer like this :
                        fragment = org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment {
				antlrParam = "-Xconversiontimeout"
				antlrParam = "30000"
			    options = {
			        backtrack = true
			        backtrackLexer = false
			    }
			}
			
			// Uses ANTLR Tools to compile a custom lexer and will also add a binding in the runtime module to use the Lexer
			fragment = parser.antlr.ex.ExternalAntlrLexerFragment {
			    // A grammar file with .g will be expected in this package (should be stored in src folder)
			    lexerGrammar = "com.group.xxx.xtext.customlexer.CustomEditorLexer"
			    runtime = true
			    antlrParam = "-lib"
			    // This is the folder where the lexer will be created
			    antlrParam = "${runtimeProject}/src-gen/com/group/xxx/xtext/customlexer"


But with the new xtext generator i don't know how to go...
I try something like this :

                  language = StandardLanguage {
			name = "com.group.xxx.xtext.Editor"
			fileExtensions = "xxx"

			serializer = {
				generateStub = false
			}
			
			parserGenerator = {
				combinedGrammar = false
			    antlrParam = "com.group.xxx.xtext/src/com/group/xxx/xtext/customlexer"
				options = {
					backtrack = true
			        backtrackLexer = false
				}
			}
}


That well divides parser and lexer in the gen-folder but the reference of my external lexer not seem to work
Can you advise me on this plz ?
Re: Custom External Lexer xText 2.10 [message #1737477 is a reply to message #1736592] Fri, 08 July 2016 14:26 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
The StandardLanguage uses the default fragments only. You may try to write your own XtextGeneratorLanguage class and use the FragmentAdapter to wrap the ExternalAntlrLexerFragment.
If that doesn't work, you better to stick with the old workflow.


---
Get professional support from the Xtext committers at www.typefox.io
Re: Custom External Lexer xText 2.10 [message #1737653 is a reply to message #1737477] Mon, 11 July 2016 15:06 Go to previous message
Miro Spönemann is currently offline Miro SpönemannFriend
Messages: 78
Registered: March 2015
Location: Kiel, Germany
Member

I don't know whether we have migrated the ExternalAntlrLexerFragment functionality. You could try the adapter as mentioned by Jan:
fragment = org.eclipse.xtext.generator.adapter.FragmentAdapter {
	fragment = parser.antlr.ex.ExternalAntlrLexerFragment {
		// A grammar file with .g will be expected in this package (should be stored in src folder)
		lexerGrammar = "com.group.xxx.xtext.customlexer.CustomEditorLexer"
		runtime = true
		antlrParam = "-lib"
		// This is the folder where the lexer will be created
		antlrParam = "${runtimeProject}/src-gen/com/group/xxx/xtext/customlexer"
	}
}

Add that to the StandardLanguage or, if that doesn't work, replace StandardLanguage by XtextGeneratorLanguage as described in the documentation:
https://www.eclipse.org/Xtext/documentation/302_configuration.html#language-configuration
Previous Topic:Two projects for one extension
Next Topic:xtext project import on click event
Goto Forum:
  


Current Time: Fri Apr 26 22:05:14 GMT 2024

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

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

Back to the top