Is there a formal grammar for PICAXE basic?

olav

New Member
I am starting a new project to build a web-based, point/click programming interface for PICAXE and I would like to base it around a formal grammar of the language.

Really, any format will do, but I plan to use PLY as parser generator so YACC/LEX format will be most appreciated.

Thank you,
Olav
 

hippy

Technical Support
Staff member
I don't think anyone has published a formal grammar definition but it should be easy enough to create from the F1 Quick Syntax Checker, the user manuals or online command documentation.

Most commands are fairly simple with some repeated and optional parameters, the SERIN command is perhaps the most complicated with optional qualifiers or just qualifiers. A few are two choice ...

HIGH <pin> { , <pin> ... }
SERVO { \[ <varOrValue> \] , } <pin> , [ OFF | <varOrByteValue> ]
HI2CIN { \[ <varOrByteValue> \] , } { <varOrValue> , } ( <var> { , <var> } )

Perhaps the main diffficulty is where some parameters are not available for some PICAXE variants.
 

mrburnette

Senior Member
Welcome olav!

From the official manual: http://www.picaxe.com/docs/axe001_mode.pdf
The Programming Editor allows control programs to be generated for microcontrollers.
Programs can be created in three ways - drawn as flowcharts, written in a simple
textual BASIC language, or written in the much more advanced assembler code language.
There has been a small number of threads over the past couple of years dealing with other programming editors, LaTeX if memory serves me right, but I do not remember any positive outcome. The three (3) most common editors for PICAXE programming are here: http://www.picaxe.com/Software

The PLY Lex-Yacc appears to be a very interesting editor, but I have no past experience with it. You could likely build a syntax file rather quickly for PLY since the PICAXE BASIC language is rather simple and does not support private variables or functions or subroutine parameter passing. If you install the Program Editor for Windows, pressing F1 brings up the entire command set and the associated syntax. Or, download manual 2 on the language: http://www.picaxe.com/docs/picaxe_manual2.pdf

Good luck. Please do report if you are successful in this approach.

- Ray
 

olav

New Member
Ray and hippy,

thank you for your replies. I have started to build a parser/lexer for the PICAXE language and will publish it once it can handle a few examples.

Maybe some explanation about the use case I am targeting: I have held some workshops with teens in the past, using both the textual PICAXE language and the flowchart approach. I would like to hold these workshops in places where there is not a laptop for every single or two participants.

My thinking is that if I can come up with a web-based editor, similar to the flowchart way, but instead of blocks using a textual representation of the program text and hyperlinks at "choice points", I can have participants use their mobile phones or tablets or really any device with an internet connection to create PICAXE programs.

A single PC with a few USB ports is then needed to run the command line compilers on the programs entered and to program PICAXE boards attached to the USB ports.

-- Olav
 

mrburnette

Senior Member
Olav, Interesting approach. As a retired IT architect, I have seen good web interfaces and a few ugly ones, too. I'll be very interested in seeing what you come up with. Somewhere in these many threads, I remember suggesting a PICAXE web-based tool.

- Ray
 

olav

New Member
I now have a very rough, first working prototype of my web-based PICAXE editor. It is implemented as a web application in Python and provides a drag & drop interface to write text-based programs in PICAXE Basic. This is what it looks like:



The software is open source and can be downloaded at http://schettler.net/fossil/paw

This is far from complete. I still need to add a whole lot of grammar and provide an editor for expressions. But the basic mechanics work. You can create new programs, add statements or move them around using drag & drop, and you can program PICAXE 08m chips using the compiler that comes with the AXEpad editor.

A first step, but I plan to use this at my next Physical Computing workshop in June, where I will offer some PICAXE boards but won't have enough computers. Using this web-based tool, participants will be able to program their PICAXEs using their iPods!

-- Olav
 

olav

New Member
I am sorry, this may not be clear from my instructions. You actually install this editor locally on your machine, connect the PICAXE chips via USB cable(s) there and have your workshop participants access it over the LAN.

But you are right, localhost will not work for this scenario. You will have to access it with the LAN address of your computer, e.g. 192.168.9.40.

-- Olav
 

mrburnette

Senior Member
@olav:

Very, very interesting. Congratulations on the follow-through from concept to prototype. I noticed over the weekend a discussion on using tablets and PICAXE and my response was that a HTML5 approach was the most likely solution to avoid a multitude of specific installation packages. Although your prototype runs locally, it shows much progress.

- Ray
 
Top