aldweb

Fermer I. aldweb

Fermer II. Gratuitiels PC

Fermer III. Gratuitiels Palm

Fermer IV. Partagiciels Palm

Fermer V. iziBasic Palm

Fermer VI. Connaissance Palm

Fermer VII. Ordinateur Poche

Fermer VIII. miniPortail

Spécial !



Version mobile
de l'aldweb Site

m.aldweb.com


Ni Français, ni Anglais ?

Essayez donc l'un de ces drapeaux :
[de] [es] [it] [pt]
Recherche




Météo / Spam / www

Météo Lyon


aldweb contre le SPAM


Newsletter
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
298 Abonnés
Sites web de la famille

Webmaster - Infos
News Amis
Visites

   visiteurs

   visiteurs en ligne

Sondage
Comment trouve-tu le nouvel habillage de l'aldweb Site ?
 
Superbe !
Joli
Moyen
Moche...
Résultats
forum.gifForum - iziBasic - Sujet n°1466

Forum - Forum
iziBasic - iziBasic


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257

actif  Sujet n° 1466  wish - improving the parser a bit

le 19/10/2006 @ 09:44
par Dave O\'Brien

Anonyme



I realize that iziBasic may never have a parser as sophisticated as desktop implementations, but I'd like to suggest a few improvements that should simplify programming for everyone (except aldweb, of course ;)


SELECT CASE variable arguments:

The SELECT CASE statement doesn't seem to accept variables for the individual cases. For example, it throws a syntax error for "foobar" below:

SELECT CASE %c1%
CASE -1
UPDATETEXT #%counter%, "*"
CASE %foobar%
UPDATETEXT #%counter%, "f"
(etc.)

...which means I have to replace %foobar% with a literal value, which makes my program break if I ever change the value of %foobar% elsewhere.


Referencing arrays in IF statements:

I just started using the built-in array A(n), but ran into puzzling syntax errors with this code:

FOR %counter% = 1 TO 100
IF a(%counter%) = 0 THEN
' do something
ENDIF
NEXT

Turns out that it didn't like an array reference in the IF statement. I had to copy the array reference to a non-array variable (e.g. %foobar%) and then test %foobar%. That makes the code a bit awkward.

Hey, while I'm wishing, there's always multi-dimensional arrays. I'd be very happy to be able to write a(x,y) for the mine-sweeper game I'm working on.

Hey, it's Christmas soon, right? ;D
  Poster une réponse  Haut

[]   


Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1
--------
le 19/10/2006 @ 18:50
par aldweb

Anonyme

visiteur
Hello Dave,

All suggestions are highly appreciated. I got so much used to using iziBasic as it is that I sometimes/often need to be told back its limits!

The SELECT CASE statement doesn't seem to accept variables for the individual cases.
No, indeed it does not.
This is a good suggestion, I don't remember why SELECT is restricted this way. I'll have to give a look back to this part of the compiler.
You may nevertheless use imbricated IFs for solving this issue (but the code is not so nice looking as with a SELECT sequence).

Referencing arrays in IF statements
... and all other statements as well should I add!
This is because I chose to implement arrays like functions, and functions cannot be put in statements other than the LET statement (itself being facultative) in iziBasic. This was much quicker to develop for me...

Hey, while I'm wishing, there's always multi-dimensional arrays.
I know, this would really avoid translating indexes in a 1 dimension array, which is a pain I have to acknowledge it!

Hey, it's Christmas soon, right?
Do you still believe in Santa Claus?

Cheers,
aldweb
Ecrire à aldweb   Poster une réponse  Haut

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2
--------
le 19/10/2006 @ 18:57
par aldweb

Anonyme

visiteur
improving the parser a bit

To be very honest with you, it would not only be a bit of improvement dear Dave!
At this stage, I would have to hack it so much to have your requests implemented that it would maybe be much wiser to redesign it from scratch with all the learnings I got from this experience of developping my first real compiler parser.
This is something that has been in my head for one year now...

Cheers,
aldweb
Ecrire à aldweb   Poster une réponse  Haut

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 3
--------
le 19/10/2006 @ 20:38
par Dave O\'Brien

Anonyme

visiteur
Yes, I figured these improvements might be non-trivial, esp. the arrays.

I wonder if there are open-source parsers that you could examine or even borrow code from? That might save some effort and be quite educational too. I never had the courage to take a compiler course myself, mind you. :^)
  Poster une réponse  Haut

Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 4
--------
le 20/10/2006 @ 17:19
par aldweb

Anonyme

visiteur
Hello Dave,

I did not examine in depth some open-source parser. Programming is a hobby for me and I love to find by myself some algorythms. I had no compiler course either, developing a byte-code compiler was a great challenge for me, and this is why I really wanted when starting this iziBasic project from scratch.
Copy & Paste is another thing... maybe a job?


Now, to come back to your original requests, here are the workarounds for them.


SELECT CASE variable arguments
IF %c1% = - 1 THEN
' do something
ELSE IF %c1% = %foobar% THEN
' do something
ELSE IF (etc.)
' do something
ENDIF
ENDIF
ENDIF (whatever the number required)



Referencing arrays in IF statements
FOR %counter% = 1 TO 100
b=a(%counter%) : IF b = 0 THEN
' do something
ENDIF
NEXT



multi-dimensional arrays
Here the principle is to use the trick of translating a multi-dimensional array to a mono-dimensional array.
Then, use the provided Dim2.iBas include file provided in the iziBasic package. And code something like:
' IBDim2.iBas

' IBDim2 is a simple application
' to show how to deal with 2
' dimensions arrays in iziBasic,
' like Array(10,5), when iziBasic
' "only" offers access to the A(n)
' array (1 dimension).

{CREATORID "LDTE"}
{VERSION "1.0"}
{PARSER ON}

{INCLUDE "Dim2.iBas"}

BEGIN
'Store some values in A(10,5)
FOR I=1 TO 10
FOR J=1 TO 5
V=(RND(I)+1)*(RND(J)+1)
GOSUB _PutInArray 'A(I,J)=V
NEXT
NEXT
'Retrieve and show values in A(10,5)
FOR I=1 TO 10
FOR J=1 TO 5
GOSUB _GetFromArray 'V=A(I,J)
PRINT V USING 0;
PRINT " ";
NEXT
PRINT
NEXT
WAIT
END



These are only workarounds while waiting for a potential Christmas gift. But they still get the required job done!


Cheers,
aldweb
Ecrire à aldweb   Poster une réponse  Haut
actif sujet actif   clos sujet clos   Important! Important!   Nouveau Nouveau message   -   Rectifier Rectifier message   Clôturer Clôturer sujet   Remonter Remonter
[]
Catégories de discussion  Forum 



 
^ Haut ^