Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Yet Another Programming Language

Sun Nov 04, 2018 8:56 pm

Hello everyone.

I have a little experience with electronics/rpi linux, but have much experience
programming computers. Browsing the RosettaCode site, i found over 190
programming languages. So i decided to write one more, WSD(Scripting Dynamics).

WSD is written in Ansi C. It was built and tested in Windows, then ported
to Android, and now to RPI zeroW with Stretch Lite.

It is a simple but efficient scripting language. It borrowed some features
from the original Basic language. There is a byte code compiler "<30k", and
byte code interpreters "<30k". It is Open Source, full c source code is available.
Its objective and strength is in scripting dynamic link libraries(shared objects).

Code: Select all

    //Dynamic libraries must have an entry point like this. It serves as a bridge
    //to access its exported functions.
    char * _run(char *proc, int *e, int argn, char **argz) {
    int i, n;
    *e=0;
    if (strcmp(proc, "getJulianDate")==0) {
        n=getJulianDate(argz[0]);
        if (n==-1) {
            sprintf(xbuf, "Error processing Julian Date %s", argz[0]);
           *e=1;
        } else {                
            sprintf(xbuf, "%d", n);
        }
        return xbuf;
    }
    if (strcmp(proc, "getDatefromJulian")==0) {

Code: Select all

    'WSD scripting Julian Date library
    c$=chr(10)
    import juldate
    loop:
        print "enter date mm/dd/yyyy "
        dte$=input
        ln=len(dte$)
        if ln=0 then goto exit:
        if ln<>10 then goto loop:
        jdte$=juldate.getJulianDate(dte$)
        if err then print errmsg & c$ : goto exit:
        print "juldate=" & jdte$ & c$
        goto loop:
    exit:
        end
All the functionality should reside in shared objects. In this example placing
"getJulianDate" function in the byte code interpreter instead of shared object
would have been possible but wrong.

For example, in Windows we have Sqlite.dll which is well documented.
I wrote a rather complex DLL "<8k" which gives access to the main Sqlite functions.

Here we have two different programming efforts, building dynamic libraries, and
writing scripts to those libraries. Like Activex objects(OCX) and vbscript.

I created a simple web site https://wsd.netlify.com where you can find source code,
and more information. WSD seems like a good fit for microcontrollers/SBC.

Try it and let us know your experience.

Bye

ejolson
Posts: 3232
Joined: Tue Mar 18, 2014 11:47 am

Re: Yet Another Programming Language

Mon Nov 05, 2018 1:59 am

Pancho88 wrote:
Sun Nov 04, 2018 8:56 pm
So i decided to write one more, WSD(Scripting Dynamics).
Does WSD stand for Windows Scripting Dynamics?

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Mon Nov 05, 2018 4:40 pm

Yes.

It was originally built and tested in Windows, then ported to Android, and now to RPI zerow stretch lite.

It is basically the same for all platforms. Its difference is "dlopen vs Loadlibrary".

Its compiled byte code runs with no change in Windows, Android, and RPI.

Bye

hippy
Posts: 5588
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Yet Another Programming Language

Fri Jun 28, 2019 8:12 pm

Pancho88 wrote:
Sun Nov 04, 2018 8:56 pm
Try it and let us know your experience.

Code: Select all

pi@Pi3B:~/wsd $ gcc -o wsd wsd.c
wsd.c: In function âmainâ:
wsd.c:2583:13: warning: implicit declaration of function âcloseâ; did you mean âpcloseâ? [-Wimplicit-function-declaration]
             close(fp);
             ^~~~~
             pclose
pi@Pi3B:~/wsd $ cat test.sd
print "Hello world!"
pi@Pi3B:~/wsd $ ./wsd test
Missing Quote in line 1
Missing Quote in line 1
Syntax Error in line 2

pi@Pi3B:~/wsd $
Not so worried about the warning from gcc, but why can't I run/compile the simplest of WSD programs ? Any help or guidance ?

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Fri Jun 28, 2019 10:16 pm

Hello

On Feb 16 2019 i posted in the rpi forums a link to Google Drive, where you could get
all the C source code to WSD.

For some strange reason it was removed from the forums. Still, if i go to google search
i can see that post is in the forums, but when i click to see it, i get a message
informing it is Not available.

Any way here is the link to google drive.
There are 3 directories, Execs, Dynlibs, scripts. They have clear documentation.

https://drive.google.com/drive/folders/ ... sp=sharing


Bye

User avatar
Paeryn
Posts: 2606
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Yet Another Programming Language

Fri Jun 28, 2019 11:31 pm

The wsdc0 compiler only works if the .sd file it compiles has DOS line endings, given a file with Unix line endings throws all the errors.

The function for evaluating bitwise operators (in Eval_Exp1 at line 862) converts any bitwise AND or OR into XOR. The cases for SB_AND and SB_OR both fall through so if any of those three are matched then c=SB_XOR.

Code: Select all

        switch (op) {
                case SB_AND:
                        c=SB_AND;
                case SB_OR:
                        c=SB_OR;
                case SB_XOR:
                        c=SB_XOR;
        }
As you can see in the example below, the compiler fails to compile if Unix files are used but works when converted into DOS. Also the result of 5 AND 11 should be 1, the result of 14 shows it did an XOR.

Code: Select all

pi@rpi3:~/Programming/wsd/comp/execs $ cat hello.sd
c$ = chr(10)
print "Hello" & c$
a = 5
b = 10
c = a AND b
print a & " AND " & b & " = " & c & c$

pi@rpi3:~/Programming/wsd/comp/execs $ ./wsdc0 hello
Unknown Keyword in line 3
Equal Sign Expected in line 6

pi@rpi3:~/Programming/wsd/comp/execs $ unix2dos hello.sd
unix2dos: converting file hello.sd to DOS format...
pi@rpi3:~/Programming/wsd/comp/execs $ ./wsdc0 hello
pi@rpi3:~/Programming/wsd/comp/execs $ ./wsdvm0 hello
Hello
5 AND 11 = 14
She who travels light — forgot something.

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Sat Jun 29, 2019 12:23 am

Hello

Thanks paerin
I will check and make the changes needed.

Bye

hippy
Posts: 5588
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Yet Another Programming Language

Sat Jun 29, 2019 1:35 am

Paeryn wrote:
Fri Jun 28, 2019 11:31 pm
The wsdc0 compiler only works if the .sd file it compiles has DOS line endings, given a file with Unix line endings throws all the errors.
Thanks. That fixed it.

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Sun Jun 30, 2019 10:27 pm

Hello

I transferred all files to Rpi from a windows machine. That is why i did not
see the dos/linux format problem.

There is a bug in handling "Double Quotes" with the linux version. This bug was
well hidden, but i am working on it.

The compiler must work with either format.

Pearyn
Thank you so much. You seem to understand, and follow the inner workings of WSD.

Hippy
Thank you for helping revive the WSD project.

Bye

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Sun Jul 07, 2019 9:55 pm

Hello

Here is the fix to the dos/linux format problem. It is very simple, but was
a little hard to see.

Code: Select all

    if (ch=='"') {          //QUOTED STRING
        n=0;
        while (1) {
            ch=MyProg[++ProgPtr];
            if (ch=='\n') break;
            if (ch=='"') {
                ch=MyProg[ProgPtr + 1];
                if (ch=='"') {
                        Token[n]=ch;
                        ProgPtr++;
                } else {
                    ch=' ';         //Here is the FIX
                    break;
                }
            } else {
                Token[n]=ch;
            }
            n++;
        }
This fix applies to both wsdc0.c(Exec) and wsdc1.c(Dll/SO).

Now we should be able to compile SD files in either format.

Also do not forget to insert the break statements in wsdc0/wsdc1.
int Eval_Exp1() { //BITWISE

Bye

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Yet Another Programming Language

Mon Jul 22, 2019 2:35 am

When I first saw this thread title I thought the topic would be a programing language named YAPL or possibly YA/PL :) .
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

Pancho88
Posts: 23
Joined: Wed Feb 21, 2018 4:40 pm

Re: Yet Another Programming Language

Wed Jul 24, 2019 10:07 pm

Davids
Download WSD from GoogleDrive, do some testing/experimenting.

Then tell us your experience.

Bye

Return to “Other programming languages”