Page 1 of 4

Pascal-S

Posted: Fri Jan 12, 2024 10:56 pm
by yock1960
Version 1.0 now posted in Development Tools.
p-compile.jpg
p-compile.jpg (176.37 KiB) Viewed 37980 times

Re: Pascal-S

Posted: Sat Jan 13, 2024 10:24 pm
by yock1960
For anyone trying this and having problems, today I discovered a bug, but one that occurs for unknown reasons, which I haven't figured out. What will happen is that the compiler will parse the source text, apparently completely, but then just sit there. It appears to hang on the terminating 'end.', adding another 'end.' appears to fix it. I spent a number of hours trying to figure out why it happens, without success. As I say, it doesn't always happen, but if you see these symptoms and don't find any other 'syntax' errors, try adding a second 'end.'.

Also, the interpreter executes the program and when the program is finished, the interpreter exits, so you need a readln(); or forever loop at the end of your code, to see the results.
snippet.jpg
snippet.jpg (46.72 KiB) Viewed 37919 times

Re: Pascal-S

Posted: Sat Jan 13, 2024 11:41 pm
by desertfish
Even with the limitations and remaining bugs, I applaud you for getting this far. I'm thoroughly amazed that you managed to use Prog8 to write a compiler for Pascal and get it more or less working. :shock:

Re: Pascal-S

Posted: Sun Jan 14, 2024 10:17 pm
by yock1960
Thanks Desertfish! I'm sure someone more knowledgeable could do a better job, but it's an interesting project! Not completely understanding the code is a big hindrance! I know more now, than at the start, but....I'm probably not detail oriented enough to really nail it down. Prog8 is very capable and well supported!

I have a fix...for the previous issue and will post an update soon.

Re: Pascal-S

Posted: Mon Jan 15, 2024 8:31 pm
by yock1960
I was hoping to have remarks working, but it continues to evade me. Here is a new updated version (in original post) , some fixes and enhancements. A few new 'standard functions' added to make all of the 'non' Pascal standard function/procedures:

Call - call a kernal routine
Clear - clear text screen
Rand - return a random number between 0-255

A few new examples to demonstrate the new function/procedures.

Here's a minor question. I made write/writeln use the double quote instead of the single quote, since that's the 'norm' for the Commodore lineage, should I change it to use single quotes?

Re: Pascal-S

Posted: Tue Jan 16, 2024 2:15 am
by ahenry3068
yock1960 wrote: Mon Jan 15, 2024 8:31 pm I was hoping to have remarks working, but it continues to evade me. Here is a new updated version (in original post) , some fixes and enhancements. A few new 'standard functions' added to make all of the 'non' Pascal standard function/procedures:

Call - call a kernal routine
Clear - clear text screen
Rand - return a random number between 0-255

A few new examples to demonstrate the new function/procedures.

Here's a minor question. I made write/writeln use the double quote instead of the single quote, since that's the 'norm' for the Commodore lineage, should I change it to use single quotes?
Long time Pascal programmer here. Pretty new to the "Commodore" way of doing things. My introduction to things Commodore IS the X16. That being said. Pascal has always been single quotes for string literals in any implementation I have seen.

Re: Pascal-S

Posted: Tue Jan 16, 2024 2:17 am
by ahenry3068
Also GotoXY is NOT a standard Pascal function in the ISO sense. But it feels like a standard function to anyone coming from Turbo Pascal. Should be a rather simple implementation. Just pass the parameters to the ROM Plot routine.

Re: Pascal-S

Posted: Tue Jan 16, 2024 8:39 pm
by yock1960
ahenry3068 wrote: Tue Jan 16, 2024 2:17 am Also GotoXY is NOT a standard Pascal function in the ISO sense. But it feels like a standard function to anyone coming from Turbo Pascal. Should be a rather simple implementation. Just pass the parameters to the ROM Plot routine.
If I can figure out how to get multiple parameters 'coded' in the compiler, I'll add this. It's certainly accounted for in the compiler, since read(ln)/write(ln) handle multiple parameters, but so far I've only added stuff with either 0 or 1 parameters.

I guess I should dive into the Turbo Pascal book that I have to see what symbols or words they use for bitwise operations, since that's what I'm about to try to add.

This certainly won't adhere to any ISO standards, but I'll try to behave if I can.

Re: Pascal-S

Posted: Wed Jan 17, 2024 3:45 am
by BruceRMcF
ahenry3068 wrote: Tue Jan 16, 2024 2:15 am
yock1960 wrote: Mon Jan 15, 2024 8:31 pm I was hoping to have remarks working, but it continues to evade me. Here is a new updated version (in original post) , some fixes and enhancements. A few new 'standard functions' added to make all of the 'non' Pascal standard function/procedures:

Call - call a kernal routine
Clear - clear text screen
Rand - return a random number between 0-255

A few new examples to demonstrate the new function/procedures.

Here's a minor question. I made write/writeln use the double quote instead of the single quote, since that's the 'norm' for the Commodore lineage, should I change it to use single quotes?
Long time Pascal programmer here. Pretty new to the "Commodore" way of doing things. My introduction to things Commodore IS the X16. That being said. Pascal has always been single quotes for string literals in any implementation I have seen.
The three C64 Pascal's that I have seen manual's for all use single quotes, so I'd stick with single quotes. When you see things to type in with double quotes, and look closer, that is always using Basic to load and run programs or to manage files, not Pascal source.

Re: Pascal-S

Posted: Wed Jan 17, 2024 11:02 pm
by yock1960
Here is the latest build of Pascal-S. I have added the keyword/command 'GOTOXY', which will enable positioning the text cursor for text output. I also changed from double quotes to single quotes inside writeln. Additionally, I added being able to perform bitwise 'and' using the & symbol. I think that Turbo Pascal used 'and' for both boolean and bitwise operations, but this was the easiest path for me. I will be adding or,xor, and shifts. I will use SHR and SHL for the shifts. I have included a program that showcases these new features.

Updated p-compile.prg and p-interpret.prg are in the .zipfile in the post at top.

AUTOMAT8.zip
(1.2 KiB) Downloaded 371 times