just a mindless "branfart"...

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
jakykong
Full Member
Posts:30
Joined:Wed Jun 25, 2003 1:05 pm
just a mindless "branfart"...

Post by jakykong » Wed Sep 22, 2004 8:26 pm

ok i am working on a translator for the first pass of a compiler i am designing. and since Qbasic is by far much easier to deal with strings in than C, even though using qbasic will add one more pass to the compiling routine, i am using it for the sake of ease.

the problem is(and it's a really stupid problem...), i can't remember how to tell where the end of a line in a file is!

unless i have a way to delineate the end of a file(the language is puctuation-free, so there is no way to use the syntax to do so), the first pass of the compiler will not know the difference between a new command and a parameter in a command... HELP!

please note: all i need to do is read a line at a time into a string from a file

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Wed Sep 22, 2004 11:41 pm

LINE INPUT
Returns all characters into a string variable up to a carriage return.

LOF
Give you the length of a file in bytes.

EOF
Returns true if you have reached the end of an open file.

If I understand you correctly, those are what you need. ;)

jakykong
Full Member
Posts:30
Joined:Wed Jun 25, 2003 1:05 pm

Post by jakykong » Thu Sep 23, 2004 6:03 am

yup that pretty much solves the problem.

jakykong
Full Member
Posts:30
Joined:Wed Jun 25, 2003 1:05 pm

Post by jakykong » Thu Sep 23, 2004 6:38 am

well got it done... thanks to you i remembered how to read a line. really was a stupid "brainfart"! i have devided to take a little different path to the compiler. The passes are as follows the way i was going to go about it before:
1: remove REMS and spaces before lines.
2: deal with compiler directives(INCLUDEs)
3: translate to BASIC
4: translate to C
5: translate to ASM
6: assemble

but there are some major efficency flaws in that. For one thing, it was translated to BASIC before it was translated to C. However, the language depends on "spaghetti code" to work with loops and so forth, and C has almost no support for spaghetti code. But i have aready developed a BASIC-C translator, so all i needed was to make it into BASIC to get the rest done. But translating between the multiple levels of programming to get it into machine code took overall about a minute(54.6 seconds to be more exact, i always include a compile time display while developing a compiler) to compile from my language to the machine code. that is a long time! especially since the code in the source file was only about 10 lines long. a simple hello world example in the applications due to *extremely* limited string support. Actually, no string support. you need ASCII to do charactors. i have 2 text functions built into it to put charactors on the screen from a variable. arrays have some support, but are definately limited. Anyway, i have one about changing my logic:
1: translate to BASIC
2: compile using BASIC compiler(bc.exe)

and that will get me to an executable file.

However, i have run onto a problem: i have never once used the bc.exe file directly, and know of no documentation on the topic. So, i need to know one more thing: what is the command line for the bc.exe compiler?

Post Reply