Go Down

Topic: An idea for converting code - BASIC to C++/Arduino, with flowcharting (Read 2 times) previous topic - next topic

michaelcollier


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?


eried

>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):

My website: http://ried.cl

cr0sh

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.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Go Up