Need help getting started on a grammar (again) (SOLVED) [message #1380003] |
Sat, 24 May 2014 20:14  |
Eclipse User |
|
|
|
Some of you may remember me from earlier this year in that I was completely unable to get Xtext working at all and managed to waste quite a fair bit of people's time in the process. The thread ended with a resolution to buy Lorenzo Bettini's book, Implementing Domain-Specific Languages with Xtext and Xtend.
I finally had a chance this weekend to crack open the book and follow along, and I'm running into a problem. I learned from my last shot at this that trying to fix it myself without some expert advice isn't going to get me anywhere.
Here's my grammar resulting from following the book through about halfway down page 38:
grammar org.example.entities.Entities with org.eclipse.xtext.common.Terminals
generate entities "http://www.example.org/entities/Entities"
Model:
entities += Entity*;
Entity:
'entity' name = ID ('extends' superType=[Entity])? '{'
attributes += Attribute*
'}'
;
Attribute:
type=[Entity] array?=('[' ']')? name=ID ';'
;
The grammar was previously working; since, the only modification was to change '[]' to '[' ']' to allow arbitrary whitespace between the square brackets.
I get a syntax error under ']' claiming: extraneous input "]" expecting ')'
I've dug around the web a little and found examples of this sort of putting two string literals right next to each other, so I suspect it's not so much an issue with the grammar as a problem with my setup. Any ideas on how to proceed would be greatly appreciated.
[Updated on: Sat, 24 May 2014 20:16] by Moderator
|
|
|
|
|
Re: Need help getting started on a grammar (again) [message #1383799 is a reply to message #1380003] |
Mon, 26 May 2014 10:47  |
Eclipse User |
|
|
|
On 25/05/2014 02:14, Jordan Wallet wrote:
> Some of you may remember me from earlier this year in that I was
> completely unable to get Xtext working at all and managed to waste quite
> a fair bit of people's time in the process. The thread ended with a
> resolution to buy Lorenzo Bettini's book, Implementing Domain-Specific
> Languages with Xtext and Xtend.
>
> I finally had a chance this weekend to crack open the book and follow
> along, and I'm running into a problem. I learned from my last shot at
> this that trying to fix it myself without some expert advice isn't going
> to get me anywhere.
>
> Here's my grammar resulting from following the book through about
> halfway down page 38:
> grammar org.example.entities.Entities with
> org.eclipse.xtext.common.Terminals
>
> generate entities "http://www.example.org/entities/Entities"
>
> Model:
> entities += Entity*;
>
> Entity:
> 'entity' name = ID ('extends' superType=[Entity])? '{'
> attributes += Attribute*
> '}'
> ;
>
> Attribute:
> type=[Entity] array?=('[' ']')? name=ID ';'
> ;
>
>
On page 38 the modified rule is
Attribute: type=[Entity] (array?='[' ']')? name=ID ';';
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
|
|
|
Powered by
FUDForum. Page generated in 0.04188 seconds