All BASIC

Message Boards => Translators => Topic started by: John on October 11, 2013, 02:39:42 AM

Title: BAS2NIM
Post by: John on October 11, 2013, 02:39:42 AM
I would like to propose that the members here contribute to a general purpose BASIC to C converter with a Nimrod twist. The bas2nim translator would take BASIC text and convert it to Nimrod text which would be converted to C and finally compiled by gcc to a binary. ScriptBasic is the best language for the converter and it runs on the same platforms as Nimrod does.

The goal with this project is to save BASIC dialects that people liked to program in and compile them to the platform of choice. Once a core BASIC translator is done, it could be extended with SB modules that handle specific features of the dialect of BASIC it's designed to translate.

Here is the first ScriptBasic to Nimrod translation.

SB
Code: [Select]
PRINT "Hello World!\n"

jrs@laptop:~/bas2nim$ scriba hello.sb
Hello World!
jrs@laptop:~/bas2nim$

Nimrod
Code: [Select]
echo("Hello World!")
jrs@laptop:~/bas2nim$ nimrod c hello.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
gcc -c -w -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/hello.o /home/jrs/bas2nim/nimcache/hello.c
gcc -c -w -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/system.c
gcc   -o /home/jrs/bas2nim/hello  /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/hello.o  -ldl
Hint: operation successful (7440 lines compiled; 1.064 sec total; 12.122MB) [SuccessX]
jrs@laptop:~/bas2nim$ ./hello
Hello World!
jrs@laptop:~/bas2nim$

jrs@laptop:~/bas2nim$ ls -l
total 164
-rwxrwxr-x 1 jrs jrs 153525 Oct 11 02:22 hello
-rw-rw-r-- 1 jrs jrs     22 Oct 11 02:21 hello.nim
-rw-rw-r-- 1 jrs jrs     24 Oct 11 02:20 hello.sb
drwx--x--x 2 jrs jrs   4096 Oct 11 02:22 nimcache
jrs@laptop:~/bas2nim$ nimrod c -d:release hello.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/hello.o /home/jrs/bas2nim/nimcache/hello.c
gcc -c -w -O3 -fno-strict-aliasing -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/system.c
gcc   -o /home/jrs/bas2nim/hello  /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/hello.o  -ldl
Hint: operation successful (7440 lines compiled; 0.476 sec total; 7.768MB) [SuccessX]
jrs@laptop:~/bas2nim$ strip -s hello
jrs@laptop:~/bas2nim$ ls -l
total 28
-rwxrwxr-x 1 jrs jrs 14432 Oct 11 02:45 hello
-rw-rw-r-- 1 jrs jrs    22 Oct 11 02:21 hello.nim
-rw-rw-r-- 1 jrs jrs    24 Oct 11 02:20 hello.sb
drwx--x--x 2 jrs jrs  4096 Oct 11 02:45 nimcache
jrs@laptop:~/bas2nim$
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 03:36:11 AM
One idea that might be cool is a use language directive so multiple dialects of BASIC code can be used.

Code: [Select]
USE SB
...

USE O2

---

Title: Re: BAS2NIM
Post by: John on October 11, 2013, 11:01:48 AM
Nimrod also works as an console mode (interactive) interpreter.

Code: [Select]
jrs@laptop:~/bas2nim$ nimrod i hello.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
Hello World!
Hint: operation successful (3133 lines compiled; 0.070 sec total; 2.256MB) [SuccessX]

jrs@laptop:~/bas2nim$ nimrod i
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: stdin [Processing]
>>> echo("Hello World!")
Hello World!
>>> quit()
stdin(3, 5) Hint: quit() called [QuitCalled]
jrs@laptop:~/bas2nim$


Title: Re: BAS2NIM
Post by: John on October 11, 2013, 11:49:32 AM
I have setup a Cloud9 IDE (https://c9.io/scriptbasic/nimrod) and github (https://github.com/ScriptBasic/Nimrod) project to support the BAS2NIM effort.

Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 04:13:09 PM
John you are a powerhouse. How do you do so much in little time is amazing.

Charles posted that eventually Oxygen will be in C, after things are finalized. So no need to do Oxygen, I would think.

Which other BASIC languages would you recommend for such a project?
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 04:19:32 PM
Quote
Which other BASIC languages would you recommend for such a project?

The plan is to use ScriptBasic for the translator as it uses traditional BASIC for the most part. I would like to see core BASIC syntax translated to Nimrod as verbatim as possible. As this moves along, other dialects (PowerBASIC, FreeBASIC, ...) can be translated. (or a combination of BASIC language syntax, in-line ASM or C)

I'm just getting started with this so nothing is cast in stone in my mind.

Title: Re: BAS2NIM
Post by: John on October 11, 2013, 06:26:14 PM
I think this first BASIC translation round should include the DIM directive as it will help define what areis variables are in the code with a matrix table storing the name, type, size (if string) and array bounds. Even thought SB doesn't require DIM or $ for stings or their functions, I think they should be included for readability and ease of translation.

Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 06:51:20 PM
I will check out your code to see how you are going about this cool stuff John.

I loaded the 3 hello programs, sb, nimrod and php and I see a compiled hello(I assume from nimrod).
I am not sure what we are to do John.  Are you on google+, perhaps we could conference?
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 07:12:34 PM
I started the party with a Hello World! conversion. How about doing a FOR/NEXT conversion to Nimrod. Until we know what we are facing, there is no need to start writing code for the translator yet. This will also have the benefit of showing how Nimrod works in BASIC lingo.

Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 07:22:24 PM
So you just want to write the equivalent code in Nimrod as it is in Scriptbasic and php?

This is fun!
Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 07:31:33 PM
John how is scriptbasic running from the cloud9 nimrod site?
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 07:49:14 PM
I don't understand the question.

Make sure you set the SCRIBACONF environment variable to point to the ~/etc/basic.conf file. You also need to export PATH to include the path to the Ninrod/bin directory. See the README.md in the workspace root directory.

If you mean how did I get SB running on Cloud9 IDE that was simple. They are running Red Hat 64 bit Linux and I just uploaded scriba and extensions modules from the CentOS (Red Hat clone) up to the workspace bin, include and module directories. Anything put in workspace bin is like /usr/bin on other Linux systems.

Quote
So you just want to write the equivalent code in Nimrod as it is in Scriptbasic and php?

The hello.php file is there to test the Cloud9 IDE local Apache webserver. Bring it into the editor and click RUN. A C9 web browser will appear showing the results of your script. (web scripting is the primary focus on Cloud9 IDE)
Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 07:59:00 PM
Quote
If you mean how did I get SB running on Cloud9 IDE that was simple.
That is what I meant John.  Thanks for the explanation.

I don't have to setup a windows development anymore. It is so much fun the way you have things setup!

I did a for file for Nimrod:  for.nim
Is this OK and what you had in mind?
Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 08:06:57 PM
Quote
The hello.php file is there to test the Cloud9 IDE local Apache webserver. Bring it into the editor and click RUN. A C9 web browser will appear showing the results of your script. (web scripting is the primary focus on Cloud9 IDE)

Oops, I edited the php file to say Hello World to match the other examples :)
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 08:07:53 PM
Excellent! Keep it coming.

Code: [Select]
# For Loop in Nimrod

# This is how you comment in Nimrod

# Nimrod uses indentations for code blocking.

# Hence you will see at times # at the front of the line and
# another later in the line to align things nicely.


#                         #BASIC equivalent
echo("Counting to ten: ") #print "Counting to ten: "
for i in countup(1, 10):  #for i = 1 to 10
    echo($i)              #print str$(i)
                          #no next command in Nimrod


#                          #BASIC equivalent
echo("Counting to one: ")  #print "Counting to one: "
for i in countdown(10, 1): #for i = 10 to 1
    echo($i)               #print str$(i)
                           #no next command in Nimrod

                           
#shortcut for                       #BASIC equivalent
echo("Shortcut counting to ten: ")  #print "Shortcut counting to ten: "
for i in 1..10:                     #for i = 1 to 10
    echo($i)                        #print str$(i)
                                    #no next command in Nimrod


#this does not work                           
#shortcut for                       #BASIC equivalent
echo("Shortcut counting to one: ")  #print "Shortcut counting to one: "
for i in 10..1:                     #for i = 10 to 1
    echo($i)                        #print str$(i)
                                    #no next command in Nimrod                           
echo("This does not work with shortcut.")                               

scriptbasic@nimrod:~/639761/BAS2NIM $ ./for
Counting to ten:
1
2
3
4
5
6
7
8
9
10
Counting to one:
10
9
8
7
6
5
4
3
2
1
Shortcut counting to ten:
1
2
3
4
5
6
7
8
9
10
Shortcut counting to one:
This does not work with shortcut.
scriptbasic@nimrod:~/639761/BAS2NIM $
Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 08:13:11 PM
Thanks John. Well if you can make an SB version and then I will convert it to Nimrod unless I get stuck. That should be a good way for me to get up to speed on both languages again.

So John: make scriptbasic version  Kent: make Nimrod version and if possible php, I could use the refresher on it as well!

Does this sound like a plan?
Title: Re: BAS2NIM
Post by: John on October 11, 2013, 08:39:05 PM
I would leave both ScriptBasic and PHP out of the picture right now. I personally have no interest in writing a BASIC to PHP translator. PHP was a mistake and security nightmare from the beginning and still is. Unfortunately everything we use on the web is written in it.  >:( All we are trying to do is create a map to write a text translator. (in SB) Just use traditional BASIC syntax for your examples. Before we get too far down the road, can you do a DIM to var translation so everyone understands how Nimrod variables work?

Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 08:53:20 PM
I got John, ok.

I am going to use GW-BASIC since it is command line and would be a good reference text.
http://www.divonasperi.it/divona/tam/tecnologia/dow-all/GW%20Basic%20(inglese).pdf

1. I am going to study cloud9 docs first.
2. Then work on this project next.



Title: Re: BAS2NIM
Post by: John on October 11, 2013, 09:18:41 PM
Sounds like a great plan. Let me know what I can do to help.

Title: Re: BAS2NIM
Post by: John on October 11, 2013, 10:33:59 PM
Kent,

Your comment about PHP got me thinking about something I briefly passed over in the Nimrod docs. Nimrod translates to more than just C. Here is a translation of the hello.nim to hello.js. The last line of the file is where all the action is at for this script.

Code: [Select]
/* Generated by the Nimrod Compiler v0.9.3 */
/*   (c) 2013 Andreas Rumpf */


var Globals = this;
var framePtr = null;
var excHandler = null;
var NTI830 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI832 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI842 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI103 = {size: 0,kind: 31,base: null,node: null,finalizer: null};
var NTI6452 = {size: 0, kind: 18, base: null, node: null, finalizer: null};
var NTI808 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI137 = {size: 0,kind: 28,base: null,node: null,finalizer: null};
var NTI139 = {size: 0,kind: 29,base: null,node: null,finalizer: null};
var NTI891 = {size: 0,kind: 22,base: null,node: null,finalizer: null};
var NTI824 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI828 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI840 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI844 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NNI844 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI844.node = NNI844;
var NNI840 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI840.node = NNI840;
var NNI828 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI828.node = NNI828;
NTI891.base = NTI824;
var NNI824 = {kind: 2, len: 4, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "parent", len: 0, typ: NTI891, name: "parent", sons: null},
{kind: 1, offset: "name", len: 0, typ: NTI139, name: "name", sons: null},
{kind: 1, offset: "message", len: 0, typ: NTI137, name: "msg", sons: null},
{kind: 1, offset: "trace", len: 0, typ: NTI137, name: "trace", sons: null}]};
NTI824.node = NNI824;
var NNI808 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI808.node = NNI808;
NTI824.base = NTI808;
NTI828.base = NTI824;
NTI840.base = NTI828;
NTI844.base = NTI840;
var NNI6452 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "Field0", len: 0, typ: NTI139, name: "Field0", sons: null},
{kind: 1, offset: "Field1", len: 0, typ: NTI103, name: "Field1", sons: null}]};
NTI6452.node = NNI6452;
var NNI842 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI842.node = NNI842;
NTI842.base = NTI840;
var NNI832 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI832.node = NNI832;
var NNI830 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI830.node = NNI830;
NTI830.base = NTI828;
NTI832.base = NTI830;
var nim_program_result = 0;
var globalraisehook_5411 = null;
var localraisehook_5416 = null;
var outofmemhook_5419 = null;
function cstrToNimstr(c_6734) {
    var result = [];
    for (var i = 0; i < c_6734.length; ++i) {
      result[i] = c_6734.charCodeAt(i);
    }
    result[result.length] = 0; // terminating zero
    return result;
  }
function ArrayConstr(len_7668, value_7669, typ_7670) {
    var result = new Array(len_7668);
    for (var i = 0; i < len_7668; ++i) result[i] = NimCopy(value_7669, typ_7670);
    return result;
  }
function add_5433(x_5436, x_5436_Idx, y_5437) {
var F={procname:"system.add",prev:framePtr,filename:"lib/system.nim",line:0};
framePtr = F;
      var len = x_5436[0].length-1;
      for (var i = 0; i < y_5437.length; ++i) {
        x_5436[0][len] = y_5437.charCodeAt(i);
        ++len;
      }
      x_5436[0][len] = 0
    framePtr = framePtr.prev;
}
function auxwritestacktrace_6447(f_6449) {
var result_6450 = [null];
var it_6455 = f_6449;
var i_6456 = 0;
var total_6457 = 0;
var tempframes_6461 = ArrayConstr(64, {Field0: null, Field1: 0}, NTI6452);
L1: while (true) {
if (!(!((it_6455 == null)) && (i_6456 <= 63))) break L1;
tempframes_6461[i_6456].Field0 = it_6455.procname;
tempframes_6461[i_6456].Field1 = it_6455.line;
i_6456 += 1;
total_6457 += 1;
it_6455 = it_6455.prev;
}
L2: while (true) {
if (!!((it_6455 == null))) break L2;
total_6457 += 1;
it_6455 = it_6455.prev;
}
result_6450[0] = cstrToNimstr("");
if (!((total_6457 == i_6456))) {
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr("("));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(((total_6457 - i_6456))+""));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(" calls omitted) ...\x0A"));
}

var j_6535 = 0;
var X3Atmp_6539 = 0;
X3Atmp_6539 = (i_6456 - 1);
var res_6541 = X3Atmp_6539;
L3: while (true) {
if (!(0 <= res_6541)) break L3;
j_6535 = res_6541;
add_5433(result_6450, 0, tempframes_6461[j_6535].Field0);
if ((0 < tempframes_6461[j_6535].Field1)) {
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr(", line: "));
result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr((tempframes_6461[j_6535].Field1)+""));
}

result_6450[0] = (result_6450[0].slice(0,-1)).concat(cstrToNimstr("\x0A"));
res_6541 -= 1;
}
return result_6450[0];
}
function rawwritestacktrace_6542() {
var result_6544 = null;
if ((framePtr == null)) {
result_6544 = cstrToNimstr("No stack traceback available\x0A");
}
else {
result_6544 = (cstrToNimstr("Traceback (most recent call last)\x0A").slice(0,-1)).concat(auxwritestacktrace_6447(framePtr));
framePtr = null;
}

return result_6544;
}
function eqStrings(a_6790, b_6791) {
    if (a_6790 == b_6791) return true;
    if ((!a_6790) || (!b_6791)) return false;
    var alen = a_6790.length;
    if (alen != b_6791.length) return false;
    for (var i = 0; i < alen; ++i)
      if (a_6790[i] != b_6791[i]) return false;
    return true;
  }
function toJSStr(s_6738) {
    var len = s_6738.length-1;
    var result = new Array(len);
    var fcc = String.fromCharCode;
    for (var i = 0; i < len; ++i) {
      result[i] = fcc(s_6738[i]);
    }
    return result.join("");
  }
function raiseException(e_6560, ename_6561) {
var Tmp1;
e_6560.name = ename_6561;
if (!((excHandler == null))) {
excHandler.exc = e_6560;
}
else {
var buf_6601 = [rawwritestacktrace_6542()];
if (!!(eqStrings(e_6560.message, null))) Tmp1 = false; else {Tmp1 = !((e_6560.message[0] == 0)); }if (Tmp1) {
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception: "));
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(e_6560.message);
}
else {
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception"));
}

buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr(" ["));
add_5433(buf_6601, 0, ename_6561);
buf_6601[0] = (buf_6601[0].slice(0,-1)).concat(cstrToNimstr("]\x0A"));
alert(toJSStr(buf_6601[0]));
}

throw e_6560;}
function raiseOverflow() {
var e_6638 = null;
e_6638 = {m_type: NTI844, parent: null, name: null, message: null, trace: null};
e_6638.message = cstrToNimstr("over- or underflow");
raiseException(e_6638, "EOverflow");
}
function raiseDivByZero() {
var e_6657 = null;
e_6657 = {m_type: NTI842, parent: null, name: null, message: null, trace: null};
e_6657.message = cstrToNimstr("divison by zero");
raiseException(e_6657, "EDivByZero");
}
function rawEcho() {
var node_7038 = document.getElementsByTagName("body")[0];
if ((node_7038 == null)) {
var e_7053 = null;
e_7053 = {m_type: NTI832, parent: null, name: null, message: null, trace: null};
e_7053.message = cstrToNimstr("<body> element does not exist yet!");
raiseException(e_7053, "EIO");
}

      for (var i = 0; i < arguments.length; ++i) {
        var x = toJSStr(arguments[i]);
        node_7038.appendChild(document.createTextNode(x))
      }
    node_7038.appendChild(document.createElement("br"));
}
rawEcho(cstrToNimstr("Hello World!"));
Title: Re: BAS2NIM
Post by: kryton9 on October 11, 2013, 10:58:35 PM
Your interesting post just gave me an idea too John.

We don't even need to go through Nimrod. We can cut it out totally.
Why not write a translator that outputs to a format Bacon
or PowerbasicToCpp or any other translator you might know of that we can use?

This way all work will be in BASIC and probably easier to do?
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 12:44:53 AM
BAD IDEA !!!

The reason for BAS2NIM is that once your code (where ever it comes from) is in Nimrod format, you can develop and compile on ALL the major platforms with one copy of the source. BaCon is Linux only. (Windows if you want a kludge)  Trust me and lets forge ahead as planned.

Title: Re: BAS2NIM
Post by: John on October 12, 2013, 01:00:53 AM
Why I like github.

Code: [Select]
scriptbasic@nimrod:~/639761/Nimrod (master) $ git pull
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 22 (delta 18), reused 19 (delta 15)
Unpacking objects: 100% (22/22), done.
From git://github.com/Araq/Nimrod
   67dedcd..173ca8d  master     -> origin/master
Updating 67dedcd..173ca8d
Fast-forward
 compiler/jsgen.nim     |  2 +-
 compiler/vm.nim        | 29 ++++++++++++-----------------
 compiler/vmdef.nim     |  3 +++
 doc/c2nim.txt          |  8 +-------
 lib/pure/ftpclient.nim |  3 ++-
 lib/pure/sockets.nim   |  4 ++--
 lib/system.nim         |  9 +++++++--
 7 files changed, 28 insertions(+), 30 deletions(-)
scriptbasic@nimrod:~/639761/Nimrod (master) $

Rebuild of Nimrod

Code: [Select]
scriptbasic@nimrod:~/639761/Nimrod (master) $ bin/nimrod c koch
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/koch.nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: koch [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: parseopt [Processing]
Hint: osproc [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: streams [Processing]
koch.nim(170, 11) Hint: 'dir' is declared but not used [XDeclaredButNotUsed]
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_koch.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_koch.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_system.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_system.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_os.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_os.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strutils.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strutils.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseutils.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseutils.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_times.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_times.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/posix_posix.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/posix_posix.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseopt.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseopt.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_osproc.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_osproc.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strtabs.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strtabs.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_hashes.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_hashes.c
gcc -c -w -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_streams.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_streams.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/koch  /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_streams.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_hashes.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strtabs.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_osproc.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseopt.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/posix_posix.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_times.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_parseutils.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_strutils.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/pure_os.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_system.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/nimcache/Nimrod_koch.o  -ldl
Hint: operation successful (16681 lines compiled; 4.749 sec total; 27.281MB) [SuccessX]
scriptbasic@nimrod:~/639761/Nimrod (master) $ ./koch boot -d:release
iteration: 1
compiler/nimrod0 cc  -d:release compiler/nimrod.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/compiler/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: nimrod [Processing]
Hint: commands [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: msgs [Processing]
Hint: options [Processing]
Hint: lists [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: ropes [Processing]
Hint: platform [Processing]
Hint: crc [Processing]
Hint: sockets [Processing]
Hint: nversion [Processing]
Hint: condsyms [Processing]
Hint: idents [Processing]
Hint: extccomp [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: wordrecg [Processing]
Hint: babelcmd [Processing]
Hint: lexer [Processing]
Hint: nimlexbase [Processing]
Hint: llstream [Processing]
Hint: nimconf [Processing]
Hint: main [Processing]
Hint: ast [Processing]
Hint: intsets [Processing]
Hint: idgen [Processing]
Hint: astalgo [Processing]
Hint: rodutils [Processing]
Hint: syntaxes [Processing]
Hint: parser [Processing]
Hint: pbraces [Processing]
Hint: filters [Processing]
Hint: renderer [Processing]
Hint: filter_tmpl [Processing]
Hint: rodread [Processing]
Hint: types [Processing]
Hint: trees [Processing]
Hint: memfiles [Processing]
Hint: rodwrite [Processing]
Hint: passes [Processing]
Hint: magicsys [Processing]
Hint: nimsets [Processing]
Hint: bitsets [Processing]
Hint: semthreads [Processing]
Hint: importer [Processing]
Hint: lookups [Processing]
Hint: semdata [Processing]
Hint: treetab [Processing]
Hint: evals [Processing]
Hint: semfold [Processing]
Hint: saturate [Processing]
Hint: transf [Processing]
Hint: cgmeth [Processing]
Hint: sempass2 [Processing]
Hint: guards [Processing]
Hint: lambdalifting [Processing]
Hint: evaltempl [Processing]
Hint: sem [Processing]
Hint: procfind [Processing]
Hint: pragmas [Processing]
Hint: semtypinst [Processing]
Hint: sigmatch [Processing]
Hint: parampatterns [Processing]
Hint: docgen [Processing]
Hint: rstast [Processing]
Hint: rst [Processing]
Hint: rstgen [Processing]
Hint: highlite [Processing]
Hint: algorithm [Processing]
Hint: sequtils [Processing]
Hint: aliases [Processing]
Hint: patterns [Processing]
Hint: cgen [Processing]
Hint: ccgutils [Processing]
Hint: cgendata [Processing]
Hint: ccgmerge [Processing]
Hint: jsgen [Processing]
Hint: json [Processing]
Hint: lexbase [Processing]
Hint: unicode [Processing]
Hint: passaux [Processing]
Hint: depends [Processing]
Hint: docgen2 [Processing]
Hint: service [Processing]
Hint: parseopt [Processing]
Hint: modules [Processing]
Hint: pretty [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/Nimrod_system.o compiler/nimcache/Nimrod_system.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/compiler_commands.o compiler/nimcache/compiler_commands.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/pure_sockets.o compiler/nimcache/pure_sockets.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/pure_osproc.o compiler/nimcache/pure_osproc.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/pure_memfiles.o compiler/nimcache/pure_memfiles.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o compiler/nimcache/compiler_jsgen.o compiler/nimcache/compiler_jsgen.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/compiler/nimrod  compiler/nimcache/compiler_pretty.o compiler/nimcache/compiler_modules.o compiler/nimcache/pure_parseopt.o compiler/nimcache/compiler_service.o compiler/nimcache/compiler_docgen2.o compiler/nimcache/compiler_depends.o compiler/nimcache/compiler_passaux.o compiler/nimcache/pure_unicode.o compiler/nimcache/pure_lexbase.o compiler/nimcache/pure_json.o compiler/nimcache/compiler_jsgen.o compiler/nimcache/compiler_ccgmerge.o compiler/nimcache/compiler_cgendata.o compiler/nimcache/compiler_ccgutils.o compiler/nimcache/compiler_cgen.o compiler/nimcache/compiler_patterns.o compiler/nimcache/compiler_aliases.o compiler/nimcache/collections_sequtils.o compiler/nimcache/pure_algorithm.o compiler/nimcache/docutils_highlite.o compiler/nimcache/docutils_rstgen.o compiler/nimcache/docutils_rst.o compiler/nimcache/docutils_rstast.o compiler/nimcache/compiler_docgen.o compiler/nimcache/compiler_parampatterns.o compiler/nimcache/compiler_sigmatch.o compiler/nimcache/compiler_semtypinst.o compiler/nimcache/compiler_pragmas.o compiler/nimcache/compiler_procfind.o compiler/nimcache/compiler_sem.o compiler/nimcache/compiler_evaltempl.o compiler/nimcache/compiler_lambdalifting.o compiler/nimcache/compiler_guards.o compiler/nimcache/compiler_sempass2.o compiler/nimcache/compiler_cgmeth.o compiler/nimcache/compiler_transf.o compiler/nimcache/compiler_saturate.o compiler/nimcache/compiler_semfold.o compiler/nimcache/compiler_evals.o compiler/nimcache/compiler_treetab.o compiler/nimcache/compiler_semdata.o compiler/nimcache/compiler_lookups.o compiler/nimcache/compiler_importer.o compiler/nimcache/compiler_semthreads.o compiler/nimcache/compiler_bitsets.o compiler/nimcache/compiler_nimsets.o compiler/nimcache/compiler_magicsys.o compiler/nimcache/compiler_passes.o compiler/nimcache/compiler_rodwrite.o compiler/nimcache/pure_memfiles.o compiler/nimcache/compiler_trees.o compiler/nimcache/compiler_types.o compiler/nimcache/compiler_rodread.o compiler/nimcache/compiler_filter_tmpl.o compiler/nimcache/compiler_renderer.o compiler/nimcache/compiler_filters.o compiler/nimcache/compiler_pbraces.o compiler/nimcache/compiler_parser.o compiler/nimcache/compiler_syntaxes.o compiler/nimcache/compiler_rodutils.o compiler/nimcache/compiler_astalgo.o compiler/nimcache/compiler_idgen.o compiler/nimcache/collections_intsets.o compiler/nimcache/compiler_ast.o compiler/nimcache/compiler_main.o compiler/nimcache/compiler_nimconf.o compiler/nimcache/compiler_llstream.o compiler/nimcache/compiler_nimlexbase.o compiler/nimcache/compiler_lexer.o compiler/nimcache/compiler_babelcmd.o compiler/nimcache/compiler_wordrecg.o compiler/nimcache/pure_streams.o compiler/nimcache/pure_osproc.o compiler/nimcache/compiler_extccomp.o compiler/nimcache/compiler_idents.o compiler/nimcache/compiler_condsyms.o compiler/nimcache/compiler_nversion.o compiler/nimcache/pure_sockets.o compiler/nimcache/compiler_crc.o compiler/nimcache/compiler_platform.o compiler/nimcache/compiler_ropes.o compiler/nimcache/pure_math.o compiler/nimcache/collections_tables.o compiler/nimcache/pure_hashes.o compiler/nimcache/pure_strtabs.o compiler/nimcache/compiler_lists.o compiler/nimcache/compiler_options.o compiler/nimcache/compiler_msgs.o compiler/nimcache/posix_posix.o compiler/nimcache/pure_times.o compiler/nimcache/pure_parseutils.o compiler/nimcache/pure_strutils.o compiler/nimcache/pure_os.o compiler/nimcache/compiler_commands.o compiler/nimcache/Nimrod_system.o compiler/nimcache/compiler_nimrod.o  -ldl -lm
Hint: operation successful (67238 lines compiled; 17.628 sec total; 202.207MB) [SuccessX]
iteration: 2
compiler/nimrod1 cc  -d:release compiler/nimrod.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/compiler/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: nimrod [Processing]
Hint: commands [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: msgs [Processing]
Hint: options [Processing]
Hint: lists [Processing]
Hint: strtabs [Processing]
Hint: hashes [Processing]
Hint: tables [Processing]
Hint: math [Processing]
Hint: ropes [Processing]
Hint: platform [Processing]
Hint: crc [Processing]
Hint: sockets [Processing]
Hint: nversion [Processing]
Hint: condsyms [Processing]
Hint: idents [Processing]
Hint: extccomp [Processing]
Hint: osproc [Processing]
Hint: streams [Processing]
Hint: wordrecg [Processing]
Hint: babelcmd [Processing]
Hint: lexer [Processing]
Hint: nimlexbase [Processing]
Hint: llstream [Processing]
Hint: nimconf [Processing]
Hint: main [Processing]
Hint: ast [Processing]
Hint: intsets [Processing]
Hint: idgen [Processing]
Hint: astalgo [Processing]
Hint: rodutils [Processing]
Hint: syntaxes [Processing]
Hint: parser [Processing]
Hint: pbraces [Processing]
Hint: filters [Processing]
Hint: renderer [Processing]
Hint: filter_tmpl [Processing]
Hint: rodread [Processing]
Hint: types [Processing]
Hint: trees [Processing]
Hint: memfiles [Processing]
Hint: rodwrite [Processing]
Hint: passes [Processing]
Hint: magicsys [Processing]
Hint: nimsets [Processing]
Hint: bitsets [Processing]
Hint: semthreads [Processing]
Hint: importer [Processing]
Hint: lookups [Processing]
Hint: semdata [Processing]
Hint: treetab [Processing]
Hint: evals [Processing]
Hint: semfold [Processing]
Hint: saturate [Processing]
Hint: transf [Processing]
Hint: cgmeth [Processing]
Hint: sempass2 [Processing]
Hint: guards [Processing]
Hint: lambdalifting [Processing]
Hint: evaltempl [Processing]
Hint: sem [Processing]
Hint: procfind [Processing]
Hint: pragmas [Processing]
Hint: semtypinst [Processing]
Hint: sigmatch [Processing]
Hint: parampatterns [Processing]
Hint: docgen [Processing]
Hint: rstast [Processing]
Hint: rst [Processing]
Hint: rstgen [Processing]
Hint: highlite [Processing]
Hint: algorithm [Processing]
Hint: sequtils [Processing]
Hint: aliases [Processing]
Hint: patterns [Processing]
Hint: cgen [Processing]
Hint: ccgutils [Processing]
Hint: cgendata [Processing]
Hint: ccgmerge [Processing]
Hint: jsgen [Processing]
Hint: json [Processing]
Hint: lexbase [Processing]
Hint: unicode [Processing]
Hint: passaux [Processing]
Hint: depends [Processing]
Hint: docgen2 [Processing]
Hint: service [Processing]
Hint: parseopt [Processing]
Hint: modules [Processing]
Hint: pretty [Processing]
Hint: operation successful (67238 lines compiled; 6.592 sec total; 202.207MB) [SuccessX]
executables are equal: SUCCESS!
scriptbasic@nimrod:~/639761/Nimrod (master) $ nimrod -v
Nimrod Compiler Version 0.9.3 (2013-10-12) [Linux: amd64]
Copyright (c) 2004-2013 by Andreas Rumpf

scriptbasic@nimrod:~/639761/Nimrod (master) $
Title: Re: BAS2NIM
Post by: kryton9 on October 12, 2013, 02:55:14 AM
BAD IDEA !!!

The reason for BAS2NIM is that once your code (where ever it comes from) is in Nimrod format, you can develop and compile on ALL the major platforms with one copy of the source. BaCon is Linux only. (Windows if you want a kludge)  Trust me and lets forge ahead as planned.

I haven't played with any of the translators, so I will take your word and continue on as we planned then.
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 11:05:02 AM
Sorry about the BAD IDEA comment. No idea is a bad idea unless it kills you.  ;D

BAS2NIM is a different kind of translator that doesn't focus on it's input as much as its output. In other words, BAS2NIM is a utility not a language.
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 11:37:02 AM
Here is the set of BASIC directives and functions that I would like to see converted to Nimrod as the first pass. I can then start working on the SB converter getting its general functionality in place and prepare for the next round.

Code: [Select]
DIM
FOR/NEXT
IF/THEN/ELSE
WHILE/WEND
<LET> Assignment
GOTO
GOSUB/RETURN


ASC
VAL
STR
MID
LEFT
UCASE
LCASE
UBOUND
LBOUND

Dream Team

AIR - Project repositories (git master) and Nimrod / C mentor.

Charles - How it works mentor and advisor so we don't paint ourself into a corner.

Daniel - uCalc Transform mentor / contributor

Josť Roca - Windows API / COM specialist

John - Project facilitator and GOTO guy.

Kent - BASIC to Nimrod syntax translation mapper, agreed upon concept tester and keeper/creator of the docs.

Others - Work with the above team as advocates testing the BAS2NIM utility for proper / efficient translation to Nimrod.


Title: Re: BAS2NIM
Post by: John on October 12, 2013, 12:29:58 PM
I'm thinking that this might be a lot easier if we were to use Danial's uCalc Transform (http://www.ucalc.com/transform.html) software instead of ScriptBasic to do the translation. I will contact Daniel and let him know what we are up to and see if he could mentor / contribute to the project. I have forked Daniel's PowerBASIC to C++ project on Github to the ScriptBasic / BAS2NIM (https://github.com/ScriptBasic/BAS2NIM) project. I will add this repository to the Cloud9 IDE git interface.

Since uCalc Transform is Windows only and a language translation template tool, the goal would be to use Daniel's tool to get the project far enough along that a cross platform Ninrod based BAS2NIM could be self compiled.

uCalc Patterns Documentation (http://www.ucalc.com/docs/Patterns.htm)

Note: I was unable to run uCalc Transform in Wine. (complained about VB missing dependencies) I'm running it in a VirtualBox on Ubuntu 64.
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 03:41:53 PM
I have attached the forked uCalc Transform project BAS2NIM to the project Cloud9 IDE. Changes will now be reflected in the github repository. Nimrod is currently up to date as of yesterdays rebuild.

Title: Re: BAS2NIM
Post by: kryton9 on October 12, 2013, 04:03:07 PM
Thanks for the initial command list to focus on John.
I will work on it some more tonight following that as a guide.

You have assembled a great set of tools for us
on a very cool web based collaboration system.

Everyone should try it, because it surprises you
on how well it works and how handy it is.

I think this is a great project to really test
the new frontier in programming and working
together.

Thanks for figuring it all out and setting it up!
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 04:06:33 PM
That's what facilitators do.   :)
Title: Re: BAS2NIM
Post by: John on October 12, 2013, 05:47:57 PM
Daniel,

Once a uCalc Transform script has been created, it there a console mode facility to process the conversions? (batch mode)

OT Have you had much luck with the PowerBASIC folks converting to C++ with your tool?

John

Update

Code: [Select]
uCalc Transform 1.8 Command Prompt
Type T /? for help with uCalc Transform 1.8 Command Prompt options.

F:\uCalcTransform>T /?
Runs uCalc Transform in batch mode (see examples at bottom)

T  [/A] [/B] [/P] [/Q] [/S] [/CR | /LF | /CRLF] [/ENCODING:{name|codepage}]
   transformfile inputfile [outputfile] [/SEND:data] [#comment]

/A     Appends to output file instead of overwriting it.
/B     Backs up output file before overwriting it (if it already exists).
/P     Previews changes instead of saving them into a file.
/Q     Quiet mode; does not ask if you want to overwrite existing output file.
/S     Saves stats to a file (whose name can be configured in Setup.cnf).

/CR    Saves with carriage return (\r, ASCII 13, hex D) as end-of-line marker.
/LF    Saves with line feed (\n, ASCII 10, hex A) as end-of-line marker.
/CRLF  Saves with CRLF (\r\n, ASCII 10:13 or hex A:D) as end-of-line marker.

/ENCODING:{name|codepage}
       Saves using encoding based on given name (string) or code page (number).

/SEND  This sends data to the SEND variable, which can be used by the
       current transform.  This is useful when you want to use the same
       transform but with slight variations for different files.

transformfile   Name of file(s) containing transform patterns.  To select the
                transform patterns currently being edited in a separate GUI
                session of uCalc Transform, use @ in place of a file name.
inputfile       Name of file(s) containing text to be modified.
outputfile      Name of file in which modified text will be saved.  If this
                file is omitted, modifications are saved in inputfile.  If a
                directory is given instead of a file, the output goes to a
                file in that directory.
#               Everything after # at the end is ignored.

Preferred settings can be configured in Setup.cnf.  Parameters explicitly
invoked at the command line supersede those configured in Setup.cnf.
Parameters can be placed anywhere before, between, or after file names.

To select multiple files for transformfile & inputfile, you may use wildcards.
When using wildcards for transformfile, it's useful (though it's not required)
to choose a given file name for the OutputFile property within each transform.

If ENCODING is omitted, the output file is saved with UTF-8 encoding without a
byte order mark (BOM).  A BOM is always inserted when an encoding is specified.

If inputfile & outputfile are omitted, then uCalc simply opens the file(s) for
editing.  To open multiple files in the current directory, use wildcards.


Examples
--------

T Change.uc  In.Txt  Out.Txt    # Modifies In.Txt & saves changes to Out.Txt
T Beautify.uc  Program.Bas      # Changes saved directly in Program.Bas
T Modify.uc  *.c                # All files ending with .c are modified
T Modify.uc  *.c  \Temp         # Saves modified *.c files in Temp directory
T Log.uc  *.xml  Log.Txt  /A    # Changes to *.xml are appended to Log.Txt
T Web.uc  index.html /LF        # Saves file using LF (\n) instead of CRLF
T @  \temp\*.vb                 # *.vb modified based on current transform
T @  *.xml  /P                  # Preview of changes shown; no files modified
T @  Item.xml  /ENCODING:utf-8  # Saves with utf-8 encoding (including BOM)
T @  C:\ABC.Txt  /ENCODING:1252 # Saves using Windows-1252 encoding
T *.uc  test.c                  # Multiple changes to test.c (if OutputFile="")
T *.uc  Interface.Bas           # Saves to different files if OutputFile set
T *.uc Source.vb profile.txt /A # Transforms are appended to profile.txt
T ReadMe.Txt                    # Simply opens up ReadMe.Txt for editing
T *.Txt                         # Open all .Txt files for editing
T Change.uc File.cpp /SEND:x64  # Variable SEND set to x64 in Change.uc
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 12:25:18 AM
Kent and I were chatting on C9IDE about what BASIC we should use to test with. I suggested ScriptBasic since it was already running on the project site. The more I thought about it, PowerBASIC Console Compiler 5 would be a much better target to work with.


Who knows, this direction might even get Eros to contribute to the project. (and join the forum)
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 12:45:31 PM
I detect that Kent is finding ScriptBasic easy to work with and using it to test with on the C9IDE project site. The concerns I have with using Daniel's uCalc Transform tool is that we have no access to it's source if anything were to happen to him. The PB user base is still spinning over Bob's passing and the product left in a limbo state. Using the GUI interface of uCalc Transform is easy to use but labor intensive creating pattern matching templates. I would like to hear from others interested in this project what their thoughts are about using uCalc Tranform and PBCC 5 as first target language to port to Nimrod.

ScriptBasic actually has a nice pattern matching feature built into the language. (LIKE & JOKER) This example shows how this feature could be use to parse BASIC syntax to translate to Nimrod.

ScriptBasic Pattern Matching (http://www.scriptbasic.org/docs/ug/ug_20.html)

Code: [Select]
code = "FOR x = 1 TO 10 STEP 2"

IF code LIKE "FOR * = # TO # STEP #" THEN
  PRINT "Iterator: ",JOKER(1),"\n"
  PRINT "Start: ",JOKER(2),"\n"
  PRINT "End: ",JOKER(3),"\n"
  PRINT "Step: ",JOKER(4),"\n"
END IF

jrs@laptop:~/bas2nim$ scriba pm_01.sb
Iterator: x
Start: 1
End: 10
Step: 2
jrs@laptop:~/bas2nim$

Code: [Select]
code = "FOR x = 1 TO 10"

IF code LIKE "FOR * = # TO #" THEN
  PRINT "Iterator: ",JOKER(1),"\n"
  PRINT "Start: ",JOKER(2),"\n"
  PRINT "End: ",JOKER(3),"\n"
  PRINT "Step: ",JOKER(4),"\n"
END IF

jrs@laptop:~/bas2nim$ scriba pm_02.sb
Iterator: x
Start: 1
End: 10
Step: undef
jrs@laptop:~/bas2nim$

Code: [Select]
begin = 1
done = 10
code = "FOR x = begin TO done"

PRINT "BASIC: ",code,"\n"

IF code LIKE "FOR * = * TO *" THEN
  PRINT "Iterator: ",JOKER(1),"\n"
  PRINT "Start: ",JOKER(2),"\n"
  PRINT "End: ",JOKER(3),"\n"
END IF

jrs@laptop:~/bas2nim$ scriba pm_03.sb
BASIC: FOR x = begin TO done
Iterator: x
Start: begin
End: done
jrs@laptop:~/bas2nim$

Code: [Select]
done = 10
code = "FOR x = 1 TO done"

PRINT "BASIC: ",code,"\n"

IF code LIKE "FOR * = * TO *" THEN
  PRINT "Iterator: ",JOKER(1),"\n"
  PRINT "Start: ",JOKER(2),"\n"
  PRINT "End: ",JOKER(3),"\n"
END IF

IF ISNUMERIC(VAL(JOKER(2))) THEN
  PRINT "The Start value is number ",JOKER(2),"\n"
END IF

jrs@laptop:~/bas2nim$ scriba pm_04.sb
BASIC: FOR x = 1 TO done
Iterator: x
Start: 1
End: done
The Start value is number 1
jrs@laptop:~/bas2nim$
Title: Re: BAS2NIM
Post by: kryton9 on October 13, 2013, 06:23:00 PM
John, I can't visualize this project in my mind yet as well as you do. So I am just following and can't really offer opinions-- as the last few years I was really focusing on oxygen, but mainly c++.
This is without any real knowledge-- just a hunch on my part, but there are so many BASICs out there, to write a translator for all of them seems like a huge undertaking.

To show how bad the state of BASIC is these days with new programmers. Look at the languages supported by the Cloud9 IDE syntax highlighter... out of 95 languages, not one BASIC.
Closest thing was VBScript. See attached screenshot.

I do believe 100% with you that a new BASIC is needed. It should be able to run on any platform that C can be compiled to. I also believe like you that having all of the brilliant minds of all of these BASIC creators all working on their own and not together is hurting the BASIC world. We need to bring everyone together to work on a killer BASIC to compete with Python and C/C++

The new basic should have 3 abilities. These are to attract Python and C/C++ users and other similar language users.
1. Interactive mode in a command line
2. Interpreted
3. Compiled to true executables with no runtime dependencies.

4. Then an IDE to take the game to a whole new level.
    Charles and I had talked about a cool IDE a couple of years back.
    No need to get into that now. But we had some great ideas that
   were very different than other IDES.

5. The langauge should be like oxygen in that you could do procedural, object oriented or a mix of the two and not force one paradigm on users.

You are right, ScirptBasic I am seeing is very flexible and fun to use. I did see that when we dabbled with it in Android when I had my tablet. But I had forgotten.

We are lucky to have you as a facilitator. With your energy and passion for wanting BASIC to be relevant well into the future, there might actually be a chance for some
positive change!

Forgot to comment on ScriptBasic for translation. Your sample code looked very nice to me. A lot easier to use than to do it in Nimrod I would think or the other tools.
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 06:46:24 PM
If ScriptBasic is chosen as the language we are going to use for the BASIC to Nimrod translator, this is how I would approach the challenge.

I like the idea of being able to use multiple dialects of BASIC at the same time along with embedding C and ASM in-line. With this in mind, I would use a SB MODULE (class) for each BASIC language dialect which would contain specifics to that language and are not processed by common syntax routines handled in the MAIN module. (what SB runs by default) I would create a keyword matrix using a combination of associative and indexed based arrays.

Example:
Code: [Select]
pbcc5{"CLS"}[0] = ADDRESS(PB_CLS())
pbcc5{"CLS"}[*] = Rules, flags and whatever else is needed

As each line(s - if multiple continuations) of the BASIC program is read in, the MAIN program will determine if the line is an assignment or directive. I would find the fist space starting from the beginning of the line and see if it's a keyword.

Code: [Select]
IF pbcc5{kwtest} = undef THEN ...must be an assignment, meta statement or other non-directive ...

Each keyword function is responsible for building its Nimrod code using expected calling arguments and global settings that might indicate state that would affect the generated Nimrod code.

I would be happy to collaborate with Kent and others to get our fist pass done in SB. (closing arguments)


Title: Re: BAS2NIM
Post by: John on October 13, 2013, 07:24:04 PM
Quote
Forgot to comment on ScriptBasic for translation. Your sample code looked very nice to me. A lot easier to use than to do it in Nimrod I would think or the other tools.

Sounds like SB deserves your vote in our poll.  ;)

Title: Re: BAS2NIM
Post by: kryton9 on October 13, 2013, 07:34:17 PM
Got my vote.
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 09:16:21 PM
Quote from: Kent
Got my vote.

Thanks! The SB team appreciates it.

I have posted on the ScriptBasic project site (Download - Sticky) a fixed scriba for accessing JOKER(n)'s beyond the number of match characters defined. (caused seg. fault / GPF) Please replace your SB 2.2 build 1 with this build 2 release. (Ubuntu 32 version posted soon)

The scriba JOKER fix download. (http://www.scriptbasic.org/forum/index.php/topic,291.msg1163.html#msg1163)
Title: Re: BAS2NIM
Post by: kryton9 on October 13, 2013, 09:41:52 PM
I am doing all my Nimrod and ScriptBasic coding on your Cloud9 Nimrod site John. It makes it very nice and easy.
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 09:50:22 PM
Quote
I am doing all my Nimrod and ScriptBasic coding on your Cloud9 Nimrod site

Cloud9 is a collaborative development service. I would think that makes it our development site.  :)
Title: Re: BAS2NIM
Post by: kryton9 on October 13, 2013, 10:09:22 PM
You figured out how to set it all up, so as far as I am concerned it is your site just as the forums you run. You deserve credit where credit is due.
Thanks for making them a community.
Title: Re: BAS2NIM
Post by: John on October 13, 2013, 10:15:33 PM
Thanks, but ... (http://www.allbasic.info/forum/index.php?topic=246.msg2778#msg2778)
Title: Re: BAS2NIM
Post by: kryton9 on October 13, 2013, 10:50:33 PM
Clever it worked :)
Title: Re: BAS2NIM
Post by: John on October 14, 2013, 12:18:30 PM
The updated scriba (ScriptBasic 2.2 Build 2) for all release candidate builds have been posted. Please update your copy of scriba.

Download Link (http://www.scriptbasic.org/forum/index.php/topic,291.msg1163.html#msg1163)



Title: Re: BAS2NIM
Post by: John on October 14, 2013, 03:41:21 PM
ScriptBasic does Old School BASIC.

Code: [Select]
10 REM My Program
20 LET A = 1
30 LET B$ = "Hello"
40 GOSUB 100
50 END
100 PRINT B$
110 PRINT
120 RETURN

OR

Code: [Select]
10 REM My Program
   LET A = 1
   LET B$ = "Hello"
   GOSUB 100
   END
100 PRINT B$
    PRINT
    RETURN

OR

Code: [Select]
' My Program
a = 1
b = "Hello"
GOSUB 100
END
100:
PRINT b,"\n"
RETURN

jrs@laptop:~/bas2nim$ scriba oldschool.bas
Hello
jrs@laptop:~/bas2nim$

Title: Re: BAS2NIM
Post by: kryton9 on October 14, 2013, 06:39:52 PM
Hmmmm, I wonder if the labels for goto's need the : afterwards. The line number didn't in your code John.
Will have to try that out.
Title: Re: BAS2NIM
Post by: John on October 14, 2013, 06:49:32 PM
In ScriptBasic line numbers are labels. SB allow a special type of line number label that allows code to follow without the : to emulate old school BASIC. Any other label requires the : label designator.
Title: Re: BAS2NIM
Post by: kryton9 on October 14, 2013, 10:36:20 PM
Thanks for the clarification!
Title: Re: BAS2NIM
Post by: John on October 14, 2013, 11:14:44 PM
I have created this thread specifically as a shared effort to get a functional traditional BASIC to Nimrod translator working using the keyword list below. (the list might change slightly if we missed something to make this micro-BASIC language functional) Think of this as a code challenge if you wish. Each member here on All BASIC that would like to participate should create a workspace post. Use that post for your project and the already existing BAS2NIM thread for discussions. I'm going to write my attempt in ScriptBasic. If Daniel would like to show off his uCalc Transform tool, this would be a great time for it. If other members have a better way / language to accomplish the task, please show us.


Title: Re: BAS2NIM
Post by: kryton9 on October 15, 2013, 12:56:25 PM
Oh wow John, you are now 2 steps ahead of me. I am going to finish my end today to see the magic your code will do.
Title: Re: BAS2NIM
Post by: John on October 15, 2013, 01:20:11 PM
Quote
Oh wow John, you are now 2 steps ahead of me. I am going to finish my end today to see the magic your code will do.

Sounds great Kent. Looking forward to see it work.

Title: Re: BAS2NIM
Post by: Daniel Corbier on October 15, 2013, 07:04:24 PM
I just released uCalc Transform just moments ago.  Sorry for the delay in response.  I plan to take a look at this thread & other messages and get back with everybody tomorrow.  I'm interested in this project.
Title: Re: BAS2NIM
Post by: kryton9 on October 16, 2013, 01:23:52 PM
I will put all my latest code and files here at the end of the day from the https://c9.io/scriptbasic/nimrod site.

Running and using instructions:
Files with .sb extension from the linux command line scriba filename.sb
Files with .bas extension, these are just for viewing via any editor of various basic tests.
Files with .nim extenstion, these are Nimrod source files. Here is how to compile from
the command line.
nimrod c test.nim                       this compiles, but full of debug info.
./test                                          this runs the executable in linux, if compiled on it.
nimrod c -d:release test.nim      this compiles to a nice small release version.

my stuff is under: projects/Kent

update date: 10/18/2013

There are 3 projects regarding basic to nimrod in my folder.
Each project is in its own sub-folder.

These are starts to give BASIC users and developers a
possible start to working in and with Nimrod.

Folder basic:
    This is just a start of a simple basic module
    to use from within Nimrod.
   
    basic.nim: this is the source code for the
    basic module.
   
    test.nim: this is Nimrod code written in Basic,
    using the basic module.
   
   
Folder sb2nim:
    This is trying to do a side by side comparison
    of Basic and Nimrod. The basic used on the
    right-side is ScriptBasic. The left side
    is one of the ways to do the similar thing
    in Nimrod.
   
    sb2nim.nim: is the Nimrod source with the 2 languages.
   
 Folder test-john-stuff
    This is adding to the code started by John
    in his folder: John and filename: bas2nim.sb
    It is written in ScriptBasic and is acting
    as the start of a translator.
   
    b2nV2.sb: this is my additions to John's code.
   
    test2.bas: a simple basic program example
                     to use for testing.
       
    test2.nim: this is the output from running b2nV2.sb
                     it is the generated translated Nimrod code.
Title: Re: BAS2NIM
Post by: John on October 16, 2013, 03:49:14 PM
It isn't much but it does prove the concept works.

ScriptBasic BAS2NIM translator
Code: [Select]
' BAS2NIM - ScriptBasic
' Last Update: 2013-10-15
' Contributors: John Spikowski & Kent Sarikaya

' BASIC keyword dictionary

keywords{"DIM"}[0]=ADDRESS(Convert_DIM())
keywords{"FOR"}[0]=ADDRESS(Convert_FOR())
keywords{"NEXT"}[0]=ADDRESS(Convert_NEXT())
keywords{"IF"}[0]=ADDRESS(Convert_IF())
keywords{"WHILE"}[0]=ADDRESS(Convert_WHILE())
keywords{"WEND"}[0]=ADDRESS(Convert_WEND())
keywords{"LET"}[0]=ADDRESS(Convert_LET())
' keywords{"GOTO"}[0]=ADDRESS(Convert_GOTO())
' keywords{"GOSUB"}[0]=ADDRESS(Convert_GOSUB())
' keywords{"RETURN"}[0]=ADDRESS(Convert_RETURN())
keywords{"PRINT"}[0]=ADDRESS(Convert_PRINT())
keywords{"END"}[0]=ADDRESS(Convert_END())
keywords{"ASC"}[0]=ADDRESS(Convert_ASC())
keywords{"VAL"}[0]=ADDRESS(Convert_VAL())
keywords{"STR"}[0]=ADDRESS(Convert_STR())
keywords{"MID"}[0]=ADDRESS(Convert_MID())
keywords{"LEFT"}[0]=ADDRESS(Convert_LEFT())
keywords{"LEFT"}[0]=ADDRESS(Convert_INSTR())
keywords{"UCASE"}[0]=ADDRESS(Convert_UCASE())
keywords{"LCASE"}[0]=ADDRESS(Convert_LCASE())
keywords{"UBOUND"}[0]=ADDRESS(Convert_UBOUND())
keywords{"LBOUND"}[0]=ADDRESS(Convert_LBOUND())


' BASIC Directives

SUB Convert_DIM
END SUB

SUB Convert_FOR
  IF BASIC LIKE "FOR * = * TO *" THEN
    expr[1] = JOKER(1)
    expr[2] = JOKER(2)
    expr[3] = JOKER(3)
    ' Translate
    PRINT Nimrod
  ELSE IF BASIC LIKE "FOR * = * TO * STEP *" THEN
    expr[1] = JOKER(1)
    expr[2] = JOKER(2)
    expr[3] = JOKER(3)
    expr[4] = JOKER(4)
    ' Translate
    PRINT Nimrod
  ELSE
    END
  END IF 
END SUB

SUB Convert_NEXT
END SUB

SUB Convert_IF
END SUB

SUB Convert_WHILE
END SUB

SUB Convert_WEND
END SUB

SUB Convert_LET
  IF BASIC LIKE "LET *" THEN
    PRINT "var ", JOKER(1), "\n"
  ELSE
    END
  END IF
END SUB

' SUB Convert_GOTO
' END SUB

' SUB Convert_GOSUB
' END SUB

' SUB Convert_RETURN
' END SUB

SUB Convert_PRINT
  IF BASIC LIKE "PRINT *" THEN
    PRINT "stdout.write(", JOKER(1), ")\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_END
END SUB


' BASIC Functions

SUB Convert_ASC
 
END SUB

SUB Convert_VAL
END SUB

SUB Convert_STR
END SUB

SUB Convert_MID
END SUB

SUB Convert_LEFT
END SUB

SUB Convert_INSTR
END SUB

SUB Convert_UCASE
END SUB

SUB Convert_LCASE
END SUB

SUB Convert_UBOUND
END SUB

SUB Convert_LBOUND
END SUB


' MAIN

filename_argument = COMMAND()
OPEN filename_argument FOR INPUT AS #1
WHILE NOT(EOF(1))
  LINE INPUT #1, BASIC
  BASIC = CHOMP(BASIC)
  sp = INSTR(BASIC, " ")
  test_keyword = LEFT(BASIC, sp -1)
  IF keywords{test_keyword}[0] <> undef THEN
    success = ICALL(keywords{test_keyword}[0])
  ELSE
    END
  END IF
WEND

First BASIC program
Code: [Select]
LET A = "Hello BAS2NIM"
PRINT A,"\n"

jrs@laptop:~/bas2nim$ scriba bas2nim.sb firstpgm.bas
var A = "Hello BAS2NIM"
stdout.write(A,"\n")
jrs@laptop:~/bas2nim$ scriba bas2nim.sb firstpgm.bas > t_nim02.nim
jrs@laptop:~/bas2nim$ nimrod c t_nim02.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: t_nim02 [Processing]
gcc -c -w -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/t_nim02.o /home/jrs/bas2nim/nimcache/t_nim02.c
gcc   -o /home/jrs/bas2nim/t_nim02  /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/t_nim02.o  -ldl
Hint: operation successful (7440 lines compiled; 0.236 sec total; 12.122MB) [SuccessX]
jrs@laptop:~/bas2nim$ ./t_nim02
Hello BAS2NIM
jrs@laptop:~/bas2nim$

Code: [Select]
LET A = "Hello BAS2NIM"
PRINT A

jrs@laptop:~/bas2nim$ scriba bas2nim.sb firstpgm.bas
var A = "Hello BAS2NIM"
stdout.write(A)
jrs@laptop:~/bas2nim$ scriba bas2nim.sb firstpgm.bas > t_nim02.nim
jrs@laptop:~/bas2nim$ nimrod c t_nim02.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: t_nim02 [Processing]
gcc -c -w -I/home/jrs/nimrod/lib -o /home/jrs/bas2nim/nimcache/t_nim02.o /home/jrs/bas2nim/nimcache/t_nim02.c
gcc   -o /home/jrs/bas2nim/t_nim02  /home/jrs/bas2nim/nimcache/system.o /home/jrs/bas2nim/nimcache/t_nim02.o  -ldl
Hint: operation successful (7440 lines compiled; 0.242 sec total; 12.122MB) [SuccessX]
jrs@laptop:~/bas2nim$ ./t_nim02
Hello BAS2NIMjrs@laptop:~/bas2nim$

Title: Re: BAS2NIM
Post by: John on October 16, 2013, 08:55:37 PM
Quote
# undef is not supported in Nimrod yet
# can't figure out how to do this in Nimrod, if possible
# to mix and leave entries in arrays empty as in SB

ScriptBasic is typeless and requires no setup of variables to use them. If you try to access a variable that hasn't been assigned, you will get an undef. ScriptBasic also has an undef function that returns a variable to it's unassigned state. This is a SB thing and you shouldn't waste your time trying to emulate it. We aren't writing a ScriptBasic to C (via Nimrod) translator, SB already compiles to C.

All variables being passed through the translator should be declared. I would still like to use PBCC 5 as the target first BASIC.

Title: Re: BAS2NIM
Post by: Daniel Corbier on October 16, 2013, 08:59:24 PM
Version 2.0 now includes a directory full of PowerBASIC snippets, many of which are actually applicable to any kind of BASIC dialect.  Of particular interest, you may want to look at files like ImplicitDim.uc or PrettyBas.uc to see how it handles keywords.  They basically use the public domain keyword list I downloaded from PB.  This line, in one step, opens the file, and creates a regular expression that handles all the keywords of that file.  Check out those examples in the download to see how they work in context.

Code: [Select]
{@Eval: "{'"+Retain(FileText("PBKeywords.txt"), "{keyword:'[a-z0-9_]+'}", Delim("\b|"))+"\b'}"}
Also note how many of the transforms use the {@Eval: } construct, which lets you dynamically compute things you can add to the text.

BTW, when I click on the c9.io link I just get a blank page.

Title: Re: BAS2NIM
Post by: John on October 16, 2013, 09:07:28 PM
Quote
BTW, when I click on the c9.io link I just get a blank page.

It was setup as a private workspace. Public workspaces are viewable to anyone but need permission for write and terminal access. Just request R/W access and I'll approve you and you will have full rights as we do.

Let me know what Cloud9 IDE user name you're using if it isn't obvious.

Title: Re: BAS2NIM
Post by: John on October 16, 2013, 09:42:30 PM
ImplicitDim.bas
Code: [Select]
Global MyGlobal_A As Long, MyGlobal_B As Dword

Function MyFunction(x, y, z) As Long
   Dim MyString As String, abcd As Long

   Print x, y, z
   Print a, b, c
   Print MyGlobal_A, MyGlobal_B
   Print MyString, abcd
   
   Function = Len(MyString)
End Function

Sub MySub(ByRef Arg_A As Extended, ByVal Arg_B As Long, ByVal Arg_C!)
   Dim MyLocal_A As String, MyLocal_B As Long

   Print Implicit_X, Implicit_Y, Implicit_Z
   Print Arg_A, Arg_B, Arg_C!
   Print MyGlobal_A, MyGlobal_B
   Print MyLocal_A, MyLocal_B
End Function

ImplicitDim.uc
Code: [Select]
# ImplicitDim.uc - uCalc Transformation file
# This file was saved with uCalc Transform 2.0 on 10/15/2013 7:08:31 PM
# Comment: Declares variables (with Dim) that were not explicitely declared before

ExternalKeywords: Exclude, Comment, Selected, ParentChild, FindMode, OutputFile, BatchAction, SEND
ExternalKeywords: Highlight, ForeColor, BackColor, FontName, FontSize, FontStyle
ExternalKeywords: FilterEndText, FilterSeparator, FilterSort, FilterSortFunc, FilterStartText, FilterUnique

FindMode: Replace

# Definitions


# Search Criteria

Criteria: 0
Enabled: True
Exclude: False
Comment: Declares variables (with Dim) that were not explicitely declared before
Selected: False
Highlight: False
ForeColor: ControlText
BackColor: Aqua
FontName:
FontSize:
FontStyle:
CaseSensitive: False
QuoteSensitive: True
CodeBlockSensitive: True
FilterEndText:
FilterSeparator: {#10}
FilterSort: False
FilterSortFunc:
FilterStartText:
FilterUnique: False
Min: 0
Max: -1
MinSoft: 0
MaxSoft: -1
BatchAction: Transform
OutputFile:
SEND:
StartAfter: 0
StopAfter: -1
SkipOver: False
ParentChild: 0
Pass: 0
PassOnce: True
Precedence: 0
RightToLeft: False

Criteria: 1
Find:
Replace: {@Define:: Token: \x27.* ~~ Properties: ucWhitespace}
         {@Eval: Dim Globals As Table, CurrentRoutine As String}

Criteria: 2
Comment: Teporarily adds Dim keyword in front of args for further parsing
Pass: 1

Criteria: 3
Selected: True
Find: {nl}{routine: Sub | Function } {etc}({args})
Replace: {nl}{routine} {etc}(Dim {args})

Criteria: 4
SkipOver: True
Find: {nl}Function =
Replace: [Skip over]

Criteria: 5
Comment: Inserts explicitly Dimmed variable names in global or local tables
Pass: 2

Criteria: 6
Find: Global {variable:1}
Replace: {Self}{@Eval: Insert(Globals, "{variable}")}

Criteria: 7
BackColor: Silver
Find: { {nl}{ Macro | Type | Union | % | $ | Declare {func:1} } | . | @ } {name:1}
Replace: {Self}{@Eval: Insert(Globals, "{name}")}

Criteria: 8
BackColor: Lime
Find: {nl}{ Sub | Function }{" +"}{RoutineName:"[a-z0-9_]+"}
Replace: {Self}{@Define:
            Var: {RoutineName}ExplicitDim As Table
            Var: {RoutineName}ImplicitDim As Table
         }{@Eval: SetVar(CurrentRoutine, "{RoutineName}"); Insert(Globals,"{RoutineName}")}

Criteria: 9
BackColor: Pink
Find: {declare: Dim [[Optional] { ByVal | ByRef }] | Local | Static } {variable:1}
Replace: {Self}{@Eval: Insert(~Eval(CurrentRoutine)ExplicitDim, "{variable}")}

Criteria: 10
Comment: Temporarily inserts declaration for each individual variable a lines with a list of multiple vars, for easier parsing
BackColor: SlateBlue
PassOnce: False
Find: {declare: Global | Dim | Local | Static } {variable},
Replace: {declare} {variable} :: {declare}

Criteria: 11
Comment: Places non-Dimmed variable names in separate local tables
Pass: 3

Criteria: 12
Find: {variable:"[a-z][a-z0-9_]*"}
Replace: {Self}{@Eval:
            IIf(Handle(Globals, "{variable}")==0 And Handle(~Eval(CurrentRoutine)ExplicitDim, "{variable}")==0,
                Insert(~Eval(CurrentRoutine)ImplicitDim, "{variable}"); "")
         }

Criteria: 13
SkipOver: True
Find: {@Eval: "{'"+Retain(FileText("PBKeywords.txt"), "{keyword:'[a-z0-9_]+'}", Delim("\b|"))+"\b'}"}
Replace: [Skip over]

Criteria: 14
BackColor: Brown
Find: {"\n"}{ Sub | Function }{" +"}{RoutineName:"[a-z0-9_]+"}
Replace: {Self}{@Eval: SetVar(CurrentRoutine, "{RoutineName}")}

Criteria: 15
Comment: Inserts local Dim statements for variables that were not dimmed
Pass: 4

Criteria: 16
BackColor: Purple
Find: {nl}{ Sub | Function }{" +"}{RoutineName:"[a-z0-9_]+"} {etc}
Replace: {Self}
            Dim {@Eval: Range(1, Count({RoutineName}ImplicitDim), "ReadKey({RoutineName}ImplicitDim, x)", Delim(", "))} ' Implicit

Criteria: 17
Comment: Clean up (temp declaration statements removed)
Pass: 5

Criteria: 18
BackColor: Violet
Find: :: {declare:1}
Replace: ,

Criteria: 19
BackColor: CornflowerBlue
Find: (Dim {args})
Replace: ({@Eval: Replace("{args}", ":: Dim", ",")})

Criteria: 20
Find: Dim {nl}
Replace: {Nothing}

# End Search

PrettyBas.bas
Code: [Select]
' The source code below is intentionally formatted incorrectly.
' PrettyBas.uc will correct spacing & indentation and will add color.
' There are two ways to test PrettyBas.uc with this file:
' A. Right-click this file from within uCalc and select:
'      Open With Indentation/Color
'      (In this case \PrettyBas.uc from the .\Transforms\ directory is used
       and is part of the setup defined in .\FileTypes\Bas)
' B. To fiddle with the transform interactively click the folder button
     and choose PrettyBas.uc as a transform:
'    (In this case \PrettyBas.uc from the .\Examples\PowerBASIC\ directory is used)

#Compile Exe
#Dim All
   #Include "Win32API.inc" ' Includes the API for Windows

Type MyType ' These will be indented properly
 x As Long
   abc As Long
     xyz As Long
   Something As Long
  Other As Long
  End Type

Function TEST(ByVal num As Long, MyStr As String  ,   xyz As Long) As Dword ' Just a test
   Dim x As Long  ,y As Long, value&, t!

   t! = Timer

  ! FNCLEX  ; some random ASM
! MOV AX  ,   "xy"
! MOV EAX, value&

For X = 1 To 10 ' The indentation will take care of this nested code
For Y =   2 To 20
  If x =  1 Then y=2

  If x= 5 Then
      If Y = X Then Print "Testing 'testing' 123" ' Just testing
      value& = value& + 1      *x   * xyz   -5^ 2
    If MyStr = "Something ""or"" other" Then   value& =Len(MyStr)*2
   End If
Next
 Print Timer-t!
Next

Function = 123+Len(MyStr)+num  /2
End Function

Function PBMain () As Long
   Dim x As Long  ,y As Long, z As String, FileNumber As Long

FileNumber = FreeFile
  Open "c:\test\kjv10.txt" For Binary As #FileNumber

If Lof(#FileNumber) > 1000 Then ' big enough
While Rnd() < .25
For x= 1 To 10
Print Test(x +123   ,"abc xyz",123)
 For y = 1 To 10 : Print  x, y: Next
   While Rnd()*10 < 5 :Print y    : Wend
Next
 Wend
 End If

Data "One","Two", "Three"  ,   "Four", 5 ,6 , 7, 8
End Function

PrettyBas.uc
Code: [Select]
# PrettyBas.uc - uCalc Transformation file
# This file was saved with uCalc Transform 1.9 on 10/13/2013 2:21:39 PM
# Comment: Adds color and indentation to BASIC source code

ExternalKeywords: Exclude, Comment, Selected, ParentChild, FindMode, OutputFile, BatchAction, SEND
ExternalKeywords: Highlight, ForeColor, BackColor, FontName, FontSize, FontStyle
ExternalKeywords: FilterEndText, FilterSeparator, FilterSort, FilterSortFunc, FilterStartText, FilterUnique

FindMode: Replace

# Definitions


# Search Criteria

Criteria: 0
Enabled: True
Exclude: False
Comment: Adds color and indentation to BASIC source code
Selected: False
Highlight: False
ForeColor: ControlText
BackColor: Transparent
FontName:
FontSize:
FontStyle:
CaseSensitive: False
QuoteSensitive: True
CodeBlockSensitive: False
FilterEndText:
FilterSeparator: {#10}
FilterSort: False
FilterSortFunc:
FilterStartText:
FilterUnique: False
Min: 0
Max: -1
MinSoft: 0
MaxSoft: -1
BatchAction: Transform
OutputFile:
SEND:
StartAfter: 0
StopAfter: -1
SkipOver: False
ParentChild: 0
Pass: 0
PassOnce: False
Precedence: 0
RightToLeft: False

Criteria: 1
BackColor: CornflowerBlue
Find: {@Note:                  == Explanation ==
        This section here, enlcosed within {@Note: ...} represents a comment.
         
        Preliminary items are defined on the right in preparation for
        transformation operations below.
     
        {@Define: ...} with one colon defines things in the "Evaluation" space,
        which is kept separate from the space of text being parsed.
     
        {@Define:: ...} (2 colons) defines things in the space of text being
        parsed.  Alphanumeric tokens are redefined to support PB prefixes/suffixes.
      }
Replace: {@Define:
            Var: Indentation = 0
            Const: IndentSize = 3
         
            Inline: {indent+}      := Indentation += IndentSize
            Inline: {indent-}      := Indentation -= IndentSize
            Inline: {indent}       := " " * Indentation
         }
         
         {@Define:: Include: PBTokens.uc}

Criteria: 2
Comment: Adds indentation
Pass: 1

Criteria: 3
Selected: True
Find: {@Start}
Replace: {@Eval: Indentation = 0}

Criteria: 4
Comment: {nl} represents New Line (defined as such in Patterns.uc), and {etc} is just a pattern variable
PassOnce: True
Find: {nl}{etc}
Replace: {nl}{indent}{etc}

Criteria: 5
Comment: Indents tag then increments indentation
PassOnce: True
Find: {nl}{StartWord: Type | Union | For | If | Do | While | Macro | Sub | Function | Select}
Replace: {nl}{indent}{StartWord}{indent+}

Criteria: 6
PassOnce: True
Find: {nl}{MiddleWord: Else | ElseIf | Case}
Replace: {nl}{indent-}{indent}{MiddleWord}{indent+}

Criteria: 7
Comment: Indents end-tag then decrements indentation
PassOnce: True
Find: {nl}{EndWord: End | Next | Loop | Wend }
Replace: {nl}{indent-}{indent}{EndWord}

Criteria: 8
PassOnce: True
Find: {nl}{SameLine: For | Do | While } {etc} :
Replace: {nl}{indent}{SameLine} {etc} :

Criteria: 9
Comment: Doesn't increase indentation for single-line If statement
PassOnce: True
Find: {nl}If {cond} { Then | Goto} {Space:"[ ]+"} {SameLine:"[^'\r\n]"}
Replace: {nl}{indent}If {cond} Then {SameLine}

Criteria: 10
PassOnce: True
Find: {nl}{Other: Function = | Macro {def} = }
Replace: {nl}{indent}{Other}

Criteria: 11
Comment: Adds color
Pass: 2

Criteria: 12
Comment: Adds color to value within quotes
Highlight: True
ForeColor: Brown
PassOnce: True
Find: {QuotedText:"[\q][^\q]*[\q]"}
Replace: {QuotedText}

Criteria: 13
Comment: {@Eval: ...} is replaced with ! | #Bloat | #Compile | #Compiler | #Debug | ...
Highlight: True
ForeColor: Blue
PassOnce: True
Find: {Keyword: {@Eval: Retain(Remove(FileText("PBKeywords.txt"), "{'\x27'}"), "{'.*'}", Delim(" | ")) } }
Replace: {Keyword}

Criteria: 14
Highlight: True
ForeColor: Green
PassOnce: True
Find: {Comment:"'.*"}
Replace: {Comment}

Criteria: 15
Highlight: True
ForeColor: Red
PassOnce: True
Find: ! {ASM}
Replace: ! {ASM}

Criteria: 16
Comment: Normalizes spacing between arithmetic symbols like +, -, *, etc.
ForeColor: Black
PassOnce: True
Find: [{"[ ]+"}] {Symbol:"[\=\:\+\-\*\^\\\/]"} [{"[ ]+"}]
Replace: {sp}{Symbol}{sp}

Criteria: 17
Comment: Normalizes spacing around commas
ForeColor: Black
PassOnce: True
Find: {Comma:" *, *"}
Replace: ,{sp}

# End Search
Title: Re: BAS2NIM
Post by: John on October 16, 2013, 09:54:18 PM
Kent,

I think your library idea as a way to get BASIC programmers using Nimrod is outstanding. Nice Job !

John
Title: Re: BAS2NIM
Post by: kryton9 on October 16, 2013, 10:10:55 PM
Thanks John. I just made a small example for real developers to get an idea of where to start if they wanted to port their BASIC to Nimrod and have all its cross platform options.

When you look in the cross compiler section, wow they can compile to arm and even embedded systems like avr.
http://nimrod-code.org/nimrodc.html#compiler-usage

Off to try your translation code now.
Title: Re: BAS2NIM
Post by: kryton9 on October 16, 2013, 10:27:53 PM
Works great John!
Quote
scriptbasic@nimrod:~/639761/projects/Kent/test-john-stuff $ scriba bas2nim.sb test1.bas
var A = "Hello BAS2NIM"
stdout.write(A,"\n")
scriptbasic@nimrod:~/639761/projects/Kent/test-john-stuff $ nimrod c -d:release test1.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: test1 [Processing]
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/test-john-stuff_test1.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/test-john-stuff_test1.c
gcc -c -w -O3 -fno-strict-aliasing -I/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/lib -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/Nimrod_system.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/Nimrod_system.c
gcc   -o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/test1  /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/Nimrod_system.o /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/projects/Kent/test-john-stuff/nimcache/test-john-stuff_test1.o  -ldl
Hint: operation successful (7680 lines compiled; 16.266 sec total; 9.922MB) [SuccessX]
scriptbasic@nimrod:~/639761/projects/Kent/test-john-stuff $ ./test1
Hello BAS2NIM
scriptbasic@nimrod:~/639761/projects/Kent/test-john-stuff $
Title: Re: BAS2NIM
Post by: John on October 16, 2013, 10:28:09 PM
Quote
The JavaScript target

Nimrod can also generate JavaScript code. However, the JavaScript code generator is experimental!

Nimrod targets JavaScript 1.5 which is supported by any widely used browser. Since JavaScript does not have a portable means to include another module, Nimrod just generates a long .js file.

Features or modules that the JavaScript platform does not support are not available. This includes:

    manual memory management (alloc, etc.)
    casting and other unsafe operations (cast operator, zeroMem, etc.)
    file management
    most modules of the Standard library
    proper 64 bit integer arithmetic
    unsigned integer arithmetic

However, the modules strutils, math, and times are available! To access the DOM, use the dom module that is only available for the JavaScript platform.

To compile a Nimrod module into a .js file use the js command; the default is a .js file that is supposed to be referenced in an .html file. However, you can also run the code with nodejs:

    nimrod js -d:nodejs -r examples/hallo.nim

hellojs.nim
Code: [Select]
echo "I'm a JavaScript Program!"

jrs@laptop:~/nimrod/nodejs$ nimrod js -d:nodejs -r hellojs.nim
config/nimrod.cfg(36, 11) Hint: added path: '/home/jrs/.babel/libs/' [Path]
Hint: used config file '/home/jrs/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: hellojs [Processing]
Hint: operation successful (3511 lines compiled; 0.057 sec total; 3.307MB) [SuccessX]
node nodejs/nimcache/hellojs.js
I'm a JavaScript Program!
jrs@laptop:~/nimrod/nodejs$

hellojs.js
Code: [Select]
/* Generated by the Nimrod Compiler v0.9.2 */
/*   (c) 2013 Andreas Rumpf */


var Globals = this;
var framePtr = null;
var excHandler = null;
var NTI842 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI103 = {size: 0,kind: 31,base: null,node: null,finalizer: null};
var NTI5851 = {size: 0, kind: 18, base: null, node: null, finalizer: null};
var NTI808 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI139 = {size: 0,kind: 28,base: null,node: null,finalizer: null};
var NTI141 = {size: 0,kind: 29,base: null,node: null,finalizer: null};
var NTI893 = {size: 0,kind: 22,base: null,node: null,finalizer: null};
var NTI824 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI828 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI840 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI844 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NNI844 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI844.node = NNI844;
var NNI840 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI840.node = NNI840;
var NNI828 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI828.node = NNI828;
NTI893.base = NTI824;
var NNI824 = {kind: 2, len: 4, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "parent", len: 0, typ: NTI893, name: "parent", sons: null},
{kind: 1, offset: "name", len: 0, typ: NTI141, name: "name", sons: null},
{kind: 1, offset: "message", len: 0, typ: NTI139, name: "msg", sons: null},
{kind: 1, offset: "trace", len: 0, typ: NTI139, name: "trace", sons: null}]};
NTI824.node = NNI824;
var NNI808 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI808.node = NNI808;
NTI824.base = NTI808;
NTI828.base = NTI824;
NTI840.base = NTI828;
NTI844.base = NTI840;
var NNI5851 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "Field0", len: 0, typ: NTI141, name: "Field0", sons: null},
{kind: 1, offset: "Field1", len: 0, typ: NTI103, name: "Field1", sons: null}]};
NTI5851.node = NNI5851;
var NNI842 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []};
NTI842.node = NNI842;
NTI842.base = NTI840;
var nim_program_result = 0;
var globalraisehook_5241 = null;
var localraisehook_5246 = null;
var outofmemhook_5249 = null;
function cstrToNimstr(c_6151) {
    var result = [];
    for (var i = 0; i < c_6151.length; ++i) {
      result[i] = c_6151.charCodeAt(i);
    }
    result[result.length] = 0; // terminating zero
    return result;
  }
function ArrayConstr(len_6863, value_6864, typ_6865) {
    var result = new Array(len_6863);
    for (var i = 0; i < len_6863; ++i) result[i] = NimCopy(value_6864, typ_6865);
    return result;
  }
function add_5263(x_5266, x_5266_Idx, y_5267) {
var F={procname:"system.add",prev:framePtr,filename:"lib/system.nim",line:0};
framePtr = F;
      var len = x_5266[0].length-1;
      for (var i = 0; i < y_5267.length; ++i) {
        x_5266[0][len] = y_5267.charCodeAt(i);
        ++len;
      }
      x_5266[0][len] = 0
    framePtr = framePtr.prev;
}
function auxwritestacktrace_5846(f_5848) {
var result_5849 = [null];
var it_5854 = f_5848;
var i_5855 = 0;
var total_5856 = 0;
var tempframes_5861 = ArrayConstr(64, {Field0: null, Field1: 0}, NTI5851);
L1: while (true) {
if (!(!((it_5854 == null)) && (i_5855 <= 63))) break L1;
tempframes_5861[i_5855].Field0 = it_5854.procname;
tempframes_5861[i_5855].Field1 = it_5854.line;
i_5855 += 1;
total_5856 += 1;
it_5854 = it_5854.prev;
}
L2: while (true) {
if (!!((it_5854 == null))) break L2;
total_5856 += 1;
it_5854 = it_5854.prev;
}
result_5849[0] = cstrToNimstr("");
if (!((total_5856 == i_5855))) {
result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr("("));
result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr(((total_5856 - i_5855))+""));
result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr(" calls omitted) ...\x0A"));
}

var j_5940 = 0;
var X3Atmp_5945 = 0;
X3Atmp_5945 = (i_5855 - 1);
var res_5947 = X3Atmp_5945;
L3: while (true) {
if (!(0 <= res_5947)) break L3;
j_5940 = res_5947;
add_5263(result_5849, 0, tempframes_5861[j_5940].Field0);
if ((0 < tempframes_5861[j_5940].Field1)) {
result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr(", line: "));
result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr((tempframes_5861[j_5940].Field1)+""));
}

result_5849[0] = (result_5849[0].slice(0,-1)).concat(cstrToNimstr("\x0A"));
res_5947 -= 1;
}
return result_5849[0];
}
function rawwritestacktrace_5948() {
var result_5950 = null;
if ((framePtr == null)) {
result_5950 = cstrToNimstr("No stack traceback available\x0A");
}
else {
result_5950 = (cstrToNimstr("Traceback (most recent call last)\x0A").slice(0,-1)).concat(auxwritestacktrace_5846(framePtr));
framePtr = null;
}

return result_5950;
}
function eqStrings(a_6207, b_6208) {
    if (a_6207 == b_6208) return true;
    if ((!a_6207) || (!b_6208)) return false;
    var alen = a_6207.length;
    if (alen != b_6208.length) return false;
    for (var i = 0; i < alen; ++i)
      if (a_6207[i] != b_6208[i]) return false;
    return true;
  }
function toJSStr(s_6155) {
    var len = s_6155.length-1;
    var result = new Array(len);
    var fcc = String.fromCharCode;
    for (var i = 0; i < len; ++i) {
      result[i] = fcc(s_6155[i]);
    }
    return result.join("");
  }
function raiseException(e_5965, ename_5966) {
var Tmp1;
e_5965.name = ename_5966;
if (!((excHandler == null))) {
excHandler.exc = e_5965;
}
else {
var buf_6001 = [rawwritestacktrace_5948()];
if (!!(eqStrings(e_5965.message, null))) Tmp1 = false; else {Tmp1 = !((e_5965.message[0] == 0)); }if (Tmp1) {
buf_6001[0] = (buf_6001[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception: "));
buf_6001[0] = (buf_6001[0].slice(0,-1)).concat(e_5965.message);
}
else {
buf_6001[0] = (buf_6001[0].slice(0,-1)).concat(cstrToNimstr("Error: unhandled exception"));
}

buf_6001[0] = (buf_6001[0].slice(0,-1)).concat(cstrToNimstr(" ["));
add_5263(buf_6001, 0, ename_5966);
buf_6001[0] = (buf_6001[0].slice(0,-1)).concat(cstrToNimstr("]\x0A"));
console.log(toJSStr(buf_6001[0]));
}

throw e_5965;}
function raiseOverflow() {
var e_6040 = null;
e_6040 = {m_type: NTI844, parent: null, name: null, message: null, trace: null};
e_6040.message = cstrToNimstr("over- or underflow");
raiseException(e_6040, "EOverflow");
}
function raiseDivByZero() {
var e_6062 = null;
e_6062 = {m_type: NTI842, parent: null, name: null, message: null, trace: null};
e_6062.message = cstrToNimstr("divison by zero");
raiseException(e_6062, "EDivByZero");
}
function rawEcho() {
      var buf = "";
      for (var i = 0; i < arguments.length; ++i) {
        buf += toJSStr(arguments[i]);
      }
      console.log(buf);
    }
rawEcho(cstrToNimstr("I\'m a JavaScript Program!"));

Made my day!
Title: Re: BAS2NIM
Post by: John on October 16, 2013, 10:31:39 PM
I will be following your work closely to fill in the holes for the SB effort. Feel free to move that along if you like.



Title: Re: BAS2NIM
Post by: John on October 16, 2013, 10:36:09 PM
PowerBASIC Keywords (courtesy of Daniel)

Code: [Select]
!
#Bloat
#Compile
#Compiler
#Debug
#Dim
#Else
#ElseIf
#EndIf
#If
#Include
#Option
#PBForms
#Register
#Resource
#Stack
#Tools
$Bel
$Bloat
$Bs
$Compile
$Cr
$CrLf
$Debug
$Dim
$Dq
$Else
$ElseIf
$EndIf
$Eof
$Esc
$Ff
$If
$Include
$Lf
$Nul
$Option
$Register
$Resource
$Spc
$Stack
$Tab
$Tools
$Vt
%Black
%Blue
%Cyan
%Def
%Err_BadFileMode
%Err_BadFileName
%Err_BadFileNameOrNumber
%Err_BadRecordNumber
%Err_CommError
%Err_DeviceIoError
%Err_DeviceTimeout
%Err_DeviceUnavailable
%Err_DiskFull
%Err_DiskMediaError
%Err_DiskNotReady
%Err_DivisionByZero
%Err_FarHeapCorrupt
%Err_FileAlreadyExists
%Err_FileIsOpen
%Err_FileNotFound
%Err_GlobalMemoryCorrupt
%Err_IllegalFunctionCall
%Err_InputPastEnd
%Err_InternalError
%Err_NoError
%Err_ObjectError
%Err_OutOfMemory
%Err_Overflow
%Err_PathFileAccessError
%Err_PathNotFound
%Err_PermissionDenied
%Err_RenameAcrossDisks
%Err_StringSpaceCorrupt
%Err_SubscriptPointerOutOfRange
%Err_TooManyFiles
%Gray
%Green
%LtGray
%Magenta
%Mix_Blackness
%Mix_CopySrc
%Mix_MaskNotSrc
%Mix_MaskSrc
%Mix_MaskSrcNot
%Mix_MergeNotSrc
%Mix_MergeSrc
%Mix_MergeSrcNot
%Mix_Nop
%Mix_Not
%Mix_NotCopySrc
%Mix_NotMaskSrc
%Mix_NotMergeSrc
%Mix_NotXorSrc
%Mix_Whiteness
%Mix_XorSrc
%Pb_Cc32
%Pb_Dll16
%Pb_Dll32
%Pb_Exe
%Pb_Revision
%Pb_RevLetter
%Pb_Win32
%Red
%VarClass_Asc
%VarClass_Bit
%VarClass_Byt
%VarClass_Cur
%VarClass_Cux
%VarClass_Dbl
%VarClass_Dwd
%VarClass_Ext
%VarClass_Fix
%VarClass_Fld
%VarClass_Guid
%VarClass_IFac
%VarClass_Int
%VarClass_Lng
%VarClass_Qud
%VarClass_SBt
%VarClass_Sng
%VarClass_Str
%VarClass_Type
%VarClass_Vrnt
%VarClass_Wrd
%VT_Array
%VT_Blob
%VT_Blob_Object
%VT_Bool
%VT_BStr
%VT_ByRef
%VT_CArray
%VT_CF
%VT_ClsID
%VT_Cy
%VT_Date
%VT_Dispatch
%VT_Empty
%VT_Error
%VT_FileTime
%VT_HResult
%VT_I1
%VT_I2
%VT_I4
%VT_I8
%VT_Int
%VT_LPStr
%VT_LPWStr
%VT_Null
%VT_Ptr
%VT_R4
%VT_R8
%VT_Record
%VT_SafeArray
%VT_Storage
%VT_Stored_Object
%VT_Stream
%VT_Streamed_Object
%VT_UI1
%VT_UI2
%VT_UI4
%VT_UI8
%VT_UInt
%VT_Unknown
%VT_UserDefined
%VT_Variant
%VT_Vector
%VT_Void
%White
%Yellow
'
?
Abs
Accel
Accept
Access
ACode$
Add
Addr
Alias
All
And
Any
Append
Arc
Array
ArrayAttr
As
Asc
Ascend
Asciiz
Asciz
Asm
Assign
AssignAccel
At
Atn
Attach
Attrib
Bar
Base
Baud
BDecl
Beep
Begin
Bgr
Bin$
Binary
Bit
Bitmap
Bits
Bits%
Bits&
Bits?
Bits??
Bits???
Border
Box
Break
Button
ByCmd
ByCopy
ByRef
Byte
ByVal
Calc
Call
CallBack
CallStk
CallStk$
CallStkCount
Cancel
Case
Catch
CbCtl
CbCtlMsg
CbHndl
CbLParam
CbMsg
CbWParam
CByt
CCur
CCux
CD
CDbl
CDecl
CDwd
Ceil
Cext
ChDir
ChDrive
Check
Check3State
CheckBox
Choose
Choose$
Choose%
Choose&
Chr
Chr$
CInt
CLng
Class
CleanUp
Clear
Client
Close
Close#
ClsId$
CodePtr
Collate
Color
ComboBox
Comm
Command$
Con
Connect
Const
Const$
Constants
Control
Copy
Cos
CQud
Create
Created
CSet
CSet$
CSng
CtsFlow
Cur
CurDir$
Currency
CurrencyX
Cux
CvByt
CvCur
CvCux
Cvd
CvDwd
Cve
Cvi
Cvl
Cvq
Cvs
CvWrd
CWrd
Data
DataCount
Date$
DC
Declarations
Declare
Decr
Default
DefByt
DefCur
DefCux
DefDbl
DefDwd
DefExt
DefInt
DefLng
DefQud
DefSng
DefStr
DefWrd
Delete
Descend
Desktop
Dialog
Dim
Dir$
Disable
DiskFree
DiskSize
Dispatch
DispParams
Dll
DllMain
DllMain&
Do
DoEvents
Double
Draw
DsrFlow
DsrSens
DtrFlow
DtrLine
Dword
Ellipse
Else
ElseIf
Empty
Enable
End
Environ
Environ$
Eof
Eqv
Erase
ErL
Err
ErrApi
ErrClear
Error
Error$
Exe
Exit
Exp
Exp10
Exp2
Explicit
Export
Ext
Extended
Extract$
Field
Field#
FileAttr
FileCopy
FileName$
FileScan
Fill
Finally
Fix
Flow
Flush
Flush#
Focus
Font
For
Format$
FormFeed
Frac
Frame
FreeFile
From
FuncName$
Function
Get
Get#
Get$
GetAttr
Global
GoSub
GoTo
Graphic
Guid
Guid$
GuidTxt$
Handle
Handles
Hex$
Hi
HiByt
HiInt
HiWrd
Host
ICase
Icon
IDispatch
Idn
If
IFace
IIf
IIf$
IIf%
IIf&
Image
ImageX
ImgButton
ImgButtonX
Imp
In
Includes
Incr
InOut
Inp
Input
Input#
Input$
InputBox$
Insert
InStr
Int
Integer
Interface
Inv
Is
IsFalse
IsNothing
IsObject
IsTrue
Iterate
IUnknown
Join$
Kill
Label
LBound
LCase$
Left
Left$
Len
Let
Lib
LibMain
LibMain&
Line
Lines
ListBox
Lo
Load
LoByt
Loc
Local
Lock
Lock#
Lof
Log
Log10
Log2
LoInt
Long
Loop
LoWrd
LPrint
LPrint$
LSet
LSet$
LTrim$
Macro
MacroTemp
Main
Main&
Mak
MakDwd
MakInt
MakLng
MakPtr
MakWrd
Margin
Mat
Max
Max$
Max%
Max&
MCase$
Member
Menu
Mid$
Min
Min$
Min%
Min&
Mix
MkByt$
MkCur$
MkCux$
Mkd$
MkDir
MkDwd$
Mke$
Mki$
Mkl$
Mkq$
Mks$
MkWrd$
Mod
Modal
Modeless
MousePtr
MsgBox
Name
New
Next
None
Not
Nothing
Notify
Nul$
Null
ObjActive
Object
ObjPtr
ObjResult
Oct$
Of
Off
On
Open
Opt
Option
Optional
Or
Orientation
Out
Output
Paint
Parity
ParityChar
ParityRepl
ParityType
Parse
Parse$
ParseCount
PBLibMain
PBLibMain&
PBMain
PBMain&
PBWin
Peek
Peek$
Pie
Pixel
Pixels
Pointer
Poke
Poke$
Polygon
Polyline
PopUp
Port
Pos
Post
PPI
Preserve
Print
Print#
Printer$
PrinterCount
Private
Profile
ProgId$
Ptr
Put
Put#
Put$
Quad
Quality
Qword
Random
Randomize
Read
Read$
Records
Recv
ReDim
ReDraw
RegExpr
Register
RegRepl
Rem
Remain$
Remove$
Render
Repeat$
Replace
Reset
Resume
Retain$
Return
RGB
Right
Right$
Ring
Rlsd
RmDir
Rnd
Rotate
Round
RSet
RSet$
RTrim$
RtsFlow
RxBuffer
RxQue
Save
SBit
Scale
Scan
ScrollBar
SDecl
Seek
Seek#
Select
Send
Server
Set
SetAttr
SetEof
SetEof#
Sgn
Shared
Shell
Shift
Show
Signed
Sin
Single
Size
SizeOf
Sleep
Sort
Space$
Spc
Sqr
State
Static
Status
StdCall
Step
Stop
Str$
StrDelete$
Stretch
String
String$
StrInsert$
StrPtr
StrReverse$
Style
Sub
Suspend
Swap
Switch
Switch$
Switch%
Switch&
Tab
Tab$
TagArray
Tally
Tan
Tcp
Text
TextBox
Then
Thread
ThreadCount
Threaded
ThreadID
Time$
TimeOut
Timer
To
Toggle
Trace
Trim$
Trn
Try
TxBuffer
TxQue
Type
UBound
UCase
UCase$
UCode$
Udp
Union
Units
UnLock
UnLock#
Until
User
Using
Using$
Val
Variant
Variant#
Variant$
VariantVT
VarPtr
Verify
Version3
Version4
Version5
Wend
While
Width
Width#
Window
WinMain
WinMain&
With
Word
Write
Write#
XInpFlow
Xor
XOutFlow
XPrint
XPrint$
Zer
Title: Re: BAS2NIM
Post by: kryton9 on October 16, 2013, 10:44:53 PM
Daniels work is daunting. But think of all the PowerBasic users looking for a way out. His work will be used by many that is for sure!
Title: Re: BAS2NIM
Post by: kryton9 on October 16, 2013, 10:47:21 PM
I will tinker with it tomorrow as I want to learn SB better.
Just the little bit we have done makes you appreciate language developers, wow talk about work!
Title: Re: BAS2NIM
Post by: kryton9 on October 17, 2013, 03:54:07 PM
John, as you know I get confused easily, so am not following well... I will get on and look at the code and then perhaps get a better picture.
Looking forward to hearing you ideas.

Perhaps we need a list of BASICS and what they can do and are planning to do and which would benefit from such a project.

For example:
ScriptBasic - already cross-platform and can output to C. So, no need for translator.
OxygenBasic - planned to be cross-platform and output to C, So, no need for translator.
PowerBasic - windows only. I don't know if it can output to C, need for translator to be cross platform
...
Title: Re: BAS2NIM
Post by: John on October 17, 2013, 04:35:13 PM
I don't think a BAS2NIM utility would be much value if it couldn't at least translate PowerBASIC Console Compiler 5 BASIC. Beyond that creating a BASIC seems to be a life long dream of most that have used the language. I think this effort will help others understand the benefits of high level languages and what is going on under the covers.

I'm still waiting to see what Daniel has up his sleeve. I'm just trying to keep some momentum going with my SB efforts. As you can see, it doesn't take much SB code/time to show a concept. I encourage anyone with an idea how to save BASIC and make it more cross platform to come forward and tell us your ideas.

Good to solve the mystery of the other vote. I should of guessed AIR was going to do some of his Python magic for us.  8)
Title: Re: BAS2NIM
Post by: AIR on October 17, 2013, 05:22:10 PM
You'll need the pyparsing module (sudo easy_install pyparsing, to get it).

Just a rudimentary, quickly thrown together attempt.  The "test" variable holds a sample, and as you can see it is NOT case sensitive.

Code: [Select]
#!/usr/bin/env python

from pyparsing import *

test = """
let g = 10
LET A = "Hello BAS2NIM"
PRINT A
print "Howya Doin? " & A
for x = 0 to g-1
    print x
next

If g = 10 then
    print "OK"
end if

while g > 0
    print g
    g = g - 1
wend

""".split('\n')


IDENT = Word(alphas, alphanums+"_")

# KEYWORDS
LET = Keyword('Let',  caseless=True)
PRINT = Keyword('print',  caseless=True)
FOR = Keyword('for',  caseless=True)
TO = Keyword('to',  caseless=True)
NEXT = Keyword('next',  caseless=True)
IF = Keyword('if',  caseless=True)
THEN = Keyword('then',  caseless=True)
ELSE = Keyword('else',  caseless=True)
WHILE = Keyword('while',  caseless=True)
WEND = Keyword('wend',  caseless=True)
END = Keyword('end',  caseless=True)
ASC = Keyword('asc',  caseless=True)
VAL = Keyword('val',  caseless=True)
STR = Keyword('str',  caseless=True)
MID = Keyword('mid',  caseless=True)
LEFT = Keyword('left',  caseless=True)
UCASE = Keyword('ucase',  caseless=True)
LCASE = Keyword('lcase',  caseless=True)
UBOUND = Keyword('ubound', caseless=True)
LBOUND = Keyword('lbound', caseless=True)
ENDIF = END + IF


# KEYWORD REPLACEMENT ACTIONS
PRINT.setParseAction(replaceWith('echo'))
LET.setParseAction(replaceWith('var'))
TO.setParseAction(replaceWith('..'))
NEXT.setParseAction(replaceWith(None))
UBOUND.setParseAction(replaceWith('high'))
LBOUND.setParseAction(replaceWith('low'))
WEND.setParseAction(replaceWith(None))



all_keywords = FOR|NEXT|IF|THEN|ELSE|WHILE|WEND|LET \
   |PRINT|END|ASC|VAL|STR|MID|LEFT|UCASE \
   |LCASE|UBOUND|LBOUND|TO

for line in test:
if "for" in line.lower():
line = line.replace('=','in')+':'
elif "then" in line.lower():
line = line.replace(' then',':').replace('=','==')
elif "while" in line.lower():
line = line.replace('=','==')+':'
elif "end if" or "endif" in line.lower():
line = line.replace('end if','')


print all_keywords.transformString(line)

Quote from: CONVERTED OUTPUT
var g = 10
var A = "Hello BAS2NIM"
echo A
echo "Howya Doin? " & A
for x in 0 .. g-1:
    echo x


if g == 10:
    echo "OK"


while g > 0:
    echo g
    g = g - 1

Just playing around with this, I probably won't have time to do this properly....

A.
Title: Re: BAS2NIM
Post by: John on October 17, 2013, 05:50:31 PM
Looks great AIR!

I'm sure if you could get enough of a framework going others would jump in and help. I'm not a Python guy but willing to learn if this is a better solution.

I installed pyparsing via synaptic. It doesn't look like it's available on the C9 IDE enviroment. I'll ask the C9 guys if they have a c9pm package available for it.

Code: [Select]
from pyparsing import Word, alphas
greet = Word( alphas ) + "," + Word( alphas ) + "!" # <-- grammar defined here
hello = "Hello, World!"
print (hello, "->", greet.parseString( hello ))

jrs@laptop:~/bas2nim$ python pyparse.py
('Hello, World!', '->', (['Hello', ',', 'World', '!'], {}))
jrs@laptop:~/bas2nim$
Title: Re: BAS2NIM
Post by: John on October 17, 2013, 07:06:55 PM
I got pyparsing 2.01 installed on the Cloud9 IDE Nimrod site.

Code: [Select]
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1 $ python setup.py install
running install
running build
running build_py
creating build
creating build/lib
copying pyparsing.py -> build/lib
running install_lib
copying build/lib/pyparsing.py -> /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/lib/python/site-packages
byte-compiling /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/lib/python/site-packages/pyparsing.py to pyparsing.pyc
running install_egg_info
Writing /var/lib/stickshift/525387a75973caafd40003a0/app-root/data/lib/python/site-packages/pyparsing-2.0.1-py2.6.egg-info
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1 $
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1 $ ls -l
total 876
drwxr-xr-x. 3 525387a75973caafd40003a0 525387a75973caafd40003a0   4096 Oct 17 22:02 build/
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  73858 Jul 17 00:49 CHANGES
drwxr-xr-x. 2 525387a75973caafd40003a0 525387a75973caafd40003a0   4096 Jul 17 03:38 docs/
drwxr-xr-x. 2 525387a75973caafd40003a0 525387a75973caafd40003a0   4096 Jul 17 03:38 examples/
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  69524 Jul 17 02:30 HowToUsePyparsing.html
drwxr-xr-x. 2 525387a75973caafd40003a0 525387a75973caafd40003a0   4096 Jul 17 03:38 htmldoc/
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1041 Oct 15  2007 LICENSE
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    994 Jul 17 03:38 PKG-INFO
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 236402 Apr 13  2009 pyparsingClassDiagram.JPG
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 141354 Apr 13  2009 pyparsingClassDiagram.PNG
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 154099 Jul 17 03:08 pyparsing.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 173787 Oct 17 22:02 pyparsing.pyc
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1947 Sep 13  2005 README
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0     35 May  5  2006 robots.txt
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1320 Jul 17 00:52 setup.py
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1 $ cd examples
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1/examples $ ls -l
total 780
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  12027 Oct 18  2012 0README.html
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  39137 Feb 28  2003 AcManForm.dfm
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  20595 Nov 23  2012 adventureEngine.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  10733 Nov 23  2012 antlr_grammar.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2499 Sep  7  2010 antlr_grammar_tests.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2170 Nov 23  2012 apicheck.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   4374 Nov 23  2012 btpyparse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    885 Nov 23  2012 builtin_parse_action_demo.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2062 Nov 23  2012 chemicalFormulas.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    806 Nov 23  2012 cLibHeader.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    744 Nov 23  2012 commasep.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2054 Nov 23  2012 configParse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1342 Nov 23  2012 cpp_enum_parser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1582 Nov 23  2012 datetimeParseActions.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7051 Nov 23  2012 deltaTime.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   6933 Nov 23  2012 dfmparse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3164 Nov 23  2012 dhcpd_leases_parser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2198 Nov 23  2012 dictExample2.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1612 Nov 23  2012 dictExample.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   4247 Mar  9  2004 ebnf.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2322 Nov 23  2012 ebnftest.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7102 Nov 23  2012 eval_arith.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2326 Nov 23  2012 excelExpr.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7196 Nov 23  2012 fourFn.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   5175 Nov 23  2012 gen_ctypes.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1311 Nov 23  2012 getNTPserversNew.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1101 Nov 23  2012 getNTPservers.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    434 Nov 23  2012 greetingInGreek.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    479 Nov 23  2012 greetingInKorean.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    372 Nov 23  2012 greeting.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    502 Nov 23  2012 groupUsingListAllMatches.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1075 Nov 23  2012 holaMundo.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1251 Nov 23  2012 htmlStripper.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3577 Nov 23  2012 httpServerLogParser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   8082 Nov 23  2012 idlParse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1928 Nov 23  2012 indentedGrammarExample.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7652 Nov 23  2012 invRegex.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3525 Nov 23  2012 jsonParser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  18475 Nov 23  2012 LAparser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1531 Nov 23  2012 linenoExample.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1658 Nov 23  2012 list1.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1788 Nov 23  2012 listAllMatches.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7326 Nov 23  2012 lucene_grammar.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1844 Nov 23  2012 macroExpander.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    796 Nov 23  2012 makeHTMLTagExample.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    587 Nov 23  2012 matchPreviousDemo.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2700 Nov 23  2012 mozillaCalendarParser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    752 Jul 16  2004 mozilla.ics
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    609 Nov 23  2012 nested.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3871 Nov 23  2012 oc.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3863 Nov 23  2012 parseListString.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2167 Nov 23  2012 parsePythonValue.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    827 Nov 23  2012 parseResultsSumExample.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3310 Nov 23  2012 partial_gene_match.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3498 Nov 23  2012 pgn.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2217 Nov 23  2012 position.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3565 Nov 23  2012 protobuf_parser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  60603 Nov 23  2012 pymicko.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   8230 Nov 23  2012 pythonGrammarParser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2562 Nov 23  2012 rangeCheck.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0 123643 Nov 23  2012 readJson.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1524 Nov 23  2012 removeLineBreaks.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2366 Nov 23  2012 romanNumerals.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2363 Nov 23  2012 scanExamples.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    452 Nov 23  2012 scanYahoo.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    935 Nov 23  2012 searchParserAppDemo.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  10737 Nov 23  2012 searchparser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   6371 Nov 23  2012 select_parser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   5504 Nov 23  2012 sexpParser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1715 Nov 23  2012 shapes.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2323 Nov 23  2012 simpleArith.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   2220 Nov 23  2012 simpleBool.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3115 Nov 23  2012 SimpleCalc.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   4760 Nov 23  2012 simpleSQL.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1082 Nov 23  2012 simpleWiki.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  43730 Feb 28  2003 SingleForm.dfm
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  13282 Nov 23  2012 sparser.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3033 Nov 23  2012 sql2dot.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3000 Nov 23  2012 stackish.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   8825 Nov 23  2012 stateMachine2.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1027 Nov 23  2012 tagCapture.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7467 Nov 23  2012 TAP.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   7867 Jan  4  2011 test_bibparse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1475 Nov 23  2012 urlExtractorNew.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   1794 Nov 23  2012 urlExtractor.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0  31847 Nov 23  2012 verilogParse.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0    887 Nov 23  2012 withAttribute.py
-rw-r--r--. 1 525387a75973caafd40003a0 525387a75973caafd40003a0   3259 Nov 23  2012 wordsToNum.py
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1/examples $ python searchParserAppDemo.py
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/install/pyparsing-2.0.1/examples/searchparser.py:61: DeprecationWarning: the sets module is deprecated
  from sets import Set
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/install/pyparsing-2.0.1/examples/searchparser.py:99: DeprecationWarning: Operator '<<' is deprecated, use '<<=' instead
  (operatorWord + operatorQuotesContent) | operatorWord
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/install/pyparsing-2.0.1/examples/searchparser.py:113: DeprecationWarning: Operator '<<' is deprecated, use '<<=' instead
  ).setResultsName("not") | operatorParenthesis)
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/install/pyparsing-2.0.1/examples/searchparser.py:120: DeprecationWarning: Operator '<<' is deprecated, use '<<=' instead
  ).setResultsName("and") | operatorNot)
/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/install/pyparsing-2.0.1/examples/searchparser.py:124: DeprecationWarning: Operator '<<' is deprecated, use '<<=' instead
  ).setResultsName("or") | operatorAnd)
grape or orange
set(['orange juice', 'grape juice', 'orange marmalade', 'orange jujubees', 'grape jelly'])
()
grape*
set(['grapefruit juice', 'grape juice', 'grape jelly'])
()
not(grape*)
set(['orange jujubees', 'orange juice', 'prune butter', 'orange marmalade', 'strawberry jam', 'prune juice'])
()
prune and grape
set([])
()
scriptbasic@nimrod:~/639761/install/pyparsing-2.0.1/examples $
Title: Re: BAS2NIM
Post by: AIR on October 17, 2013, 07:30:22 PM
I just did:  easy_install pyparsing (without the sudo) and it installed fine in my c9 test instance.
Title: Re: BAS2NIM
Post by: John on October 17, 2013, 07:33:33 PM
Excellent!

It would be great if you could setup a github project for BAS2NIM using Python.

Building Recursive Descent Parsers with Python (http://www.onlamp.com/pub/a/python/2006/01/26/pyparsing.html)

Quote
Pyparsing provides a basic framework for creating recursive-descent parsers, taking care of the overhead functions of scanning the input string, handling expression mismatches, selecting the longest of matching alternatives, invoking callback functions, and returning the parsed results. This leaves developers free to focus on their grammar design and the design and implementation of corresponding token processing. Pyparsing's nature as a combinator allows developers to scale their applications from simple tokenizers up to complex grammar processors. It is a great way to get started with your next parsing project!

Code: [Select]
#
# simpleArith.py
#
# Example of defining an arithmetic expression parser using
# the operatorPrecedence helper method in pyparsing.
#
# Copyright 2006, by Paul McGuire
#

from pyparsing import *

integer = Word(nums).setParseAction(lambda t:int(t[0]))
variable = Word(alphas,exact=1)
operand = integer | variable

expop = Literal('^')
signop = oneOf('+ -')
multop = oneOf('* /')
plusop = oneOf('+ -')
factop = Literal('!')

# To use the operatorPrecedence helper:
#   1.  Define the "atom" operand term of the grammar.
#       For this simple grammar, the smallest operand is either
#       and integer or a variable.  This will be the first argument
#       to the operatorPrecedence method.
#   2.  Define a list of tuples for each level of operator
#       precendence.  Each tuple is of the form
#       (opExpr, numTerms, rightLeftAssoc, parseAction), where
#       - opExpr is the pyparsing expression for the operator;
#          may also be a string, which will be converted to a Literal
#       - numTerms is the number of terms for this operator (must
#          be 1 or 2)
#       - rightLeftAssoc is the indicator whether the operator is
#          right or left associative, using the pyparsing-defined
#          constants opAssoc.RIGHT and opAssoc.LEFT.
#       - parseAction is the parse action to be associated with
#          expressions matching this operator expression (the
#          parse action tuple member may be omitted)
#   3.  Call operatorPrecedence passing the operand expression and
#       the operator precedence list, and save the returned value
#       as the generated pyparsing expression.  You can then use
#       this expression to parse input strings, or incorporate it
#       into a larger, more complex grammar.
#       
expr = operatorPrecedence( operand,
    [("!", 1, opAssoc.LEFT),
     ("^", 2, opAssoc.RIGHT),
     (signop, 1, opAssoc.RIGHT),
     (multop, 2, opAssoc.LEFT),
     (plusop, 2, opAssoc.LEFT),]
    )

test = ["9 + 2 + 3",
        "9 + 2 * 3",
        "(9 + 2) * 3",
        "(9 + -2) * 3",
        "(9 + -2) * 3^2^2",
        "(9! + -2) * 3^2^2",
        "M*X + B",
        "M*(X + B)",
        "1+2*-3^4*5+-+-6",]
for t in test:
    print(t)
    print(expr.parseString(t))
    print()

jrs@laptop:~/bas2nim/pyparsing-2.0.1/examples$ python simpleArith.py
9 + 2 + 3
[[9, '+', 2, '+', 3]]
()
9 + 2 * 3
[[9, '+', [2, '*', 3]]]
()
(9 + 2) * 3
[[[9, '+', 2], '*', 3]]
()
(9 + -2) * 3
[[[9, '+', ['-', 2]], '*', 3]]
()
(9 + -2) * 3^2^2
[[[9, '+', ['-', 2]], '*', [3, '^', [2, '^', 2]]]]
()
(9! + -2) * 3^2^2
[[[[9, '!'], '+', ['-', 2]], '*', [3, '^', [2, '^', 2]]]]
()
M*X + B
[[['M', '*', 'X'], '+', 'B']]
()
M*(X + B)
[['M', '*', ['X', '+', 'B']]]
()
1+2*-3^4*5+-+-6
[[1, '+', [2, '*', ['-', [3, '^', 4]], '*', 5], '+', ['-', ['+', ['-', 6]]]]]
()
jrs@laptop:~/bas2nim/pyparsing-2.0.1/examples$

Code: [Select]
#
# cLibHeader.py
#
# A simple parser to extract API doc info from a C header file
#
# Copyright, 2012 - Paul McGuire
#

from pyparsing import Word, alphas, alphanums, Combine, oneOf, Optional, delimitedList, Group, Keyword

testdata = """
  int func1(float *vec, int len, double arg1);
  int func2(float **arr, float *vec, int len, double arg1, double arg2);
  """
 
ident = Word(alphas, alphanums + "_")
vartype = Combine( oneOf("float double int char") + Optional(Word("*")), adjacent = False)
arglist = delimitedList(Group(vartype("type") + ident("name")))

functionCall = Keyword("int") + ident("name") + "(" + arglist("args") + ")" + ";"

for fn,s,e in functionCall.scanString(testdata):
    print(fn.name)
    for a in fn.args:
        print(" - %(name)s (%(type)s)" % a)

jrs@laptop:~/bas2nim/pyparsing-2.0.1/examples$ python cLibHeader.py
func1
 - vec (float*)
 - len (int)
 - arg1 (double)
func2
 - arr (float**)
 - vec (float*)
 - len (int)
 - arg1 (double)
 - arg2 (double)
jrs@laptop:~/bas2nim/pyparsing-2.0.1/examples$
Title: Re: BAS2NIM
Post by: AIR on October 17, 2013, 10:50:09 PM
Good to solve the mystery of the other vote. I should of guessed AIR was going to do some of his Python magic for us.  8)

I knew that was gonna make you wonder!   ;D

A.
Title: Re: BAS2NIM
Post by: kryton9 on October 17, 2013, 11:36:42 PM
AIR + PYTHON = MAGIC TRANSLATOR

My latest updates here:
http://www.allbasic.info/forum/index.php?topic=249.msg2826#msg2826
Title: BAS2NIM
Post by: John on October 18, 2013, 10:08:30 AM
I have merged all BAS2NIM threads into one. The project / post thread idea  didn't work out and became too confusing. As this progresses, I might create separate sub boards for each of the BAS2NIM translators. (SB, Python, uCalc, ...)

Please post all working code concepts here on All BASIC. The C9 IDE BAS2NIM site is not viewable to non-developer members.

 
Title: Re: BAS2NIM
Post by: John on October 18, 2013, 10:39:23 AM
Kent merged his BASIC to Nimrod translation maps into the ScriptBasic proof of concept example I posted. This example is to show how common BASIC syntax converts to Nimrod and not an example of a real BASIC program. (BASIC functions are part of a directive not standalone)

BASIC code example
Code: [Select]
LET A = "Hello BAS2NIM"
PRINT A,"\n"
ASC   "Z"
VAL   "123"
STR   321
MID   "One Two Three Four",  1, 3
MID   "One Two Three Four",  5, 3
MID   "One Two Three Four",  9, 5
MID   "One Two Three Four", 15, 4
LEFT  "One Two Three Four", 3
INSTR "One Two Three Four", "One"
INSTR "One Two Three Four", "Two"
INSTR "One Two Three Four", "Three"
INSTR "One Two Three Four", "Four"
UCASE "aLl mIxEd cAsE"
LCASE "aLl mIxEd cAsE"

ScriptBasic translator
Code: [Select]
'b2nV2.sb
'renamed don't want to mess up the original copy
PRINT "# output from command line: scriba b2nV2.sb test2.bas > test2.nim \n"
PRINT "# compile from command line: nimrod c test2.nim \n"
PRINT "# execute from command line: ./test2 \n"
PRINT "import strutils \n"


' BAS2NIM - ScriptBasic
' Last Update: 2013-10-15
' Contributors: John Spikowski & Kent Sarikaya

' BASIC keyword dictionary

keywords{"DIM"}[0]=ADDRESS(Convert_DIM())
keywords{"FOR"}[0]=ADDRESS(Convert_FOR())
keywords{"NEXT"}[0]=ADDRESS(Convert_NEXT())
keywords{"IF"}[0]=ADDRESS(Convert_IF())
keywords{"WHILE"}[0]=ADDRESS(Convert_WHILE())
keywords{"WEND"}[0]=ADDRESS(Convert_WEND())
keywords{"LET"}[0]=ADDRESS(Convert_LET())
' keywords{"GOTO"}[0]=ADDRESS(Convert_GOTO())
' keywords{"GOSUB"}[0]=ADDRESS(Convert_GOSUB())
' keywords{"RETURN"}[0]=ADDRESS(Convert_RETURN())
keywords{"PRINT"}[0]=ADDRESS(Convert_PRINT())
keywords{"END"}[0]=ADDRESS(Convert_END())
keywords{"ASC"}[0]=ADDRESS(Convert_ASC())
keywords{"VAL"}[0]=ADDRESS(Convert_VAL())
keywords{"STR"}[0]=ADDRESS(Convert_STR())
keywords{"MID"}[0]=ADDRESS(Convert_MID())
keywords{"LEFT"}[0]=ADDRESS(Convert_LEFT())
keywords{"INSTR"}[0]=ADDRESS(Convert_INSTR())
keywords{"UCASE"}[0]=ADDRESS(Convert_UCASE())
keywords{"LCASE"}[0]=ADDRESS(Convert_LCASE())
keywords{"UBOUND"}[0]=ADDRESS(Convert_UBOUND())
keywords{"LBOUND"}[0]=ADDRESS(Convert_LBOUND())


' BASIC Directives

SUB Convert_DIM
END SUB

SUB Convert_FOR
  IF BASIC LIKE "FOR * = * TO *" THEN
    expr[1] = JOKER(1)
    expr[2] = JOKER(2)
    expr[3] = JOKER(3)
    ' Translate
    PRINT Nimrod
  ELSE IF BASIC LIKE "FOR * = * TO * STEP *" THEN
    expr[1] = JOKER(1)
    expr[2] = JOKER(2)
    expr[3] = JOKER(3)
    expr[4] = JOKER(4)
    ' Translate
    PRINT Nimrod
  ELSE
    END
  END IF 
END SUB

SUB Convert_NEXT
'no NEXT in nimrod
END SUB

SUB Convert_IF
END SUB

SUB Convert_WHILE
END SUB

SUB Convert_WEND
'no WEND in nimrod
END SUB

SUB Convert_LET
  IF BASIC LIKE "LET *" THEN
    PRINT "var ", JOKER(1), "\n"
  ELSE
    END
  END IF
END SUB

' SUB Convert_GOTO
'no GOTO in nimrod
' END SUB

' SUB Convert_GOSUB
' END SUB

' SUB Convert_RETURN
' END SUB

SUB Convert_PRINT
  IF BASIC LIKE "PRINT *" THEN
    PRINT "stdout.write(", JOKER(1), ")\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_END
END SUB


' BASIC Functions

SUB Convert_ASC
  IF BASIC LIKE "ASC *" THEN
     S = MID(JOKER(1), 2, LEN(JOKER(1))-2)
     PRINT "echo(", "ord('", S, "'))\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_VAL
  IF BASIC LIKE "VAL *" THEN
    PRINT "echo(", "parseInt(", JOKER(1), "))\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_STR
  IF BASIC LIKE "STR *" THEN
    PRINT "echo(", "$", JOKER(1), ")\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_MID
  IF BASIC LIKE "MID *, *, *" THEN
    PRINT "echo(", JOKER(1),"[",JOKER(2)-1,"..",JOKER(2)+JOKER(3)-2,"])\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_LEFT
  IF BASIC LIKE "LEFT *, *" THEN
    PRINT "echo(", JOKER(1),"[0..",JOKER(2) - 1,"])\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_INSTR
  IF BASIC LIKE "INSTR *, *" THEN
    PRINT "echo(find(", JOKER(1), ",", JOKER(2), ")+1)\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_UCASE
  IF BASIC LIKE "UCASE *" THEN
    PRINT "echo(", JOKER(1),".toUpper())\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_LCASE
  IF BASIC LIKE "LCASE *" THEN
    PRINT "echo(", JOKER(1),".toLower())\n"
  ELSE
    END
  END IF
END SUB

SUB Convert_UBOUND
END SUB

SUB Convert_LBOUND
END SUB


' MAIN

filename_argument = COMMAND()
OPEN filename_argument FOR INPUT AS #1
WHILE NOT(EOF(1))
  LINE INPUT #1, BASIC
  BASIC = CHOMP(BASIC)
  sp = INSTR(BASIC, " ")
  test_keyword = LEFT(BASIC, sp -1)
  IF keywords{test_keyword}[0] <> undef THEN
    success = ICALL(keywords{test_keyword}[0])
  ELSE
    END
  END IF
WEND

Output

scriptbasic@nimrod:~/639761/projects/John $ scriba b2nV2.sb test2.bas
# output from command line: scriba b2nV2.sb test2.bas > test2.nim
# compile from command line: nimrod c test2.nim
# execute from command line: ./test2
import strutils
var A = "Hello BAS2NIM"
stdout.write(A,"\n")
echo(ord('Z'))
echo(parseInt("123"))
echo($321)
echo("One Two Three Four"[0..2])
echo("One Two Three Four"[4..6])
echo("One Two Three Four"[8..12])
echo("One Two Three Four"[14..17])
echo("One Two Three Four"[0..2])
echo(find("One Two Three Four","One")+1)
echo(find("One Two Three Four","Two")+1)
echo(find("One Two Three Four","Three")+1)
echo(find("One Two Three Four","Four")+1)
echo("aLl mIxEd cAsE".toUpper())
echo("aLl mIxEd cAsE".toLower())
scriptbasic@nimrod:~/639761/projects/John $ scriba b2nV2.sb test2.bas > test2.nim
scriptbasic@nimrod:~/639761/projects/John $ nimrod c test2.nim
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/babel-0.1.0' [Path]
config/nimrod.cfg(36, 2) Hint: added path: '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/.babel/pkgs/' [Path]
Hint: used config file '/var/lib/stickshift/525387a75973caafd40003a0/app-root/data/639761/Nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: test2 [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: operation successful (9446 lines compiled; 1.955 sec total; 16.163MB) [SuccessX]
scriptbasic@nimrod:~/639761/projects/John $ ./test2
Hello BAS2NIM
90
123
321
One
Two
Three
Four
One
1
5
9
15
ALL MIXED CASE
all mixed case
scriptbasic@nimrod:~/639761/projects/John $
Title: Re: BAS2NIM
Post by: kryton9 on October 18, 2013, 12:15:06 PM
Thanks John, for posting the code.
I tried and thought it was too long with all three projects in one. So I just attached the zip file.

Is there a way to turn on syntax highlighting as you and Charles did on the OxygenBasic Forums?
http://www.oxygenbasic.org/forum/index.php?topic=200.0
The you just specify like this with BBCODE:
Code: Text
  1.  code here
Code: Text
  1.  code here
Code: Python
  1.  code here
Title: Re: BAS2NIM
Post by: John on October 18, 2013, 12:48:34 PM
There are too many versions of BASIC and other LIKE languages posted here to try and create keyword maps for. It would be a full time job.  I would like to get Nimrod and SB supported on C9 IDE for the ACE editor but I don't know if they will allow additions to what they already offer. Researching it.


Title: Re: BAS2NIM
Post by: kryton9 on October 18, 2013, 11:30:46 PM
There is an older cloud9 running on the beaglebone black. I played with it. So you could probably download cloud9 and put it on your server and then do what you want with it.

About syntax highlighting... in one of my posts, I had gotten (font)(size) -using () instead of square brackets to not confuse it--  to work, but it was just one time, all the others it failed.
I had courier 8 point and you could fit a lot of code and it kept the space nicely since monospaced.

Let me try it here without the (code) block to see if that was messing it up.

Without code block:
                  1                  2                  3
123456789012345678901234567890


With code block:
Code: [Select]
[font=andale mono][size=8pt]                  1                  2                  3
123456789012345678901234567890[/size][/font]

So the code block is messing it up. I will just remember to not use it from now on. Courier didn't work as well as andale mono tonight, so switched to that.

Hey, the voting changed,  I will see if I can change my vote too :)
Title: Nimsic BASIC Language Translator(s)
Post by: John on October 22, 2013, 03:06:43 AM
AIR and I have been chipping away at creating a BASIC to Nimrod translator in Python and in ScriptBasic. Daniel has joined in the effort with his uCalc Transform set of tools. My hope is that Kent will join forces with Daniel and get that project off the ground.

I think the goal of the BAS2NIM project should be to create a BASIC like language syntax that is traditional enough that BASIC programmers will feel at home with it but with the goal of a smooth and easy translation to Nimrod code. If the goal was to target any one BASIC language then only a small group would benefit. The real end goal is to make BASIC programmers efficient Nimrod programmers without the pain of abruptly having to learn a new language. Think of BAS2NIM as training wheels for Nimrod.

Nimrod doesn't support GOTO / GOSUB so it isn't going to be part of Nimsic. :o  Armando is forging the path and I'm trying to follow his lead with SB. As the core language jells we will post some examples here to play with.

I would also like to see a USE Nimrod, C and ASM feature in the BASIC syntax as a pass-through using the translator. The hope again is the user becomes more comfortable with Nimrod using less BASIC wrapper code as time goes on.
Title: Shot down
Post by: John on October 22, 2013, 02:16:20 PM
Armando doesn't like the Nimsic name idea so the name is not going to be used. It sounded good at the time.  :)
Title: Re: Nimsic BASIC Language Translator(s)
Post by: AIR on October 22, 2013, 03:50:44 PM
The real end goal is to make BASIC programmers efficient Nimrod programmers without the pain of abruptly having to learn a new language. Think of BAS2NIM as training wheels for Nimrod.

I think it's just better to learn Nimrod.  It's a very powerful and flexible language.

Quote
I would also like to see a USE Nimrod, C and ASM feature in the BASIC syntax as a pass-through using the translator. The hope again is the user becomes more comfortable with Nimrod using less BASIC wrapper code as time goes on.

You're gonna have to write that part.  ;D

Nimrod's syntax is not difficult to pick up.  You can code it in a more Basic-like way [LEN(mystring)] or in a more OOP-like style [mystring.len()].

What I find really cool about it is if you create a function like:

Code: [Select]
proc stuff(a: string): string =
    return "This is your string: " & a

You can call it both ways:

Code: [Select]
echo stuff("Nimrod")

echo "Nimrod".stuff()

It's a trivial example, but it illustrates one of the things I like about this language.

So you can take Kent's basic.nim provided "left()" command, and instead of doing

Code: [Select]
left(mystring,5)
You can also do

Code: [Select]
mystring.left(5)
Which looks clearer, to me anyway.

A.
Title: Re: BAS2NIM
Post by: kryton9 on October 23, 2013, 12:25:21 AM
I agree just the little bit I worked with it. I don't think it is too hard for any basic programmer to come over to it.

There is lots of documentation, enough to get you started, but many more examples with commented code or articles would really help.
Once I get into it, I hope to document with examples as AIR just showed above. Seeing something is a lot easier to understand than reading about it
in depth.