LisaList2

Advanced search  

News:

2022.06.03 added links to LisaList1 and LisaFAQ to the General Category

Pages: [1]   Go Down

Author Topic: Clascal parser for Python  (Read 2424 times)

stepleton

  • Sr. Member
  • ****
  • Karma: +109/-0
  • Online Online
  • Posts: 384
Clascal parser for Python
« on: January 19, 2023, 05:40:04 pm »

I'd mentioned in a separate thread that I'd written a compiler that compiles a Pascal subset to BASIC. This is for a different computing platform, which makes it of limited interest to people here... except that my compiler uses a specific, powerful grammar. You may not be able to compile Clascal with my compiler, but you can parse it!

The reason I chose Pascal for my compiler project is because I'd written a Clascal grammar a couple of years ago and then done nothing with it --- I just had the grammar lying around. I derived it from the railroad diagrams in the Pascal Workshop documentation, along with documentation for the ToolKit on Bitsavers and other material. The grammar makes use of the Lark parsing toolkit for Python, although perhaps it can be translated for other parser generators too.

So if you want to write your own Clascal compiler in Python, this can certainly help you. But even if you don't want to do that, which is understandable, the grammar may still be helpful. If the Lisa source code has inspired you to write some Clascal of your own, then this grammar may be able to demonstrate that your program is free of syntax errors. If you can parse your source code with my grammar, then whatever's wrong with your program is probably something else. (Assuming I didn't leave any bugs in the grammar.)

If you don't develop by typing into the Workshop's source code editor but instead prefer to edit files on a modern computer, this method of syntax checking may save you some time from copying over code that will never compile.

The compiler is here: https://github.com/stepleton/mupas
The grammar files are the ones that start with the letter 'p', and an example of how to invoke it is here. All the rest you can ignore, unless you want to compile code much simpler than Clascal for the BASIC that runs on the Tektronix 4050 series of vector graphics machines.
Logged
Pages: [1]   Go Up