Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [Xtext] not fixed elements in a grammar file
[Xtext] not fixed elements in a grammar file [message #39697] Mon, 13 April 2009 12:58 Go to next message
Eclipse UserFriend
Hello,

Supposing that our text file is composed of columns (like a CSV file)

The unknown nubmer of column in not a deal because we can solve with many
operators (* or +) in the grammar file.
My problem is in the name of elements in the grammar file. Actually I dont
want to put fixed names for may columns because it may change from a file
to another.

To be clearer, I will return to the Addressbook example. Here we now
exacttly what we want, FirstName, lastName, phoneNumber,...
my problem is that I don't want to put fixed names to my elements.

In the begining, I thought that I can do this with a "foreach" loop in the
xpand file. But I don't know if it is feasable

Does any one have an idea about this kind of problem?
Thanks for help.

Best regards,

Hayfa.
Re: [Xtext] not fixed elements in a grammar file [message #39820 is a reply to message #39697] Tue, 14 April 2009 03:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hayfa,

could you come up with an example explaining what you want to achieve.
I didn't get it.

Sven

Hayfa schrieb:
> Hello,
>
> Supposing that our text file is composed of columns (like a CSV file)
>
> The unknown nubmer of column in not a deal because we can solve with
> many operators (* or +) in the grammar file.
> My problem is in the name of elements in the grammar file. Actually I
> dont want to put fixed names for may columns because it may change from
> a file to another.
>
> To be clearer, I will return to the Addressbook example. Here we now
> exacttly what we want, FirstName, lastName, phoneNumber,...
> my problem is that I don't want to put fixed names to my elements.
>
> In the begining, I thought that I can do this with a "foreach" loop in
> the xpand file. But I don't know if it is feasable
>
> Does any one have an idea about this kind of problem?
> Thanks for help.
>
> Best regards,
>
> Hayfa.
>
>
Re: [Xtext] not fixed elements in a grammar file [message #39911 is a reply to message #39820] Tue, 14 April 2009 05:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

Sorry for having not been clear.
Let's take the example of a csv file. We have a set of columns and lines
separated with a given separator:

col1;col2;col3;...;coln
data11;data12;data13;...;data1n
data21;data22;data23;...;data2n
..
..
..

In this case, I don't know exactly the number of columns, so I can't
assign fixed names to the columns in such a way that I can call them later
(in the xpt file for example).
My question is how can I mention this in the grammar. Sould I use a
variable or something?

Thank you so much.

Best Regards,

Hayfa.
Re: [Xtext] not fixed elements in a grammar file [message #40004 is a reply to message #39911] Tue, 14 April 2009 10:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Hayfa,

I still don't know what exactly you want to do.
But if it's just parsing CSV I wouldn't use something like Xtext.

Regards,
Sven

File :
headings=HeadingsRow
data+=DataRow*;

HeadingsRow :
heading+=ID (';' heading+=ID)*;

DataRow :
data+=ID (';' data+=ID)*;

Hayfa schrieb:
> Hi Sven,
>
> Sorry for having not been clear.
> Let's take the example of a csv file. We have a set of columns and lines
> separated with a given separator:
>
> col1;col2;col3;...;coln
> data11;data12;data13;...;data1n
> data21;data22;data23;...;data2n
> .
> .
> .
>
> In this case, I don't know exactly the number of columns, so I can't
> assign fixed names to the columns in such a way that I can call them
> later (in the xpt file for example). My question is how can I mention
> this in the grammar. Sould I use a variable or something?
>
> Thank you so much.
>
> Best Regards,
>
> Hayfa.
>
Re: [Xtext] not fixed elements in a grammar file [message #467958 is a reply to message #39911] Mon, 03 August 2009 09:01 Go to previous message
Eclipse UserFriend
> Let's take the example of a csv file. We have a set of columns and lines
> separated with a given separator:
>
> col1;col2;col3;...;coln
> data11;data12;data13;...;data1n
> data21;data22;data23;...;data2n

http://blogs.itemis.de/stundzig/archives/498
Previous Topic:[XText] release on friday
Next Topic:DSL editor incl. error and warning pane in standalone (RCP/PDE) application
Goto Forum:
  


Current Time: Mon Jul 14 15:35:50 EDT 2025

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

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

Back to the top