top of page

After taking a degree in computer science in the 1970s I spent my working life in computing. In retirement I have needed, on occasion, to knock up a few simple computer programs, but it’s not easy to do that unless you are a regular user of one of the languages available. I can manage programming in “C” but then you need to remember the effect of those ‘*’ and ‘&’ symbols and it can get quite confusing.

 

I decided, therefore, to implement an interpreter for a siimple language of my own design. This I have called “SLang” for short. The idea is you write your program in a text file (.txt) and send this as input to a “Slangparse” program (written in “C”). This checks for errors and bombs out if it finds one, otherwise it produces a .code file (also a text file). The .code file is then given as input to a “Slangrun” program (also written in “C”), and this runs the SLang program.

 

Programs can take input from the keybord and print results to the screen - they run as “console apps”. They can read from and write to files, and there is also an interface to SQLite databases.

 

I can supply the “C” source of the “Slangparse” and “Slangrun” programs to anyone who would like to try them. It works on my MacBook Pro but I haven’t tried it on any other platform. I have around a dozen SLang programs that work, but use SLAng at your own risk. I can’t guarantee that it is bug free, though I am confident using it myself. I can supply a userguide and several example programs.

 

Here’s one example, which calculates square roots:

 

start

 

function absvalue(x)

    if x< 0 return -x else return x endif

endfunction

 

function sqrt(x)

decimal s;

s=x/2

loop

    if absvalue(s*s-x) < 0.0000001 return s endif

    s = (s + x/s)/2

endloop

endfunction

 

decimal x;

loop

    x = PROMPTNUMBER("Type a number, (-1 to terminate): ")

    if x < 0 exitloop endif

    PRINTLINE ("The square root of " + NUMTOTEXT(x,6) + " is " + NUMTOTEXT(sqrt(x),6))

endloop

 

end

bottom of page