Pages: [1]   Go Down
Author Topic: An idea for converting code - BASIC to C++/Arduino, with flowcharting  (Read 1855 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I've been working on some ideas for helping developers switch from BASIC to target code - C/C++/Arduino (and others).

My demo application reverse engineers BASIC code and converts to the selected target code.

To make things simpler, the code is broken down into subroutines automatically and a flowchart is created for each routine.

This way users can either use the flowchart interface or the text editing interface in whichever language they like.

There are plenty of BASIC programmers out there who I reckon would find this a good way to switch to Arduino.

The application uses Gold Parser Builder to define the Source & Target languages http://goldparser.org/ so I don't need to re-code the whole application to include another language. It can currently process a couple of dialects of BASIC (my own which is similar to VB, and PBASIC e.g. Basic Stamp) and can handle a few dialects of C/C++/C#/Java/Arduino.

The IDE uses a database to track the list of available compilers, so users can compile an Arduino application, or they could create a simple C project and the IDE will fire up and link the correct set of files - it should be able to handle ChipKit, Maple - just update the local database.

Here are some videos I uploaded to demo this to a colleague in Singapore, in each case the source code is pasted into the editor and flowcharts/conversions are then done automatically there are more features than this but these are the ones that I think will interest Arduino users?

1. Reverse engineering BASIC into 2 subroutines and generate flowchart(s)


2. Reverse Engineer PBASIC


3. Reverse Engineer BASIC and convert to C style


4. Reverse Engineer Arduino program, draw the flowcharts and convert to BASIC


I'd be interested in hearing peoples views..

Thanks in advance
Michael
Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks really cool!
Logged

My website: http://ried.cl

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks really cool!
Thanks, would you like to try it? I could use some feedback from arduino users..

Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure smiley-grin
Logged

My website: http://ried.cl

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You think with the parser you used for the code it is possible to update the old arduino libraries? http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/ looking at those rules? I am trying to add an automated installer (it is pretty complete now) but still missing the "old library" update procedures (for now I is just fairy simple regex replacements) but I think I need fancy stuff to understand if  replacement is in comments, or anything the coder can do.
Logged

My website: http://ried.cl

0
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You think with the parser you used for the code it is possible to update the old arduino libraries? http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/ looking at those rules? I am trying to add an automated installer (it is pretty complete now) but still missing the "old library" update procedures (for now I is just fairy simple regex replacements) but I think I need fancy stuff to understand if  replacement is in comments, or anything the coder can do.

I can parse for some of the rules for definate, I tried the 2 below and the parser could pick them up and at least give a report to the user that they need changing if some kind of tool was needed to do that.

The BYTE keyword
Serial.print(val, BYTE)
To:
Serial.write(val); //sends as char

Migrating Wire (I2C) statements
Wire.send()
To:
Wire.write()
And change:
Wire.receive()
To:
Wire.read()

I don't know about the problems caused by dervied classes, I would need to examine this e.g.

Return values from write() methods
Classes derived from Print must implement a write method to write data to the device that the class supports. The signature of the write method has changed from void to size_t to return the number of characters written. If you have a class derived from Print you need to modify the write method as follows and return the number of characters written (typically 1). Change:

    void write
    To:
    size_t write


Overall I think it's worth attempting something, the main problem is that I have not validated the Arduino/Wiring syntax completely, but then again doing something like this would go some way toward getting that validation completed.

Can you download Gold Parser Builder http://goldparser.org/builder/files/GOLD-Builder-5.2.0-Setup.zip
I can send a compiled grammer file for arduino etc that you can load into it and scan your library source file, from there you can see in a tree structure what is recognised and possible to trap in some kind of conversion tool?

Logged

Chile
Offline Offline
Edison Member
*
Karma: 35
Posts: 1251
Arduino rocks?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

>and possible to trap in some kind of conversion tool?

You mean to compile the solution?
I want to build a dll with this routines so I can update them in the future. The basic structure I am using now (of course is extremelly primitive but it is just to split the Library Repair from the Manager in my Modded Arduino IDE):

 
Logged

My website: http://ried.cl

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5551
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I would suggest rather than homebrewing your own system, roll it into (or likely, fork off of) the QB64 project; it uses (IIRC) gcc as it's backend to compile to native.
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Pages: [1]   Go Up
Jump to: