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?

Community
  • 1
  • 1
Adam Schmideg
  • 10,590
  • 10
  • 53
  • 83

3 Answers3

1

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

Sven Efftinge
  • 3,065
  • 17
  • 17
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

Indrajeet
  • 5,490
  • 2
  • 28
  • 43
Sora
  • 1
  • 1
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?

Christian Dietrich
  • 11,778
  • 4
  • 24
  • 32
  • 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 06 '12 at 11:36