![]() |
Any way to to include command line options into the code? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Any way to to include command line options into the code? (/showthread.php?tid=246) |
Any way to to include command line options into the code? - programandala.net - 06-16-2010 Is there any compiler directive to include command line options into the source? I've looked in the docs and in the forum, and found some mentions about "#pragma", but nothing clear. I always include the following comment at the top of my source Code: ' Compile with the following command: Code: #option tap Code: #options tap strict-bool Then all programs could be compiled just with zxb.py program.bas. Of course, the actual command line options would have higher priority than those in the source. Re: Any way to to include command line options into the code? - boriel - 06-16-2010 The are called #pragmas (this is a standard compiler feature on most compilers). Instead of using #option, use #pragma option. Unfortunately, YES, this is very undocumented. See how library/*.bas uses them. The reason they're undocumented is because they're being worked on and refactored at the moment. A brief explanation follows: To change any option use Code: #pragma option <optionName>=Value Example: Disabling case-sensitive identifiers: Code: #pragma option case_insensitive = TRUE Code: #pragma push(case_insensitive) The above technique is used in many library/*.bas files to make some functions case insensitive. For example, POINT and SCREEN$ functions came with Sinclair BASIC and they must be case insensitive. So saving the case_insensitive option temporarily we won't interfere with user's options status ![]() The options list grows almost day by day. But here are the most common and useful of them (at the moment), 'NAME', type, default value:
Re: Any way to to include command line options into the code? - programandala.net - 06-16-2010 Thank you. I'll try to document all this a bit in the wiki, using your message. boriel Wrote:The options list grows almost day by day. But here are the most common and useful of them (at the moment), 'NAME', type, default value: I blindly tried the following: Code: #pragma option tap = TRUE ...just to confirm no one is yet implemented. Do you plan to implement a #pragma alternative for every command line option? Re: Any way to to include command line options into the code? - boriel - 06-16-2010 Quote:Yes, of course. Note, "tap" won't be possible, but "outputFormat" instead, which must be one of ('tap', 'tzx', 'asm', 'bin', 'ic'). Update: IC stands for "Intermediate Code". Use -e to generate it (ASCII source) and see what happens. ZXB is a *compiler toolkit* so any other high-level language that compiles into IC could be also used. I tell you this because I've noticed you're very interested in Forth. Creating a High Level Compiler that produces IC code should be not very difficult, and you could integrate Forth into the ZX Basic compiler. That is, zxf could be a main executable that later integrates the rest of the modules and libraries this toolkit uses. |