1

I want to put my terminals into a separate file, because I'll use an external lexer in the production version. I tried following the answer to using custom terminals definitions. So I have a mypackage/Tokens.xtext file and a mypackage/MyDsl.xtext file containing

grammar mypackage.MyDsl with mypackage.Tokens

The generation works fine, but it creates a MyDslStandaloneSetupGenerated in src-gen which doesn't compile, because it calls the non-existent mypackage.TokensStandaloneSetup.doSetup(). It also generates src-gen/mypackage/services/MyDslGrammarAccess which refers to an also non-existent TokensGrammarAccess class. So my question is basically: when I have another grammar file, what else should I do to make it usable?

3 Answers 3

1

You need to also run a generator for the token grammar.

1
  • That means I have to write some additional file(s), including a generator? What other files are to be written? Nov 29, 2011 at 11:31
0

in Xtext you usually put the tokens (terminals) and the parser rules into the same .xtext file. Is there a specific reason why you want to split this?

1
  • I would like to do the same thing. My reason is that I generate the "base-grammar" and would like to put the generated token in a seperate file.
    – Tobias
    Jan 6, 2012 at 11:36
0

Simple Reason:

Easier to Read and work with the Grammar for everybody (especially other users)

Seems like Xtext still does not support the use of more than one .xtext file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.