Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Hint on how to implement dynamically enabled/disabled language features(Hints on which parts of xtext would need to be customized for a language to have a dynamical grammar/model. Where "dynamic" means in this case to be able to enabled/ disable rules)
Hint on how to implement dynamically enabled/disabled language features [message #1737876] Wed, 13 July 2016 17:39 Go to next message
Javier Fernandes is currently offline Javier FernandesFriend
Messages: 6
Registered: July 2009
Junior Member
Hi guys !

I know this could be like a really abstract question for something that depends on each case, but for my xtext language I would really love to have some sort of "levels" to enabled / disabled some language features.

For example, my language is an OOP language used for teaching OOP starting with objects and later introducing classes in the course.
So a class is a grammar rule. A language file can have objects, classes, packages, etc..

But I would really like the IDE to behave like ignoring that Class grammar rule, if not "enabled".
Some aspects that I think that it will impact:

* Parser
* Autocomplete
* Syntax highlight

So any help or hint on where to touch would be really appreciated.
Or a strategy if you have one.
Specifically for the parser part Razz


Also, does XText have some kind of plans on supporting such a thing ?

Thanks !

Regards
Re: Hint on how to implement dynamically enabled/disabled language features [message #1737886 is a reply to message #1737876] Wed, 13 July 2016 18:54 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi Javier!

Abstract question - abstract answer Smile

There is no out-of-the-box solution for this nor any plans to support this. What you basically need is an implementation of each level of the grammar. You could provide a grammar per level in your project, all generated by one workflow. Each of them should map to the same metamodel, which then should define a superset of all concepts.

At runtime you would need to create an injector dependent on your runtime settings, which would effectively pick the guice modules of the certain level.

I'm not sure if that actually works in the UI, though.

Kind regards,
~Karsten
Re: Hint on how to implement dynamically enabled/disabled language features [message #1737930 is a reply to message #1737876] Thu, 14 July 2016 08:49 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

this is not a real answer to your question, but what you aim at is
similar to Java-- https://github.com/LorenzoBettini/javamm (intended for
teaching) implemented with Xtext and Jbase
https://github.com/LorenzoBettini/jbase.

cheers
Lorenzo

--
Prof. Lorenzo Bettini, Computer Science, DISIA, Univ. Firenze
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Hint on how to implement dynamically enabled/disabled language features [message #1738003 is a reply to message #1737930] Thu, 14 July 2016 20:42 Go to previous messageGo to next message
Javier Fernandes is currently offline Javier FernandesFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks Karsten !

I was thinking more like in a single language than composing multiples. And introducing some "intrusive changes" to enable / disabled features.
But I could try what you said.
Thanks

@Lorenzo: also thanks for your response. I'll take a look at it.

As for the language itself, we already have one that now has more than 2 years. It is called Wollok.
We have been using it in two national universities in Argentina. Soon also to be used in a public high-school.

It is an interpreted, dynamically typed language (but with many static checks).
And it combines objects with classes.

Over many years of teaching OOP we (a group of professors from several national universities in Argentina) elaborated what we call an "incremental learning path" which, to summarise, starts just with objects and introduces classes later.
We initially used Pharo's Smalltalk, and then a tool that we built (not me, but some other colleagues) on top of it for working only with objects called Ozono (Paper here, and link to the tool sorry only in spanish).
Wollok is the "evolution" of such experiences, built on top of XText (I have been also using XText to teach DSLs in another subjects also in nat univ here)
Two other papers we wrote
- Wollok - Relearning How To Teach Object-Oriented Programming
- Instances and classes in the Introduction of Object Oriented Programming


Here is the github page
The language reference (quiet long)

And some screenshots on the release notes (sorry, pending two latest releases notes Razz)
https://github.com/uqbar-project/wollok/wiki/Wollok-v1.3-Confucius
https://github.com/uqbar-project/wollok/wiki/Wollok-v1.2-Buddha
https://github.com/uqbar-project/wollok/wiki/Wollok-v1.1---Aristoteles

Examples (need a refactor)


We are currently working (amongst other subjects) in a webapp to try the language online, and contribute with examples, tests (ending up in automatic branches and PRs).
It is in a really alpha state Razz
https://wollok-showcase.herokuapp.com/#/dashboard/overview

Another prototype that we are working on is an (almost) automatic graphical interface for objects called "Wollok Game". So that professors can build "incomplete" games, or bundle assets, and then student just need to code the domain code, but still be able to "see" their logic running in a visual way.
http://wollok.github.io/granja-de-orson-game/
Sorry only in spanish for the moment, but you can check the screenshots Smile

We also have a test plugin, similar to JUnit in eclipse, a debugger, a Sublime plugin that along with a headless version of the product allows to run wollok in a lightweight way, ACEEditor support (web editor), and some work-in-progress diagrams Smile

The language is starting to have advanced feature like mixins (similar to scala's traits) and we are very concerned on the fact that starters students shouldn't be bothered or confused with advanced topic (that for example was took in consideration while thinking on the modularization and import system. You don't want the student to write imports and packages for your first hello-world program. Even if you just tell them "write this as it is, we will explain it later")
We would love to have language features getting "unlocked" as far as they go through the learning process.

Anyway. I think that I will get better knowledge on AntLR and the inner details of how XText generates the parser to see if there's a way to dynamically change that Razz

Regards

[Updated on: Thu, 14 July 2016 20:46]

Report message to a moderator

Re: Hint on how to implement dynamically enabled/disabled language features [message #1738022 is a reply to message #1738003] Fri, 15 July 2016 07:16 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Hi Javier!

I looked at the links you provided and I am quite impressed what you have done. Thanks for sharing!

The Web example is not working correctly at the moment. The examples can be choosed from the left side, but when you press the Play button an exception is printed in the output area.

It is of great interest to me if you find a solution to your problem. So please reply to this thread if you came further.

~Karsten
Re: Hint on how to implement dynamically enabled/disabled language features [message #1738279 is a reply to message #1738022] Mon, 18 July 2016 15:41 Go to previous message
Javier Fernandes is currently offline Javier FernandesFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Karsten,

Thanks for your feedback.
For sure I'll come back here and update you if we manage to implement this.

Regards !
Previous Topic:Xtext Nodeutil undefined error
Next Topic:Xtext external character as part of terminal rule?
Goto Forum:
  


Current Time: Tue Feb 27 21:34:37 GMT 2024

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

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

Back to the top