Author Topic: Code parser  (Read 8836 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Code parser
« on: September 21, 2005, 08:15:19 pm »
Hi,

A number of us have complained about EA's inability to reverse engineer any method body into the Initial Code Property of the Behaviour tab of the Operation Dialog.

Since this isn't going to happen anytime soon (is it Sparxians?), does anybody know of a good code parser that I could use to parser some code and grab the body of the methods?

I initially need C# but if it was multi-language that would even be better.

(Before anyone criticises me for being inconsistent - "The concept of round-trip-engineering from model to and from pure code is fundamentally flawed".  I only intend to do this once (well, maybe a small number of times;D) )  Thereafter I will be refactoring the code out of the model...

TIA,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

thomaskilian

  • Guest
Re: Code parser
« Reply #1 on: September 22, 2005, 03:00:40 am »
What a coincidence! I was just about to write the same post when search returned your post.  

I'd also like EA to put the code in Initial Code. That should be easy, shouldn't it?

If you're in a hurry, Paolo, I'd recommend yacc - or the good old human interface ;)

What I'd like to see is the Initial Code window on the  General tab. In that way I could copy/paste code snippets much faster than now (select operation, switch to tab Behaviour, paste code, save, switch to tab General).
« Last Edit: September 22, 2005, 03:17:37 am by thomaskilian »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code parser
« Reply #2 on: September 22, 2005, 03:25:57 am »
I've no experience with yacc, but I suspect that given the level it's working at, it doesn't stop at the body but keeps going down to the symbols.  In other words, it's too detailed for me.

If my understanding is wrong than I'd appreciate someone putting me right.

The fall-back position is the human interface  ;D which I'd use if I could guarantee I'd only use it ones, but I'm too long in the tooth to bet on that one...  So I'd rather get a programmatic solution.

Like you, I don't understand why Sparx didn't add it as an option on reverse engineering.  Even if it ONLY did it if the value was empty...

How's about it Sparx?  Thomas an I will beta test it...  ;D

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Code parser
« Reply #3 on: September 22, 2005, 04:46:30 am »
There is one more beta tester!  ::)
bye
Andreas

thomaskilian

  • Guest
Re: Code parser
« Reply #4 on: September 22, 2005, 02:11:23 pm »
Quote
I've no experience with yacc, but I suspect that given the level it's working at, it doesn't stop at the body but keeps going down to the symbols.  In other words, it's too detailed for me.


You won't probably be able to parse ANY code without going into each symbol (did I mention that my thesis was a Modula2 compiler?). That's the nature of the thing. Having said this, EA's parser MUST have the code - just to be able to skip it in order to find other methods and declarations.  It's probably extra work NOT putting the code in ;)
« Last Edit: September 22, 2005, 02:12:26 pm by thomaskilian »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code parser
« Reply #5 on: September 22, 2005, 03:09:55 pm »
Quote
You won't probably be able to parse ANY code without going into each symbol (did I mention that my thesis was a Modula2 compiler?). That's the nature of the thing. Having said this, EA's parser MUST have the code - just to be able to skip it in order to find other methods and declarations.  [size=13]It's probably extra work NOT putting the code in ;)[/size][/b]
Yes, I agree!  Another example of EA's UI (Unique Interface)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Code parser
« Reply #6 on: September 22, 2005, 10:16:49 pm »
Hello guys,

The bodies of methods are currently not imported into the code field in EA because we made the decision not to.  Certainly not because it was too hard.

This thread prompted a discussion here, and we are planning to add the option in for our next major release.

However, we're curious about why you want it and how you will use it.  This is how we would invisage the code engineering be used.

Code is initially reverse engineered into EA if project already existed. (code field left blank).
Edit/refactor in EA.
Operation bodies can be edited by selecting the operation in the model, the built in editor then opens to the source of that method.  (Multiple enhancements to this have been made for the next release)
Changes can then be generated.  EA synchronises with existing source code so that method bodies are preserved.
Repeat everything except for the first step indefinately.

Simon

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code parser
« Reply #7 on: September 23, 2005, 01:09:44 am »
Simon,

I definitely CAN'T speak for the others as my needs are specialised...

I literally just want EA to put the body in to the InitialCode property if it is empty.  Otherwise leave it alone.

Thereafter, I'll do my Majik with it...

Any chance I could get a special build of the current release with this functionality?  I need this by early next week.  For a presentation to Senior Managment...

It would be a GREAT sales boon!

I'm really trying to push EA here to replace ROSE.

They've literally spent millions on RATIONAL in the past few years...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Code parser
« Reply #8 on: September 23, 2005, 01:50:20 am »
So beware of those who authorised the million spend feeling threatened by a change ...

thomaskilian

  • Guest
Re: Code parser
« Reply #9 on: September 23, 2005, 02:10:05 am »
Mike is right. Cover your ass ;)

Simon, I think I know why you didn't put in the code. Once you have the option, the users will cry for a roundtrip engineering like in Rose (with all these tags inside to identify the model relations). So for reverse engineering you have to be very careful. I wouldn't like to see that burden carried with EA :P

I don't want any roundtrip - the MODEL rules! However, sometimes you inherit some piece of code and you have the feeling it's better to maintain it in an EA repository. For that purpose I need to import everything ONCE.

My 2 cents...

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code parser
« Reply #10 on: September 23, 2005, 02:19:46 am »
Quote
So beware of those who authorised the million spend feeling threatened by a change ...
The decision was made last year to stop RATIONAL.  The problem is stasis...

But the threat in other situations is very real and your concerns are appreciated...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Code parser
« Reply #11 on: September 23, 2005, 07:11:47 am »
Quote
My 2 cents...
Of course - Euro-users now have cents as well ! Our kids just call them Euro-pennies.

PS. Did you know that old French 10F coins in some cases work in 1 EUR coin machines ?
Since 10F is (was) worth more than 1 EUR, it wasn't cheating !

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Code parser
« Reply #12 on: September 25, 2005, 07:14:20 pm »
Paolo, we can't really provide a build for you Paolo.  The best that we can do is the beta, but that won't be ready for your deadline.  So I think as Thomas originally suggested, the human interface might be your best bet.  At least you can do that with confidence that if you need to do it again, EA will be providing the option.

I also realised that your needs for this would be driven by different factors than most EA users.

Thomas, you're right about why we never wanted the option, and I definately agree with you that the MODEL should rule, and ideally reverse engineering is something only done once. (Actually, ideally it shouldn't need to be done at all.)

I do however see a use in keeping the code as something the model can refer to.  So that the method in the model, doesn't need to describe how it is implemented.  That is where synchronisation becomes useful.

I'd also like to clarify that my original post describes how I would see things happening without the option being added, or with it turned off.
« Last Edit: September 25, 2005, 07:16:40 pm by simonm »