Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » One line = one attribute(One line represent an information)
One line = one attribute [message #959170] Fri, 26 October 2012 14:01 Go to next message
Jean-Michel Syrotas is currently offline Jean-Michel SyrotasFriend
Messages: 4
Registered: June 2012
Junior Member
Hi,

I am writing a (very simple) grammar using EMF with the following specifications:

Each section begins with [KEYWORD] like
[DESCRIPTION]
or
[COORDINATES]

In each section, each line represent an information, for example:
[COORDINATES]
POINT1 N043.57.47.808 W079.45.48.888
POINT2 N043.33.29.999 W079.28.05.401

etc.

There is no closing tag for the sections, each section stops when another one begins.
I had no problem writing this grammar, except for the [DESCRIPTION] section which is quite particular.

Indeed, each line represent a specific attribute, sometimes with blank characters. Here is an example:
[DESCRIPTION]
A full description with spaces...
A_LONG_ID
A_SHORT_ID
N043.40.37.800
W079.37.49.800
800
579
10.00000000
13.33333300


Is there any way for me to match the lines one by one here, i mean I'd like to match the first line in a single string, but I cannot find the way. I made some researches, but it seams not possible ~~

Any adea?
Re: One line = one attribute [message #959201 is a reply to message #959170] Fri, 26 October 2012 14:28 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
How do you know where the description text ends?

Use a Datarule - something like this:

Documentation
: 'DESCRIPTION' text = DescriptionText
;
DescriptionText hidden()
: ( WS
| SL_COMMENT | ML_COMMENT
| ID | STRING | INT
| ANY_OTHER
| KW1 | ... | KWn)*
;

Naturally, you need to not include the keywords and terminals that break
the description text. It is tricky if something like 'POINT' should
break the description, as the user can then not write the word 'POINT' i
the description.

Or solve this with an external lexer that more efficiently can collect
all of the text into one token. (This requires that the end of the
description text is easy to detect lexically).

- henrik

On 2012-26-10 16:02, Jean-Michel Syrotas wrote:
> Hi,
>
> I am writing a (very simple) grammar using EMF with the following
> specifications:
>
> Each section begins with [KEYWORD] like [DESCRIPTION] or [COORDINATES]
> In each section, each line represent an information, for example:
> [COORDINATES]
> POINT1 N043.57.47.808 W079.45.48.888
> POINT2 N043.33.29.999 W079.28.05.401
>
> etc.
> There is no closing tag for the sections, each section stops when
> another one begins.
> I had no problem writing this grammar, except for the [DESCRIPTION]
> section which is quite particular.
>
> Indeed, each line represent a specific attribute, sometimes with blank
> characters. Here is an example:
> [DESCRIPTION]
> A full description with spaces...
> A_LONG_ID
> A_SHORT_ID
> N043.40.37.800
> W079.37.49.800
> 800
> 579
> 10.00000000
> 13.33333300
>
>
> Is there any way for me to match the lines one by one here, i mean I'd
> like to match the first line in a single string, but I cannot find the
> way. I made some researches, but it seams not possible ~~
>
> Any adea?
Previous Topic:Yet Another Question about Cross Referencing Languages
Next Topic:Customizing actions in rules
Goto Forum:
  


Current Time: Thu Apr 25 01:32:23 GMT 2024

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

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

Back to the top