Pascal-S

For works-in-progress. This is the place to upload things that aren't done yet, or tech demos of specific systems or technologies.
Forum rules
This is the only download category to upload works in progress of your application or game.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Pascal-S

Post by yock1960 »

Version 1.0 now posted in Development Tools.
p-compile.jpg
p-compile.jpg (176.37 KiB) Viewed 37931 times
Last edited by yock1960 on Mon Jun 03, 2024 10:14 pm, edited 12 times in total.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Pascal-S

Post 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 37870 times
User avatar
desertfish
Posts: 1096
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Pascal-S

Post 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:
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Pascal-S

Post 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.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Pascal-S

Post 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?
User avatar
ahenry3068
Posts: 1136
Joined: Tue Apr 04, 2023 9:57 pm

Re: Pascal-S

Post 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.
User avatar
ahenry3068
Posts: 1136
Joined: Tue Apr 04, 2023 9:57 pm

Re: Pascal-S

Post 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.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Pascal-S

Post 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.
BruceRMcF
Posts: 224
Joined: Sat Jan 07, 2023 10:33 pm

Re: Pascal-S

Post 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.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Pascal-S

Post 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 362 times
Post Reply