Skip to main content



      Home
Home » Archived » GMT (Generative Modeling Technologies) » [TCS] Best practices
[TCS] Best practices [message #378134] Thu, 14 June 2007 04:28 Go to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

Hello,

Working with a base metamodel, I am trying to express its concrete
syntax in TCS (using the TCSToolkit). As several classes in this
metamodel have their textual representation starting with the same
tokens, this leads to grammar ambiguity.

So I would like to know, according to you, what is the best way to lift
this ambiguity (adapting the metamodel by adding factoring classes ? or
whatever...)

Thanks

Quentin

PS : to be sure to be up to date, I looked at my TCSToolkit version. (It
is said that TCS2ANTLR was last modified on February 26 2007 21:35:00)
Does it exist an updated version and/or a cvs repository for it ?
Re: [TCS] Best practices [message #378180 is a reply to message #378134] Thu, 14 June 2007 05:23 Go to previous message
Eclipse UserFriend
Hello,

> Working with a base metamodel, I am trying to express its concrete
> syntax in TCS (using the TCSToolkit). As several classes in this
> metamodel have their textual representation starting with the same
> tokens, this leads to grammar ambiguity.
>
> So I would like to know, according to you, what is the best way to lift
> this ambiguity (adapting the metamodel by adding factoring classes ? or
> whatever...)

The simplest way, is to increase k (in LL(k)). However, this will only
work if the ambiguities can be lifted with a fixed lookahead.

syntax MyLanguage(k = <the value you want for k (3 is not specified)>) {
....
}

Then, you may use disambiguate = "..." to add syntactic predicates
(http://antlr2.org/doc/metalang.html#SyntacticPredicates), which enable
arbitrary lookahead.


template Test (disambiguate = "...")
:
;

A simple way to find a working predicate, although it is not minimal, is
to use the whole rule itself:

template Test (disambiguate = "test")
:
;


Another solution is to wait for the new version of TCS that will support
ANTLR 3.0 and the LL(*) algorithm, which enables arbitrary lookahead and
automatic backtracking ;-).


> PS : to be sure to be up to date, I looked at my TCSToolkit version. (It
> is said that TCS2ANTLR was last modified on February 26 2007 21:35:00)
> Does it exist an updated version and/or a cvs repository for it ?

There is no newer version available yet.


Best regards,

Frédéric Jouault
Re: [TCS] Best practices [message #601851 is a reply to message #378134] Thu, 14 June 2007 05:23 Go to previous message
Eclipse UserFriend
Hello,

> Working with a base metamodel, I am trying to express its concrete
> syntax in TCS (using the TCSToolkit). As several classes in this
> metamodel have their textual representation starting with the same
> tokens, this leads to grammar ambiguity.
>
> So I would like to know, according to you, what is the best way to lift
> this ambiguity (adapting the metamodel by adding factoring classes ? or
> whatever...)

The simplest way, is to increase k (in LL(k)). However, this will only
work if the ambiguities can be lifted with a fixed lookahead.

syntax MyLanguage(k = <the value you want for k (3 is not specified)>) {
....
}

Then, you may use disambiguate = "..." to add syntactic predicates
(http://antlr2.org/doc/metalang.html#SyntacticPredicates), which enable
arbitrary lookahead.


template Test (disambiguate = "...")
:
;

A simple way to find a working predicate, although it is not minimal, is
to use the whole rule itself:

template Test (disambiguate = "test")
:
;


Another solution is to wait for the new version of TCS that will support
ANTLR 3.0 and the LL(*) algorithm, which enables arbitrary lookahead and
automatic backtracking ;-).


> PS : to be sure to be up to date, I looked at my TCSToolkit version. (It
> is said that TCS2ANTLR was last modified on February 26 2007 21:35:00)
> Does it exist an updated version and/or a cvs repository for it ?

There is no newer version available yet.


Best regards,

Frédéric Jouault
Previous Topic:[TCS] Best practices
Next Topic:[oaw:xtend] Editor complains when using 2 stdlibextensions
Goto Forum:
  


Current Time: Fri Apr 18 07:24:22 EDT 2025

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

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

Back to the top