Jump to content



Photo

Looking for a scriping language with a tiny footprint

scripting language embedded systems

  • Please log in to reply
4 replies to this topic

#1 Lant

Lant

    Neowinian Senior

  • Joined: 13-April 06

Posted 14 November 2012 - 20:29

Hey guys. I'm currently looking for a scripting language with a tiny footprint (less than 3KB RAM and a binary that when compiled is less than 20/30KB).

All I need is the ability to evaluate statements similar to first order logic.
For example: !(x : X | x > 5)
Would mean that "for all x in the set X, return true if all xs are greater than 5, otherwise return false".

I need the ability to define functions that would return these sets (The ability to define X and pass parameters to that function that returns a set).

It would also need to be able to support a limited form of structures, where an attribute could be obtained on a certain variable (eg. x.count).

As for data types, integer, floating point and sets are about all I need. Anything else would probably be ripped out to save space.

It needs to be written in C and the ability to compile on old versions of GCC (3.4.x) would also be useful.

Anyone got any ideas? Ideally I don't want to have to write this myself.


#2 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 15 November 2012 - 01:55

Your requirements are quite strict and I'm not sure that this suggestion meets them completely, but it sounds like you are describing close to the ideal use case for bc, the arbitrary precision calculator language. You can download the source code for the latest version from the GNU Project Archives and read the man page on die.net.

Edit: Although BusyBox does not include bc, you could probably accomplish what you are looking for using the combination of sh, awk, and grep it includes, albeit much less elegantly. BusyBox also gives you the option of selecting features at compile time, so you could choose not to include features you don't need.

#3 OP Lant

Lant

    Neowinian Senior

  • Joined: 13-April 06

Posted 16 November 2012 - 09:36

I'm using this on an embedded system, so it lacks anything like sh, awk or grep. There isn't really an OS... my code gets compiled when the OS code gets compiled.
This also means that there is no notion of running different executables, so no ability to run sh, awk or grep. (At least the platform gives support for proto-processes, or pseudo-processes or whatever it calls them)

Thanks for bc, I'll have a look into it.

Its a shame that if I do have to write it myself, I can't even use bison or flex because of code size issues.

#4 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 16 November 2012 - 19:13

If this is for a proprietary system where you can't use GPL'd code, you can try the FreeBSD implementation of bc instead of the GNU version I linked to in my last post. Its less featureful than the GNU version, but that may not matter, depending on how much of the functionality you actually need. (And, most importantly, its BSD licensed.)

PS: I feel your frusturation with limited ROM space for embedded development. I have hit the limit on the PIC18F242 and ATMEGA328P many times.

#5 OP Lant

Lant

    Neowinian Senior

  • Joined: 13-April 06

Posted 16 November 2012 - 21:26

GPL code is perfectly fine for me, its all for academia so there shouldn't be an issue.

Anyway it looks like our team is just going to implement a small language. We've already got a small vm working, just need to finish the lexing, parsing and compiling.