|
Post by vovchik on Nov 30, 2014 16:47:06 GMT 1
Dear Alex, That latest pic looks really im-pressive. My m4ide doesn't want to open any file. It shows the GUI and the file selector but nothing loads. With kind regards, vovchik
|
|
|
Post by alexfish on Nov 30, 2014 18:06:11 GMT 1
Hi Vovchik did U try the 32 bit Exec page1BR Alex can try this also but this is two step away as regards complete RE need to add extra compile button/+set sizes of hence hot off the press; BR Alex Attachments:m4ide.c.tar.bz2 (5.45 KB)
|
|
|
Post by vovchik on Nov 30, 2014 18:57:26 GMT 1
Dear Alex, Nothing seems to open files, except your first brasic, which worked fine for me. The IDE posted above compiles and shows, but nothing loads (i.e. source). With kind regards, vovchik
|
|
|
Post by alexfish on Dec 1, 2014 18:20:50 GMT 1
@ Peter
Have took a closer look at the FOR NEXT LOOP in M4BASIC
define(FOR,`_FC undefine(`TO') define(TO,`undefine(`STEP') define(STEP,`divert(-1) undivert(5) divert(5)') divert(3))') divert(5)1 divert(6)){ divert(1)for( divert(2)_FA(') define(_FA,`$1;divert(4);substr($1,0,index($1,=))+= divert(3)substr($1,0,index($1,=))<=')
I think possible the for next loop can only increment
My interpretation for part of the the _FA looks like
this will increment and decrement
BR Alex
|
|
|
Post by Pjot on Dec 1, 2014 21:10:48 GMT 1
Thanks Alex,
How do you propose the final M4 macro for FOR/NEXT? If you can improve it, I'll be happy to add it (with your credentials of course).
BR Peter
|
|
|
Post by alexfish on Dec 1, 2014 22:48:14 GMT 1
Thanks Alex, How do you propose the final M4 macro for FOR/NEXT? If you can improve it, I'll be happy to add it (with your credentials of course). BR Peter Hi Peter still on the bits , in part stuck , but only in Time , Time = possible get there soon.. rather it be sooner. the could be if the $1 as in your $1 in the FOR could be the whole parenthesis IE the bits between the () for uninitiated . the present for $1 = "x=y" , now if all could be passed at present the code now looks like this , as mentioned still working on this..here taking the parenthesis as c look + here only looking for the less than or greater than. also as said still working on it , now need to see where U been pushing the bits define(FOR,`_FC for( ifelse(eval(( eval(substr($1,eval( 4+ index($1,STEP)),len($1))))<0),1,>=,<=) ') the code needs to be something like FOR(S = 50 TO 1 STEP -1) FOR(S = 1 TO 50 STEP 1)
the output give the actual code with the append GT or LT @alexfish:~/Desktop/M4IDE/examples$ m4 ./testm4.m4 test for( >= for( <=
Credentials , pint of free beer will do. Br Alex just changed to give the actual bit ; from this should be able to place the GT $ LT.
|
|
|
Post by alexfish on Dec 1, 2014 23:14:34 GMT 1
@ Peter
whilst here this what has been done to the original code to get working out of main if required,
although to do so , have to have the include , this is implemented in the IDE , but should also work in terminal mode
it should not throw any errors. or throw the output off course .
BR Alex
define(SINCLUDE,`_FC sinclude($1)') define(INCLUDE,`_FC #include') divert(0)dnl #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <math.h> #include <time.h> #include <sys/ioctl.h> #include <gc.h> #define _MEMTYPE char #define _maxdigit 32 #define _bufsize 256
int RETVAL; unsigned char _ptr = 0; char *_sbuf[256] = { NULL }; sinclude(includes.m4) divert(0)dnl int main(int argc, char* argv[]){
GC_INIT(); srandom((unsigned int)time(NULL)); m4wrap(`_FC return(0);}')dnl
|
|
|
Post by alexfish on Dec 2, 2014 3:53:20 GMT 1
Just an update on unwinding the never ending piece of string For loop
manage to complete the long hand macro of a for loop within parenthesis as in ($1)
the macro's For and next "testm4.m4"
define(_FC,`divert undivert') define(FOR,`_FC for( substr($1,0,index($1,TO)) ;substr($1,0,index($1,=)) ifelse(eval(( eval(substr($1,eval( 4+ index($1,STEP)),len($1))))<0),1,>=,<=) substr($1,eval(2+index($1,TO)),eval(eval(index($1,STEP) eval( - eval(2+index($1,TO))) ) )) ; substr($1,0,index($1,=))+= substr($1,eval( 4+ index($1,STEP)), eval( len($1)eval(- eval( 4+ index($1,STEP) )))) ){ ') define(NEXT,`_FC } divert(-1)')
the file for testing "test"
FOR(S = 10 TO 1 STEP -1)
NEXT
FOR(S = 1 TO 10 STEP 1)
NEXT
run from terminal if do not have indent installed delete the ' | indent '
m4 ./testm4.m4 test | indent
output should be
m4 ./testm4.m4 test | indent for (S = 10; S >= 1; S += -1) {
}
for (S = 1; S <= 10; S += 1) {
} now looking at option's as to , get it working without brackets... flex was easier.. BR Alex
|
|
|
Post by Pjot on Dec 2, 2014 21:03:53 GMT 1
Hi Alex, I bet that was! The M4 macro language really needs some twists in our minds. The FOR/NEXT construct took me longest to get right by the way... And for the pint of free beer - you're on! Cheers Peter
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 2, 2014 21:48:16 GMT 1
This reminds me of my C BASIC effort using #defines. When using the BASIC like C syntax and using gcc -E to expand, it looked like Alex's example. C BASIC was an effort to create a transitional helper language front end to C. As one became more comfortable with the C language, the C BASIC syntax can be replaced with standard C. BaCon could have filled that role if the generated output was readable and dead code removal in place. At one point I was going to fork some of BaCon's runtime functions for C BASIC. I abandoned the effort as BaCon kept on expanding it's dependences making the effort not worth doing. I mentioned this as the BaCon code I converted to C BASIC is a good example of what I personally would like to see BaCon generate in C BASIC code. Bitbucket C BASIConized BaCon Examples
|
|
|
Post by alexfish on Dec 3, 2014 12:27:17 GMT 1
Hi Peter Hi Alex, I bet that was! The M4 macro language really needs some twists in our minds. The FOR/NEXT construct took me longest to get right by the way... And for the pint of free beer - you're on! Cheers Peter To True... After playing with some of the bits last night , M4 . Conclusion LSD + Mushrooms , and Very Addictive , to get of them the Free Beer may go up to Wine.. anyway this is just an update of where I be sitting with the M4Basic for loop , now need to push the bits where "x=X" think one can also have some fun with this bit of code BR Alex can save the code the just run it from the terminal IE : m4 test Have Fun the code define(N,1)dnl define(xvar,`XVAR')dnl define(FOR, `for( ')dnl define(TO,` ; xvar LE X STEP xvar += N ) {X=')dnl define(STEP, `;')dnl define(LE, `<=')dnl define(GT, `>=')dnl define(NEXT,`}')dnl define(XVAR,`int')
dnl define the variable just like c define(int,`s')
dnl Simple for itererates to c FOR s = 1 TO 20 // rest of code here NEXT
define(int,`a')
FOR t = 1 TO 200 //Rest of Code here NEXT
define(int,`b') FOR b = 1 TO X //Rest of Code here NEXT
define(int,`c') FOR c = 1 TO 300 //Rest of Code here NEXT
define(int,`d') FOR d = 30 TO LE 200 //Rest of Code here NEXT define(int,`e') FOR e = 30 TO GT 200 //Rest of Code here NEXT
define(int,`f') FOR f = 400 TO >= 1 //Rest of Code here NEXT
results should be Update Have managed to intercept the TO >> as in $0 without infinite loop , the terminal will show TO at $1 rest define(N,1)dnl define(xvar,`XVAR') define(FOR, `for( ')dnl define(TO,` ; xvar LE X STEP xvar += N $0rest) {X=')dnl define(STEP, `;')dnl define(LE, `<=')dnl define(GT, `>=')dnl define(NEXT,`}')dnl define(XVAR,`int')dnl still on going
|
|
|
Post by Pjot on Dec 3, 2014 12:29:34 GMT 1
This never has been the intention of BaCon in the first place (and never will for that matter).
And a small correctional note: since release 3.x BaCon uses an external static library to include only those functions which are needed by the target program.
BR Peter
|
|
|
Post by alexfish on Dec 4, 2014 14:26:53 GMT 1
Hi Alex, I bet that was! The M4 macro language really needs some twists in our minds. The FOR/NEXT construct took me longest to get right by the way... And for the pint of free beer - you're on! Cheers Peter Re Quote:: think have found the necessary bits Re M4. Also since this is also just an update on progress the free beer is on for now.. , obvious if fail then no free beer. BR Alex
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Dec 4, 2014 20:48:11 GMT 1
BaCon does a very good job for what it was designed to do. You should be very proud of your accomplishment! Making BaCon is no small task.
|
|
|
Post by alexfish on Dec 5, 2014 8:26:49 GMT 1
Peter' this is the first solution to the First post regarding for next loop within parenthesis ($) IE , would try without the brackets. Now looking to look at some err checking + possible at some C like functionality to same' Have Fun + Cheers' Alex Solution 2:: as it stand of now. 'updated' the specific part which need to be improved on is "ifelse(eval(( eval(substr($@,eval(4+ index($@,STEP)),len($@)))) <0),1,>=,<=)" at present can not detect a named var , so rule = step must be numerical , auto update if var has failed; hence the improve on: define(FOR,`_FC pushdef(`_FC') popdef(`_FC') ') _FA(') define(_FA,` for(substr($@,0,eval(index(`$@',`TO')-2)) ; substr($@,0,index($@,=)) ifelse(eval(( eval(substr($@,eval(4+ index($@,STEP)),len($@))))<0),1,>=,<=) substr($@,eval(2+index($@,TO)),eval(eval(index($@,STEP) eval(-eval(2+index($@,TO)))))) ; substr($@,0,index($@,=))+=substr($@,eval( 4+ index($@,STEP)),eval(len($@)eval(- eval( 4+ index($@,STEP))))) ){')
test code FOR t = 1 TO 100 STEP +1
NEXT
FOR t = 100 TO 1 STEP -1
NEXT
Results the code looks quite resilient, FOR t = 1 TO 100 STEP 1 PRINT "PPP" NEXT
|
|