Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar related help
Grammar related help [message #1712574] Mon, 26 October 2015 14:36 Go to next message
Prakyath Jaladhar is currently offline Prakyath JaladharFriend
Messages: 15
Registered: July 2015
Junior Member
Hi,

The language I am working on contains entry methods, so the rule for an entry method may look like this:

Entry:
	  'entry' 'void' entryName=ID ep=EParameters code=CCode
;

CCode:  '[' -> ']' 
	| '{' -> '}' 
	| '(' -> ')' 
	;


The CCode can also contain braces as well. So basically whatever comes after EParameters which can be inside one of the three braces should be treated as CCode (which can include braces inside as well). I need to ignore whatever code is in the CCode block. How can I achieve this?
Re: Grammar related help [message #1712603 is a reply to message #1712574] Mon, 26 October 2015 17:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
On 26.10.15 15:36, Prakyath Jaladhar wrote:
> Hi,
>
> The language I am working on contains entry methods, so the rule for an
> entry method may look like this:
>
>
> Entry:
> 'entry' 'void' entryName=ID ep=EParameters code=CCode
> ;
>
> CCode: '[' -> ']' | '{' -> '}' | '(' -> ')' ;
>
>
> The CCode can also contain braces as well. So basically whatever comes
> after EParameters which can be inside one of the three braces should be
> treated as CCode (which can include braces inside as well). I need to
> ignore whatever code is in the CCode block. How can I achieve this?

You would need a handcrafted lexer for that to make it efficient and
correct.
A somewhat slower but also correct solution would use a data type rule
and list all other terminals in its body.

What do you really want to do? Why do you want to have black box
literals in your language?

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Find help at http://xtext.itemis.com or xtext(@)itemis.com
Blog: zarnekow.blogspot.com
Twitter: @szarnekow
Google+: https://www.google.com/+SebastianZarnekow
Re: Grammar related help [message #1712605 is a reply to message #1712603] Mon, 26 October 2015 17:45 Go to previous message
Prakyath Jaladhar is currently offline Prakyath JaladharFriend
Messages: 15
Registered: July 2015
Junior Member
Hi Sebastian,

Thank you for the reply. I am porting existing yacc grammar for a parallel programming framework called Charm++. It is developed in c++ and the grammar for the charm++ source file (*.ci) is written in yacc. It also has a dedicated lexer too.

I am trying to make eclipse as an IDE for *.ci files. I just need to ignore the code written in c++ in the CCode block.

An example ci file might look like this:
module jacobi {
    entry Jacobi(void);
    entry [accel] void doCalculation() {
        int x, y;
        .
        .
    }
}


I need to ignore the code inside the function doCalculation as it is normal c++ code. I tried to make the CCode rule a terminal rule, but the parser considers all brackets as CCode rule. How should I use a data type rule and list all other terminals in its body?
Previous Topic:5 minute tutorial: Bundle org.eclipse.equinox.simpleconfigurator is not active
Next Topic:Extending Domainmodel example: Adding own TypeComputer
Goto Forum:
  


Current Time: Tue Apr 23 07:54:13 GMT 2024

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

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

Back to the top