Adam Schmideg
Adam Schmideg

Reputation: 10860

Xtext grammar in two files

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?

Upvotes: 1

Views: 757

Answers (3)

Sora
Sora

Reputation: 1

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

Upvotes: 0

Christian Dietrich
Christian Dietrich

Reputation: 11868

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?

Upvotes: 0

Sven Efftinge
Sven Efftinge

Reputation: 3095

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

Upvotes: 1

Related Questions