Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Triple-Sec programming language

5 views
Skip to first unread message

dun...@yahoo.com

unread,
Jun 14, 2005, 11:33:23 PM6/14/05
to
I am writing a new programming language called 'Triple-Sec':

http://www.geocities.com/dunric/triple.html

Triple-Sec is a simple BASIC-like interpreter with 36 variables
and 8 non-dimensional strings. Here are the basic commands
used in Triple-Sec:
---------------------------------------------------------------
WRITE '<text>' (where <text> is up to 240 characters)
CLEAR (clears screen)
ADD x TO <variable> (add x to a variable: A-Z,Z0-Z9)
SUB x FROM <variable> (sub x from a variable: A-Z,Z0-Z9)
IF A=B THEN B=C (1-level IF command, like BASIC, but no ELSE)
JUMP x (like GOTO, where x is a line number)
INPKEY '<text>',var$ (get INPUT from var$: A-G$)
READ var$ (like READ in BASIC, from var$: A-G$)
@ '<text>',num,etc. (like DATA, using '@' instead)
GETKEY var$ (wait for keypress, from var$: A-G$)
MEM x (display available memory)
CLVAR (clear all variables of data)
RUN (or EXEC) (RUN the current program)
SAVE (SAVEs program; prompted for filename)
LOAD (LOADs program; prompted for filename)
LIST (LISTs program; Lines 1 through 9999)
BYE (or QUIT) (Exits Triple-Sec)
---------------------------------------------------------------

Limitations:

Triple-Sec is meant to be as 'BASIC' as possible. That is, it currently
only accepts 1 command per line, up to 9999 lines. A program cannot
exceed
9999 lines.

It also only allows 36 total variables (A through Z, plus Z0 through
Z9) and 8 total strings (A$ to G$, non-subscripted). Strings
cannot be subscripted, but variables can be (up to 255 elements, single
subscript).

Triple-Sec is being coded in PowerBASIC for DOS. If you'd like to help
me on this project, please e-mail me.

Program Examples:

Here is an example of a simple Triple-Sec program:

0: CLVAR
1: WRITE 'Hello World!'
2: A(1)=1.2:A$="Triple-Sec Version "
3: WRITE A$;A(1)
4: READ B$
5: @ 'This is the contents of variable B$'
6: READ C$
7: @ 'This is the contents of variable C$'
8: READ Z0
9: @ 25
10: WRITE B$
11: WRITE C$
12: WRITE 'The contents of variable Z0 is:';Z0
13: INPKEY 'Press the 'y' key to continue';D$
14: IF D$="y" OR D$="Y" THEN JUMP 17
15: WRITE 'Please enter 'y'...'
16: JUMP 13
17: ADD 1 TO Z0
18: WRITE 'Z0 is now: ';Z0
19: SUB 10 FROM Z0
20: WRITE 'Z0 is now: ';Z0
21: CLVAR
22: WRITE 'Variables cleared.'"
23: WRITE 'Memory is now: '
24: WRITE MEM x
25: WRITE 'Press any key to clear screen...'"
26: GETKEY E$
27: CLEAR

E-mail the author (Paul Panks, a/k/a "Dunric"):

dun...@yahoo.com

If you'd like to help me with this project, also please e-mail me and
offer suggestions on how to code this interpreter, or other ideas.

Paul

Erik de Castro Lopo

unread,
Jun 15, 2005, 3:55:17 AM6/15/05
to
dun...@yahoo.com wrote:
>
> I am writing a new programming language called 'Triple-Sec':
>
> http://www.geocities.com/dunric/triple.html
>
> Triple-Sec is a simple BASIC-like interpreter with 36 variables
> and 8 non-dimensional strings.

You are joking aren't you?

> If you'd like to help me with this project, also please e-mail me and
> offer suggestions on how to code this interpreter, or other ideas.

You must be joking!!!!!!

You post this to two groups (comp.lang.functional and
comp.lang.scheme) full of people who would rather give
up programming that program in BASIC.

Then I see that you cross-posted it to alt.lang.basic
where your post is 100% on topic. This makes me wonder
if you even know what a functional programming language
is, but then if you knew what a functional programming
language is, you wouldn't be reading alt.lang.basic.


Anyway .....

Erik

--
+-----------------------------------------------------------+
Erik de Castro Lopo nos...@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
The idea that Bill Gates has appeared like a knight in shining armour to
lead all customers out of a mire of technological chaos neatly ignores
the fact that it was he who, by peddling second-rate technology, led them
into it in the first place. - Douglas Adams in Guardian, 25-Aug-95

dun...@yahoo.com

unread,
Jun 15, 2005, 8:02:06 AM6/15/05
to
Well, I suppose functional could be anything beyond Commodore PET
Basic, or Bally BASIC, for that matter. :)

Paul

Erik de Castro Lopo

unread,
Jun 15, 2005, 10:06:49 AM6/15/05
to
dun...@yahoo.com wrote:
>
> Well, I suppose functional could be anything beyond Commodore PET
> Basic, or Bally BASIC, for that matter. :

Not according to this:

http://en.wikipedia.org/wiki/Functional_programming

BASIC, in all its forms is an imperative programming language.

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nos...@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+

Linux: the only OS that makes you feel guilty when you reboot
-- Kenneth Crudup in comp.os.linux.misc

TLOlczyk

unread,
Jun 15, 2005, 10:38:53 AM6/15/05
to

Uhm. Triple-sec. is that what you were drinking when you thought this
up?

The reply-to email address is olczy...@yahoo.com.
This is an address I ignore.
To reply via email, remove 2002 and change yahoo to
interaccess,

**
Thaddeus L. Olczyk, PhD

There is a difference between
*thinking* you know something,
and *knowing* you know something.

Frisbee®

unread,
Jun 15, 2005, 2:07:57 PM6/15/05
to
Will this help you find a wife, Paul?

<dun...@yahoo.com> wrote in message
news:1118806403.8...@o13g2000cwo.googlegroups.com...

Message has been deleted

Jon Harrop

unread,
Jun 15, 2005, 3:03:01 PM6/15/05
to
Arthur J. O'Dwyer wrote:
> Anyway, this looks like a decent couple of weeks' project for a
> moderately skilled amateur programmer.

Or a couple of hours if you use a language designed to write compilers and
interpreters in, like ML.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com

btpag...@yahoo.com

unread,
Jun 15, 2005, 4:22:16 PM6/15/05
to
What about Blue Curaco programming?

Brent

Cédric LEMAIRE

unread,
Jun 16, 2005, 3:51:22 AM6/16/05
to
> Or a couple of hours if you use a language designed to write compilers and
> interpreters in, like ML.


... Or a couple of hours (not more) to write the parser and to make a
compiler which translates Triple-Sec to C++, using CodeWorker, a
parsing tool and a source code generator (http://www.codeworker.org).

Proof. Here is the translation of the example code to C++, done by the
compiler written in CodeWorker:

#include <process.h>
#include <conio.h> // Windows only (sorry!), for GETKEY

#include <iostream>
#include <string>
#include <vector>

int arrayIndex(std::vector<double>& array, unsigned int iIndex) {
if (array.size() < iIndex) array.resize(iIndex);
return iIndex - 1;
}

// the data declared into the program:
const char* tcData[] = {"This is the contents of variable B$", "This is
the contents of variable C$", "25"};
int iDataCursor = 0;

// this program uses 7 variables:
std::vector<double> A_arr; // variable 'A()'
std::string A_str; // variable 'A$'
std::string B_str; // variable 'B$'
std::string C_str; // variable 'C$'
double Z0 = 0.0; // variable 'Z0'
std::string D_str; // variable 'D$'
std::string E_str; // variable 'E$'

void CLVAR() {
A_arr.clear();
A_str = "";
B_str = "";
C_str = "";
Z0 = 0.0;
D_str = "";
E_str = "";
}

size_t usedMEM() {
size_t iUsedMEM = 0;
iUsedMEM += A_arr.size() * sizeof(double) +
sizeof(std::vector<double>);
iUsedMEM += A_str.size() + sizeof(std::string);
iUsedMEM += B_str.size() + sizeof(std::string);
iUsedMEM += C_str.size() + sizeof(std::string);
iUsedMEM += sizeof(double);
iUsedMEM += D_str.size() + sizeof(std::string);
iUsedMEM += E_str.size() + sizeof(std::string);
return iUsedMEM;
}

int main(int, char**) {
// The translation of the program to C++:
try {
CLVAR();
std::cout << "Hello World!" << std::endl;
A_arr[arrayIndex(A_arr, (unsigned int) 1)] = 1.2;
A_str = "Triple-Sec Version ";
std::cout << A_str << A_arr[arrayIndex(A_arr, (unsigned int) 1)] <<
std::endl;
if (iDataCursor >= 3) throw "All data are consumed; can't read them
anymore";
B_str = tcData[iDataCursor++];
if (iDataCursor >= 3) throw "All data are consumed; can't read them
anymore";
C_str = tcData[iDataCursor++];
if (iDataCursor >= 3) throw "All data are consumed; can't read them
anymore";
Z0 = atof(tcData[iDataCursor++]);
std::cout << B_str << std::endl;
std::cout << C_str << std::endl;
std::cout << "The contents of variable Z0 is: " << Z0 << std::endl;
line13:
std::cout << "Press the 'y' key to continue ";
std::cin >> D_str;
if (((D_str == "y") || (D_str == "Y"))) {
goto line17;
}
std::cout << "Please enter 'y'..." << std::endl;
goto line13;
line17:
Z0 += 1;
std::cout << "Z0 is now: " << Z0 << std::endl;
Z0 -= 10;
std::cout << "Z0 is now: " << Z0 << std::endl;
CLVAR();
std::cout << "Variables cleared." << std::endl;
std::cout << "Memory is now: " << std::endl;
std::cout << -1*((int) usedMEM())/*implementation of MEM is
platform-dependent: return the used memory as a negative number*/ <<
std::endl;
std::cout << "Press any key to clear screen..." << std::endl;
{
// Windows implementation of 'GETKEY'
int iKey;
for (;;) {
iKey = _getch();
if (iKey != 0 && iKey != 0xE0) break;
_getch();
}
E_str = std::string(1, (char) iKey);
}
std::cout << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl << std::endl << std::endl << std::endl << std::endl <<
std::endl;
} catch(const char* tcError) {
std::cout << tcError << std::endl;
return 1;
}
return 0;
}

Dinko Tenev

unread,
Jun 16, 2005, 4:11:18 AM6/16/05
to
Cédric LEMAIRE wrote:
> Proof. Here is the translation of the example code to C++, done by the
> compiler written in CodeWorker:

[ deleted ]

> std::cout << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl << std::endl << std::endl << std::endl << std::endl <<
> std::endl;

I must say, I'm truly impressed :)

Cheers,

D. Tenev

gsw...@mailcity.com

unread,
Jun 16, 2005, 4:27:16 AM6/16/05
to
dun...@yahoo.com wrote:
> I am writing a new programming language called 'Triple-Sec':
>
> http://www.geocities.com/dunric/triple.html
>
> Triple-Sec is a simple BASIC-like interpreter with 36 variables
> and 8 non-dimensional strings. Here are the basic commands
> used in Triple-Sec:

I'll say it's an interesting project for you and hope it is proving a
good exercise.

As a language it's far too restricted to be useful (compared to other
freebies) but i don't think it matters!

In time you may find comp.compilers or comp.lang.basic.misc a better
place to target your message

You could also look up the old Moonrock basic and BASM projects as
comprehensive tools for translating a reasonably useful BASIC variant
to assembly, or check out the occasional 'all new' BASIC compiler,
interpreter porject that comes along

Cédric LEMAIRE

unread,
Jun 16, 2005, 4:41:40 AM6/16/05
to
>> std::cout << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl << std::endl << std::endl << std::endl << std::endl <<
>> std::endl;

> I must say, I'm truly impressed :)

Yes I know, It's very ugly! It intends to clear the screen! My lazyness
suggested me to write @repeatString(" << std::endl", 40)@ for
generating the statement, and I wasn't capable to resist.

It isn't the only piece of this code I'm ashamed of, but I wanted to
spend less than 2 hours.

John W. Krahn

unread,
Jun 16, 2005, 6:58:51 AM6/16/05
to
Cédric LEMAIRE wrote:
>>> std::cout << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl << std::endl << std::endl << std::endl << std::endl <<
>>>std::endl;
>
>>I must say, I'm truly impressed :)
>
> Yes I know, It's very ugly! It intends to clear the screen! My lazyness
> suggested me to write @repeatString(" << std::endl", 40)@ for
> generating the statement, and I wasn't capable to resist.

You only have 40 lines?

$ echo $LINES
56


John
--
use Perl;
program
fulfillment

Cédric LEMAIRE

unread,
Jun 16, 2005, 8:31:09 AM6/16/05
to
> You only have 40 lines?

> $ echo $LINES
> 56

No 25, but if it's important for you, I'll think about adding 16
carriage returns more... or 200 if somebody else has more lines (screen
projected on a building wall for instance) and for keeping a margin.

Michael Mattias

unread,
Jun 16, 2005, 9:28:27 AM6/16/05
to
"budgie" <m...@privacy.net> wrote in message
news:rqu2b1pjssrg6u8t5...@4ax.com...

> On 14 Jun 2005 20:33:23 -0700, dun...@yahoo.com wrote:
>
> >I am writing a new programming language called 'Triple-Sec':
>
> (snip)

>
> >Triple-Sec is being coded in PowerBASIC for DOS.
>
> (snip rest)
>
> Maybe I'm alone on this, but I fail to see the point in creating a new
> BASIC-like dialect using another flavour of BASIC ....

Perhaps to serve demand:
-PB/DOS is a compiler.
-New Product is an interpreter.


MCM


Programmer Dude

unread,
Jun 16, 2005, 6:31:04 PM6/16/05
to
budgie writes:

> Maybe I'm alone on this, but I fail to see the point in creating a new
> BASIC-like dialect using another flavour of BASIC ....

Self-education. (The OP is obviously very green.)

Erik de Castro Lopo

unread,
Jun 17, 2005, 4:40:07 AM6/17/05
to

**VERY***

I can't imagine a language more ill suited to writing a language
compiler or interpretter than BASIC.

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nos...@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+

"The power of accurate observation is commonly called cynicism by those
who don't have it." -- George Bernard Shaw

ararghmai...@now.at.arargh.com

unread,
Jun 17, 2005, 6:53:11 AM6/17/05
to
On Fri, 17 Jun 2005 18:40:07 +1000, Erik de Castro Lopo
<nos...@mega-nerd.com> wrote:

<snip>


>I can't imagine a language more ill suited to writing a language
>compiler or interpretter than BASIC.

It's not all that hard, if you know BASIC well enough. BCET is
self-compiling. 2nd URL in Sig.

--
ArarghMail506 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.

Markus Hoffmann

unread,
Jun 17, 2005, 6:24:52 AM6/17/05
to
On Fri, 17 Jun 2005, Erik de Castro Lopo wrote:

> Programmer Dude wrote:
> >
> > budgie writes:
> >
> > > Maybe I'm alone on this, but I fail to see the point in creating a new
> > > BASIC-like dialect using another flavour of BASIC ....
> >
> > Self-education. (The OP is obviously very green.)
>
> **VERY***
>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.

Thats not quite true! X11-Basic p.ex. is partially witten and compiled by
itself. This is a so called boot-strapping approach to writing new
interpreter/compilers.

regards
M.

Steve Rush

unread,
Jun 17, 2005, 8:08:51 AM6/17/05
to
Erik de Castro Lopo wrote:

> Programmer Dude wrote:
>>
>> budgie writes:
>>
>> > Maybe I'm alone on this, but I fail to see the point in creating a new
>> > BASIC-like dialect using another flavour of BASIC ....
>>
>> Self-education. (The OP is obviously very green.)
>
> **VERY***
>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.

Have you seen any of the modern BASIC dialects? No more line numbers,
procedures with local variables, more control structures than Pascal, the
best string handling outside the specialized text-processing languages like
SNOBOL, and a full set of bit-banging operators. Even QuickBasic was
powerful enough to let me translate the Turbo Pascal code in Jack
Crenshaw's "Let's Build a Compiler!" tutorial as I went along, and there
has been considerable development since then (but not at Microsoft).
Google FreeBasic for an up-to-date, cross-platform BASIC compiler that is
used to maintain itself.

Ray Dillinger

unread,
Jun 17, 2005, 11:37:35 AM6/17/05
to

'tis not so much different from the classic introductory
project in various lisps -- writing a lisp interpreter.

Bear

Frisbee®

unread,
Jun 17, 2005, 1:07:56 PM6/17/05
to
"Programmer Dude" <Ch...@Sonnack.com> wrote in message
news:fcv3b1h6lup3u491h...@4ax.com...

Actually, I know Paul from other newsgroups, and I suspect many other
motives. Paul is... let's say unique.


Programmer Dude

unread,
Jun 17, 2005, 2:00:56 PM6/17/05
to
Erik de Castro Lopo writes:

>>> Maybe I'm alone on this, but I fail to see the point in creating a new
>>> BASIC-like dialect using another flavour of BASIC ....
>>
>> Self-education. (The OP is obviously very green.)
>
> **VERY***
>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.

Forth? APL?? COBOL??? LOGO???? :-)

BASIC almost always has native string types and functions (often
built in at a low level) for manipulating them. BASICs can even
just compare two strings usefully.

Ain't the language *I'd* choose, but I can think of worse.

Markku Alén

unread,
Jun 17, 2005, 4:10:49 PM6/17/05
to

"Erik de Castro Lopo" <nos...@mega-nerd.com> kirjoitti
viestissä:42B28C67...@mega-nerd.com...

>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.
>

I disagree. I have written a full C-language compiler entirely with a Visual
Basic. Okey okey, it's not a same thing than writing a compiler with let's
say QBasic. And actually, i only wrote the C-frontend and code generator
with the VB. A maker, an assembler and linker are written in C. But i don't
see why one can't implement a whole compiler toolchain with basic-like
language.

Regards,
Markku Alén


Steve Rush

unread,
Jun 17, 2005, 4:42:26 PM6/17/05
to
Programmer Dude wrote:

>
>> I can't imagine a language more ill suited to writing a language
>> compiler or interpretter than BASIC.
>
> Forth? APL?? COBOL??? LOGO???? :-)
>
> BASIC almost always has native string types and functions (often
> built in at a low level) for manipulating them. BASICs can even
> just compare two strings usefully.

Forth is fairly low-level, which is actually good if you're going to write a
compiler in a language not specifically designed for such. Of course, by
the time you finished, you might have trouble remembering how to speak to
humans.

I can imagine an APL wizard producing a compiler in one gigantic function,
getting it to work, and not even recognizing his own code once the
amphetamines wore off.

Programmers' Purgatory: You have to write and verify an Ada compiler, but
the only compiler you have is Grace Hopper's original COBOL, running on
contemporary punched-cards-and-vaccuum-tubes hardware. In Hell all you
have is LOGO running on an eight-bit TV-output microcomputer that doesn't
have a printer or _any_ mass storage, not even a floppy drive. You need to
save your work? Copy it from the screen by hand before the next power
failure.

ano...@netscape.net

unread,
Jun 17, 2005, 6:47:15 PM6/17/05
to

Steve Rush wrote:
[...snip...]


> In Hell all you
> have is LOGO running on an eight-bit TV-output microcomputer that doesn't
> have a printer or _any_ mass storage, not even a floppy drive. You need to
> save your work? Copy it from the screen by hand before the next power
> failure.

Geez, use a cassette!

Vic Drastik

unread,
Jun 17, 2005, 8:30:36 PM6/17/05
to

"Erik de Castro Lopo" <nos...@mega-nerd.com> wrote in message
news:42B28C67...@mega-nerd.com...

> Programmer Dude wrote:
> > > Maybe I'm alone on this, but I fail to see the point in creating a new
> > > BASIC-like dialect using another flavour of BASIC ....
> > Self-education. (The OP is obviously very green.)
>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.
> Erik


Then your imagination is quite limited. XBasic is entirely written in
XBasic, is free, open-source, GPL and cross-platform (Windows and Linux).
Furthermore, it has both interpreted and compiled modes, is powerful,
elegant and beautiful. I only know 2 languages superior to it as a tool for
expressing algorithms ( APL and J, which are really the same language
anyway). Here is a quine written in XB which uses no numbers and only a
single PRINT statement

DECLARE FUNCTION Q()
FUNCTION Q() STRING
_="_"
__="="
___="\""
____="\n"
_____="\\"
______="n"
_______="DECLARE FUNCTION Q()"
________="FUNCTION Q() STRING"
_________="PRINT
_______;____;________;____;_;__;___;_;___;____;_;_;__;___;__;___;____;_;_;_;
__;___;_____;___;___;____;_;_;_;_;__;___;_____;______;___;____;_;_;_;_;_;__;
___;_____;_____;___;____;_;_;_;_;_;_;__;___;______;___;____;_;_;_;_;_;_;_;__
;___;_______;___;____;_;_;_;_;_;_;_;_;__;___;________;___;____;_;_;_;_;_;_;_
;_;_;__;___;_________;___;____;_;_;_;_;_;_;_;_;_;_;__;___;__________;___;___
_;_________;____;__________"
__________="END FUNCTION"
PRINT
_______;____;________;____;_;__;___;_;___;____;_;_;__;___;__;___;____;_;_;_;
__;___;_____;___;___;____;_;_;_;_;__;___;_____;______;___;____;_;_;_;_;_;__;
___;_____;_____;___;____;_;_;_;_;_;_;__;___;______;___;____;_;_;_;_;_;_;_;__
;___;_______;___;____;_;_;_;_;_;_;_;_;__;___;________;___;____;_;_;_;_;_;_;_
;_;_;__;___;_________;___;____;_;_;_;_;_;_;_;_;_;_;__;___;__________;___;___
_;_________;____;__________
END FUNCTION

Here is yet another nice XB quine

DECLARE FUNCTION Q()
DECLARE FUNCTION P(STRING s)
FUNCTION P(STRING s)
SHARED k
SELECT CASE 4*(k<13)-3*(k<15)+(k<30)-2*(k<43)
CASE 0: PRINT s
CASE 1: PRINT CHR$(80)+CHR$(40)+CHR$(34)+s+CHR$(34)+CHR$(41)
END SELECT
INC k
END FUNCTION
FUNCTION Q()
SHARED k
DO
P("DECLARE FUNCTION Q()")
P("DECLARE FUNCTION P(STRING s)")
P("FUNCTION P(STRING s)")
P("SHARED k")
P("SELECT CASE 4*(k<13)-3*(k<15)+(k<30)-2*(k<43)")
P("CASE 0: PRINT s")
P("CASE 1: PRINT CHR$(80)+CHR$(40)+CHR$(34)+s+CHR$(34)+CHR$(41)")
P("END SELECT")
P("INC k")
P("END FUNCTION")
P("FUNCTION Q()")
P("SHARED k")
P("DO")
P("LOOP UNTIL k>44")
P("END FUNCTION")
LOOP UNTIL k>44
END FUNCTION

Vic


Albert Lai

unread,
Jun 17, 2005, 11:36:25 PM6/17/05
to
budgie <m...@privacy.net> writes:

> Maybe I'm alone on this, but I fail to see the point in creating a new
> BASIC-like dialect using another flavour of BASIC ....

A common criticism to functional programming languages is "the only
major use of ___ is writing a compiler or interpreter for ___".

The purpose of the OP is obviously to bring this criticism to BASIC.

I recommend the OP to write a theorem prover in BASIC as the next
project.


P.S. What has happened to that guy who claimed to write a theorem
prover in Javascript "because it's OO" many years ago? Is he done
yet?

Jon Harrop

unread,
Jun 18, 2005, 12:21:12 AM6/18/05
to
Markku Alén wrote:
> I disagree. I have written a full C-language compiler entirely with a
> Visual Basic. Okey okey, it's not a same thing than writing a compiler
> with let's say QBasic. And actually, i only wrote the C-frontend and code
> generator with the VB. A maker, an assembler and linker are written in C.
> But i don't see why one can't implement a whole compiler toolchain with
> basic-like language.

You can write compilers in BASIC, of course, in just the same way that you
can nail a chicken to your head...

Markku Alén

unread,
Jun 18, 2005, 10:50:40 AM6/18/05
to

"Jon Harrop" <use...@jdh30.plus.com> kirjoitti
viestissä:42b3a17e$0$2050$ed2e...@ptn-nntp-reader04.plus.net...

>
> You can write compilers in BASIC, of course, in just the same way that you
> can nail a chicken to your head...
>

I haven't compromised nothing when wrote the C-compiler in Visual Basic. In
a matter of fact, the Visual Basic gave me a good tools for example managing
a memory and error-conditions. The source code is clean and elegant, no
hacks at all. Then again, the Visual Basic is a bit different than a
"traditional" BASIC.

Today, i could write my C-compiler with the c-language and the
implementation would also be very clean because of memory and error handling
concepts are already designed. But why should i? The VB version works great
and it is a very big source code. Maintaining the source code is a lot
easier in VB than in C.

PS. One, and only one, thing i missed in Visual Basic is an unsigned data
types. That could be tolerable if the Visual Basic's overflow exception
could be disabled.

-- Markku

Torbjörn Lager

unread,
Jun 18, 2005, 11:23:51 AM6/18/05
to
Albert Lai wrote:

> P.S. What has happened to that guy who claimed to write a theorem
> prover in Javascript "because it's OO" many years ago? Is he done
> yet?

Maybe this is it?

http://www.umsu.de/logik/trees/

- Torbjörn

Steve Rush

unread,
Jun 18, 2005, 5:45:58 PM6/18/05
to
Torbjörn Lager wrote:

I was surprised. I didn't think Javascript was Turing - complete. Of
course, it doesn't really take much. Look at the original Turing machine.
_That_ would be a hellish programming job: construct a general theorem
prover as a Turing machine.

Steve Foley

unread,
Jun 20, 2005, 8:19:49 AM6/20/05
to
How about Triple-sec?

"Erik de Castro Lopo" <nos...@mega-nerd.com> wrote in message
news:42B28C67...@mega-nerd.com...

>

William

unread,
Jun 20, 2005, 11:13:31 AM6/20/05
to
"Erik de Castro Lopo" <nos...@mega-nerd.com> wrote in message
news:42B28C67...@mega-nerd.com...

> **VERY***


>
> I can't imagine a language more ill suited to writing a language
> compiler or interpretter than BASIC.

You have no imagination :-)

In the mid-90s I wrote a compiler using QuickBASIC 4.5 that was
faster and friendlier than its C counterpart. (The trick to
efficient BASIC is leveraging the built in commands. For example,
using a substring search command to turn a text token into a
number which can be used for lookups, switch statements, etc.)

It generated a byte code file that was interpreted by a simple
65816 assembly-based interpreter. The compiler handled all the
nasty bits like nested conditionals, expression parsing (with
precedence and parentheses), symbol table, string tokenizing
and compression (recursively removing common strings), etc.

Being BASIC it was dead easy to throw in new features as needed
or requested. (And easy to tighten up the syntax checking
every time someone found a way to break it :-) -Wm


Steve Rush

unread,
Jun 22, 2005, 1:16:46 AM6/22/05
to
On Mon, 20 Jun 2005 10:13:31 -0500, William wrote:

> "Erik de Castro Lopo" <nos...@mega-nerd.com> wrote in message
> news:42B28C67...@mega-nerd.com...
>
>> **VERY***
>>
>> I can't imagine a language more ill suited to writing a language
>> compiler or interpretter than BASIC.
>
> You have no imagination :-)
>
> In the mid-90s I wrote a compiler using QuickBASIC 4.5 that was
> faster and friendlier than its C counterpart. (The trick to
> efficient BASIC is leveraging the built in commands. For example,
> using a substring search command to turn a text token into a
> number which can be used for lookups, switch statements, etc.)

Back in eight-bit days, I wrote some Adventure programs on a TRS-80. I
was amazed at how much faster the INSTR() function worked than any BASIC
search routine I could come up with. I assume that this was the
difference between well-optimized machine code and interpreted BASIC. I
know that Microsoft BASIC doesn't represent strings in memory as trees, as
some newer BASICs do.

I suspect that most of the people bad-mouthing BASIC haven't really looked
at BASIC since the days of line numbers and two-character variable names.

0 new messages