NO

Author Topic: C, Java, JacaScript, Lotus Script and VB  (Read 5134 times)

MGJ

  • Guest
C, Java, JacaScript, Lotus Script and VB
« on: January 07, 2008, 03:39:52 PM »
Hello,

I'm a C, Java, JavaScript, Lotus Script and VB Developer and I have little problems when I'm switch between the Softwarelanguages.

First:
Inside C and Java I remark Lines with /* ... */ or //
Inside JavaScript, Lotus Script and VB I use ' for remark.

So it would be nice, the Pelles C IDE checks when I'm typing ' as the first character in a line, and replace them with //.

Second:
Inside VB and Lotus Script I type If .... Then .... End If

Now it would be nice, the Pelles C IDE could check them and replaces Then with {, replaces End If with } and replaces Else with } else { Replace should be not! case sensitive.

Thanks.

Synfire

  • Guest
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #1 on: January 07, 2008, 08:16:34 PM »
You would probably have to write an add-in to handle the C/C++ comment to BASIC comment conversions on the fly. But most of the rest of the stuff can be done with a header file (not really sure why you would want to but it can be done).

In your custom header file create definitions like:
Code: [Select]
#define While while
#define If if
#define Then {
#define Do {
#define Else } else {
#define Else_If } else if
#define End(x) }
...

These will allow you to create source code which looks like:
Code: [Select]
While ( 1 ) Do
If ( MyProc() == 1 ) Then
// MyProc Returned 1
Else_If ( MyProc() == 2 ) Then
// MyProc Returned 2
Else
// MyProc Returned something else
End( If )
End( While )

When the preprocessor expands those definitions, they are practically the same as:
Code: [Select]
while ( 1 ) {
if ( MyProc() ) {
// MyProc Returned 1
} else if ( MyProc() == 2 ) {
// MyProc Returned 2
} else {
// MyProc Returned something else
}
}

Of course all this really does is slow down compile time so that your code looks like a different language when you could just as easily develop in a different language or become more familiar with C/C++. You're not the first to want to do this, there was this one guy I used to work with that used to do the same thing, it annoyed the hell out of me. He had a set of includes which wrapped everything into his own little psuedo language which was a mix of C/BASIC/FORTH. He claimed it "sped up development time" but considering the time it took for us to decipher his code when we coordinated on a project it was hardly ever the case. [and god forbid a bug ever occur in his code]. :-\

I guess this is cool if you never plan for anyone to ever see any of your source code, and so long as you keep it simple so that you don't end up so heavily wrapping the language that when a bug occurs you have to decode (or fix) your wrappers every time a program errors. But personally I don't really see much of a point in it.

Regards,
Bryant Keller

Offline MrBcx

  • Global Moderator
  • Member
  • *****
  • Posts: 191
    • Bcx Basic to C/C++ Translator
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #2 on: January 11, 2008, 12:38:42 PM »
If you want to use BASIC constructs with Pelles C compiler, I recommend that you look into BCX.

BCX is an excellent BASIC to C/C++ translator that works great with Pelles C, as
well as compilers from Borland, Watcom, Digital Mars, VC++, Lcc-Win32, Mingw32.

I personally perfer Pelles C for it's excellent code generation and lack of bloat.

Bcx Basic to C/C++ Translator
https://www.BcxBasicCoders.com

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #3 on: January 12, 2008, 02:04:42 PM »
I do not think this is in any case practical, if a C source code looks like BASIC, how would you tell the difference if one removes or changes the files extension  ???

I am too using different programming languages, but I never thought what you describe would do me a favour.

I am used to switch my brain if I use a different language, so I can handle comments to be ', //, # or $$ and the different ways to structure loops and conditionals ;)
---
Stefan

Proud member of the UltraDefrag Development Team

MGJ

  • Guest
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #4 on: January 16, 2008, 11:04:52 PM »
I do not want that my C source code looks like BASIC.
So I want that the IDE, not the preprocessor, changes my wrang input into correct C code, if possible.

So easy.

thx

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #5 on: January 17, 2008, 05:36:34 PM »
This is way too specialized to be included in the IDE. As Synfire already pointed out, an add-in should be able to handle this. Left as an exercise for the happy coder...
/Pelle

Freddy

  • Guest
Re: C, Java, JacaScript, Lotus Script and VB
« Reply #6 on: February 13, 2008, 10:14:57 PM »
If you do this it would not be C anymore. If you want to know the power of C you should really get used to its syntax.
As exercise write a tool to do that translation!
TIP: Use regexp.h for matching patterns. ;)