April 23, 2024, 01:13:08 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Syntax discussion

Started by Ionic Wind Support Team, October 24, 2005, 04:24:48 PM

Previous topic - Next topic

0 Members and 14 Guests are viewing this topic.

Ionic Wind Support Team

October 24, 2005, 04:24:48 PM Last Edit: October 24, 2005, 06:05:49 PM by Ionic Wizard
Aurora is still in its infancy, but supports a syntax similar to C with higher level concepts.

Example syntax:

#typedef uint unsigned int;
#typedef pointer uint;

a=100;
while a > 0
{
a--;
}

uint b;
b = 0xffff;

do
{
b++;
}until b=0xffff00ff;

a = rnd(3);
select a
{
case 0:
b=88;
case 1:
b=99;
case 2:
b=111;
}


Ionic Wind Support Team

Ionic Wind Support Team

The design of the IF statement slightly differs from either C or BASIC.  THEN has been eliminated and since lines are terminated with the ';' character a single line IF can be split up.  For example:


IF (a > 100) b=2 else b=3;

IF (a > 100)
    b=2
else
    b=3;


The parenthesis are optional and are included for readability.  The compiler also accepts:


IF a > 100
   b=2
ELSE
   b=3;


The important thing to remember when using a single line IF statement is that the semicolon marks the end of the line in Aurora instead of a newline character like in BASIC. 

A structured IF statement uses brackets


IF a > 100
{
     b=2;
     c="cat";
}
ELSE
{
     b=3;
     c="dog";
}


Ionic Wind Support Team

Vikki

Looking good. Actually looks pretty cool!  ;) I like the semi colon termination

Ionic Wind Support Team

The semicolon is used in a lot of languages.  The biggest problem with BASIC like languages is the reliance on the newline character as a line terminator.  Which makes it hard to parse, and hard to continue a statement on separate text editor lines.

Aurora supports the same array loading as IBasic did, and the difference is obvious:


int a[20];
a= 1,2,3,4,5,
   6,7,8,9,10,
   11,12,13,14,15,
   16,17,18,19,20;


Ionic Wind Support Team

Vikki

Yes, that is nice. It is also a better visual marker for us programming challenged types. :)

Ionic Wind Support Team

Feel free to post any suggestions.  Things you would like to see in the core language, etc.

Ionic Wind Support Team

Vikki

I'll put my thinking cap on right now. This will be fun. :)

Ionic Wind Support Team

OK.  Got IF working the way I wanted finally.  Parsing all of the variations of IF was a pain  :o  I wanted to be able to combine a single line ELSE with an IF block like you can in C....took a bit of convincing the lexer that '}else{' and '}else statement' were different tokens, along with allowing all of the variations of newlines and such.  Anyway this parses now and creates correct assembly code.


a=1;
if a
{
b=2;
if b=2
{
d=6;
}
}
else
{
b=3;
c=5.0;
}

if b
{
x = 1+1;
z = x;
}
else
y=11;


The code font on these forums are a bit small...wonder if I can changer that ?

Ionic Wind Support Team

Vikki

Cool on the IF statements.

Don't know on the size of the code sections.

Will Aurora have oo you know like classes and objects? Or are we going to be more closely tied to C?

Ionic Wind Support Team

Yes we will have objects.  But you won't need to use them and can still program top down if you wish.

Still struggling with one more aspect of the IF statement.  Want to allow "else if" constructs without needing to terminate each IF with a closing brace.

Almost working as I can do this now:

if something
{
}
else if somethingelse
...
else if something more
...

Paul.
Ionic Wind Support Team

Vikki

How about having the else if as elseif?

How will we create windows and things? Will it be similar to IB or will we be using more of a C type syntax for that? i.e.,

void main(args...)
{
...
}

Still thinking about more things too...

Ionic Wind Support Team

Not as complicated as C but you will need a main function.  Haven't finalized the syntax of function defintions yet.  We can call it whatever we want though.  Like 'start'

start(numargs as int, arglist as string[]),int
{
}

We can use libraries of functions for easy creation of windows. 

#include "aurorawin.inc"
WINDOW win;
OpenWindow(win,....);

To maintain cross platform code I would need to create a similar library on Linux that glues to GTK (Linux API for dealing with GUI stuff).

But you won't need to be tied down to it, or even use it.  On windows you can have an API include file and just use it like C

#include "windows.inc"
HWND mywin;
mywin = CreateWindowEx(...

Your program wouldn't compile on the linux version though.  Still many wouldn't care anyway.

Paul.



Ionic Wind Support Team

Ionic Wind Support Team

OK,  Finalized my ELSE syntax.  Keeping the distinction of a single instruction ELSE while allowing ELSE IF.

For example there are cases where you need to use a 'block' else.


if 1
{
x = 1+1;
z = x;
}
else if 2 {
y=11;
}
else
while (a<12){ y--;a++;}



Will generate an error on the 'while' since it is not a single statement.  Informing you to use a 'block' else. Like so:


if 1
{
x = 1+1;
z = x;
}
else if 2 {
y=11;
}
else
{
while (a<12){ y--;a++;}
}


C allows the first form which can be confusing to read.  And I am just tired of working on ELSE contexts. ;)  Maybe I'll go back to it later. 

Paul.

Ionic Wind Support Team

Vikki


Ionic Wind Support Team

Getting closer.  We can now create subroutines. 


declare mysub(unsigned int a),unsigned int;
sub mysub(unsigned int a),unsigned int
{
a +=2;
return a;
}


The older AS keyword works too.


declare mysub(a AS unsigned int),unsigned int;
sub mysub(a AS unsigned int),unsigned int
{
a +=2;
return a;
}


The first form is more common and will aid in converting code from other languages.  The second form helps when converting from BASIC languages.  The 'declare' statement is only needed while we are developing and for import libraries.  Once I have a preparser written it will be optional. 

Defining variables has three syntaxes too.

DIM a AS int;
DEF b AS int;
int b;

Look familiar  ;)

Ionic Wind Support Team

Vikki


Steven Picard

Okay, I like where you're going with the language.  The funny thing was, before I got on the forum I was thinking "I hope Paul makes a new language that is as safe as BASIC (you know what I mean, a newbie can jump in and not worry about garbage collection, they have dynamic arrays, they can be sloppy, etc.) but I would like it to be easier to see some C or C++ code that I like and easily convert it.  I'm not saying I want C+++ or JAVA++, I just want to be able to come across some nice C\C++ code and say "Hey I'd like to convert that over to Aurora, that could be useful" and be able to do that without hitting a brick wall to easily (okay, I just want to be able to lazily convert it over  ;D)

I also like the fact that you are making it cross platform (not just Linux) because I can't give up Windows, that's my bread and butter but I still like Linux.

Steven Picard

BTW, I like the name Aurora.  I hope you keep it.  8)

Ionic Wind Support Team

Yep I'll keep the name.  In fact finished desigining a bunch of icons for it last night.

The syntax was designed for easy porting of code from other languages in mind. 

Paul.
Ionic Wind Support Team

Steven Picard

Sounds good!

I'd like a language that I can whip out a lazy app if I want (like in BASIC) but can use for advanced stuff as well.

What about in-line assembly? If you do have it will you be using NASM or FASM?  Too bad there's no cross plaftform assembly language (at least that I know of.)

Did you see my 1k Assembler on the Pyxia forum?  I know you'll know right away how I did it but I want to see how quickly the guys over there figure it out.

Steven Picard

How difficult would it be to make it work with IBasic Pro command paks? 

Ionic Wind Support Team

NASM is cross platform, which is why I use it.

As for the command paks....depends on which one your talking about.   They are just static libraries after all.

Paul.

Ionic Wind Support Team

Steven Picard

I was primarily thinking about the 3D Pak.  ;D

Steven Picard

...although, I think the 3D Pak is dead.  Tom has shown no interest in it.  Well, at least this language will easily work with external DLL's such as Ogre, etc.

Ionic Wind Support Team

Tom is a strange character.

There is a multitude of good 3D engines out there written by people that know a bit more about it than me.  I prefer to concentrate on the language for now.  I was pushed in a paticular direction with Pro when Idigicon was involved.  A direction that ultimately limited what I could do with the core, syntax, IDE, etc.  Idigicon was more concerned with their image, and making sure no one badmouthed them online, then they were with the actual products.

Ionic Wind Support Team