Omnimaga

General Discussion => Technology and Development => Computer Projects and Ideas => Topic started by: Juju on January 11, 2014, 02:57:34 am

Title: A new scripting language for Linux
Post by: Juju on January 11, 2014, 02:57:34 am
So I felt like practicing my C/C++ skills, and I thought, why not writing a programming language? So that's what I did. This one will be heavily based on the TI-BASIC and Axe syntax, but instead of emulating a 96x64 monochrome screen, it'll just output stuff to stdout like nearly every scripting language out there, like Python and Lua. That is, I don't intend fully emulating the TI-83+, but rather adapt it to the Linux operating system.

Right now, it's barely working, not much is implemented outside of numbers, strings, A-Z, Str0-9, Ans, ->, Disp, Input and the fact : behaves like \n.

You can download and compile it here: https://github.com/juju2143/tibasic

It should work for Linux and Mac OS X. For you Windows guys, you can try Cygwin.

And if you like, I'll just throw a bonus (https://github.com/juju2143/flufflepuff) in, that is, 2 languages for the price of one!
Title: Re: A new scripting language for Linux
Post by: Sorunome on January 11, 2014, 05:39:05 am
Wha, that looks pretty interesting!
Are you planning on also adding some way to communicate with X?
Title: Re: A new scripting language for Linux
Post by: blue_bear_94 on January 11, 2014, 12:19:55 pm
What kind of changes did you have to make?
Title: Re: A new scripting language for Linux
Post by: DJ Omnimaga on January 11, 2014, 02:52:55 pm
Seems pretty interesting. Will Axe's pt-on do 16x16 sprites with colors?

Also, will double-buffering be supported like in Axe? It's always useful to prevent flickering.
Title: Re: A new scripting language for Linux
Post by: Juju on January 11, 2014, 06:37:35 pm
There is a graphic library planned (probably kinda like Axe CSE if there was one). It will probably use SDL and use a command to invoke a window.

It'll kinda be the same concept as on the calc with the home screen and the graph screen, the home screen uses command line and if you switch to the graph screen it'll open a graphic window. But, unlike the calc, the window isn't always available.

And of course it will support double buffering.
Title: Re: A new scripting language for Linux
Post by: Sorunome on January 11, 2014, 06:38:48 pm
Yay, are you also planning on doing stuff like buttons, scrollboxes, input boxes etc?
Title: Re: A new scripting language for Linux
Post by: Juju on January 11, 2014, 06:44:22 pm
Yay, are you also planning on doing stuff like buttons, scrollboxes, input boxes etc?
Probably not. You might have to do it yourself with mouse/keyboard input. (getKey/getMouse?)
Title: Re: A new scripting language for Linux
Post by: Sorunome on January 11, 2014, 06:51:15 pm
ah, ok

Also, alpha channel :3
Title: Re: A new scripting language for Linux
Post by: blue_bear_94 on January 11, 2014, 07:12:54 pm
What bothered me in TI-Basic was the limited number of variables. Any plans to increase the limit? (Maybe all numerical variables start with a capital letter, and can be followed by lowercase letters?)
Title: Re: A new scripting language for Linux
Post by: Lunar Fire on January 12, 2014, 12:42:00 am
I cloned your repository, typed make, got an error.
I am running a 64-bit Lubuntu 13.10 Virtual Machine on a 64-bit Windows 7 Ultimate host.

I can give you more info if you need to, but this does not even seem to be related to the hardware configuration I have.

Code: [Select]
tommy@Rainbow-VM:~/Documents/tibasic$ make
bison -d tibasic.y
flex tibasic.l
tibasic.l:16: unrecognized rule
tibasic.l:16: unrecognized rule
tibasic.l:16: unrecognized rule
make: *** [lex.yy.c] Error 1

---

Wha, that looks pretty interesting!
Are you planning on also adding some way to communicate with X?

Communicating with X between multiple instances of a program will require the use of Unix sockets. I could dig in JuJu's code and try to add this functionality, as it will be required to emulate communication between 2 TI calculators. Of course it would require some kind of mechanism to emulation connection and disconnection between the two endpoints, which has to be thought out a bit.

So yes, it is possible but not that simple to implement.
Title: Re: A new scripting language for Linux
Post by: Juju on January 12, 2014, 12:46:19 am
Welp, you're right. I'll check it out.

EDIT: Fixed. Accidental stray character caused it to not compile.
Title: Re: A new scripting language for Linux
Post by: Lunar Fire on January 12, 2014, 01:00:05 am
That bug is the bane of all programmers. It's been a while since I coded anything in C or C++, but that annoying bug did get me everytime.

It has compiled just fine now. Thanks for the quick response.

EDIT: I modified my BrainPuff page to include a link to your github project page, since I noticed you were asking for it but I did not link back to you yet.
Title: Re: A new scripting language for Linux
Post by: DJ Omnimaga on January 12, 2014, 01:08:31 am
That is nothing. Try the HP Prime whitespace bug. I forgot what caused it, but since HP Prime program code is stored in unicode format (UTF-16 I think?), there is more than one character that looks like a space, and copy/pasting code from forums to the connectivity kit or the emulator sometimes cause that code to not compile (Syntax error), even if the code is fine. Often, it's due to wrong whitespaces getting inserted into the code (usually at the end) and a bug in the HP Prime emulator causes error when compiling programs with those spaces. It can be very hard to solve, since they're hard to notice >.<
Title: Re: A new scripting language for Linux
Post by: Juju on January 17, 2014, 08:35:55 pm
UPDATE 6126bb7 (https://github.com/juju2143/tibasic/commit/6126bb7a0a940db0a8b3c80c95234396e37bc608)

- "string->Str1 now works
- File extension is optional (./tibasic prgmA)
- prgm[A-Z][A-Z0-9]{0,7} includes works (save a file as prgmA.tib)
Title: Re: A new scripting language for Linux
Post by: DJ Omnimaga on January 18, 2014, 12:21:53 am
I am really curious if some classic BASIC games will run fine even with no modifications? I remember once I made an Axe program that almost ran identically with no change (except inverted X coordinates).
Title: Re: A new scripting language for Linux
Post by: calcdude84se on January 18, 2014, 09:16:16 pm
I am really curious if some classic BASIC games will run fine even with no modifications? I remember once I made an Axe program that almost ran identically with no change (except inverted X coordinates).
Basically with the PC interpreter acting as a TI-BASIC interpreter? That would be neat. But Juju did say he wouldn't be emulating the calculator screen. (Which is IMO a perfectly reasonable decision. The goal here isn't actually to create TI-BASIC again)
But still, a calculator TI-BASIC compatibility mode could be cool (Even if it means I have to resize my terminal to 16x8 for the homescreen :P)
Title: Re: A new scripting language for Linux
Post by: Lunar Fire on January 18, 2014, 09:35:14 pm
It would be possible to specify a compatibility mode with a command-line switch (like -mode=ti83) to force the use of a 96x64 screen like the calculators had.

Without supporting graph functions for now, it could be cool to emulate a text-only TI-83 screen with ncurses. Would be as simple as setting a 12x8 characters screen with a monospace font (maybe even the TI-83 font).

That project is very interesting and I would like to contribute to it, but for now I don't understand a thing about flex and bison. I'm reading tutorials to learn about the mechanics of those tools but for now I don't get anything. I'll tell you if I ever manage to do something with this.
Title: Re: A new scripting language for Linux
Post by: bb010g on January 18, 2014, 09:37:45 pm
Or just be able to specify color (--color or -c) and screen size (--size or -s) and then have the mode (--mode or -m) do that for flexibility.
Title: Re: A new scripting language for Linux
Post by: Juju on January 27, 2014, 06:44:59 pm
UPDATE:

- Added interactive mode (-i, --interactive).

UPDATE2:

- Added #comments (so shebangs works, try adding #!/usr/bin/tibasic as first line) (also fixed a bug where a newline as beggining of file throws a syntax error)
Title: Re: A new scripting language for Linux
Post by: DJ Omnimaga on January 27, 2014, 11:50:23 pm
I am really curious if some classic BASIC games will run fine even with no modifications? I remember once I made an Axe program that almost ran identically with no change (except inverted X coordinates).
Basically with the PC interpreter acting as a TI-BASIC interpreter? That would be neat. But Juju did say he wouldn't be emulating the calculator screen. (Which is IMO a perfectly reasonable decision. The goal here isn't actually to create TI-BASIC again)
But still, a calculator TI-BASIC compatibility mode could be cool (Even if it means I have to resize my terminal to 16x8 for the homescreen :P)
Oh I didn't meant perfect emulation, but rather making it so that porting BASIC programs using Notepad's Find/Replace only takes like 5-10 minutes instead of having to recode everything from scratch or learning a new language. It's fine if it can't, though.
Title: Re: A new scripting language for Linux
Post by: Juju on January 27, 2014, 11:53:07 pm
My current milestone is to get WFRNG (http://www.ticalc.org/archives/files/fileinfo/139/13964.html) to work without much changes.
Title: Re: A new scripting language for Linux
Post by: Sorunome on January 28, 2014, 12:43:49 am
Why not Reubenquest? :trollface: