Re: [Oopic-compiler-devel] Compiler design
Status: Planning
Brought to you by:
ndurant
From: Neil D. <nd...@us...> - 2004-05-12 01:49:43
|
D. Daniel McGlothin wrote: > A couple of quick thoughts. > > 1. lack of support for the three syntax styles Savage implemented is > probably a non-starter (unless we have the IDE selecting between the OOpicMK > compiler and this one). As it is now, the user must specify the syntax; we > can require the same as a command line. Or possibly use a token in the > sourcecode similar to what Parallax did with their new PBasic syntax and the > firmware revisions, and let the preprocessor pick it out. Agreed. We could also have the syntax selected implicitly based on the file extension. There's no reason why we need to stick with .osc file extensions - we could use .c, .bas, .java or whatever. Or perhaps a combination - if it's explicitly specified on the command line, use that, if not then check for a token in the source, and failing that use the file extension. And failing that, assume it's C! > 2. After those, the grammer for an (or many) arbitrary syntax could be > defined. > > 3. In all cases, the compiler tools yield a similar internal representation > that is subjected to code generation and optimization. Agreed. Many compilers that support multiple input languages (eg gcc) separate the internal representation generation from the code generation and optimisation, and I think it would be wise for us to do the same. I think C, BASIC and Java are similar enough to allow identical internal representation. We would effectively have a number of different "front ends" that convert input code into an internal structure. > For the original scripts' syntax, should we generate identical code to > the OOpicMK or use our own? I'm not sure I understand what you mean (it's 2.44am here - brain fade!) > 4. Does the grammer specification require some (or deep) knowledge of the > possible syntactical structures the native byte-codes would permit? If so, > then I should get some more work done. I don't think so - the grammar specification should be pretty much like the standard C grammar (for C language support) which we can obtain from C syntax documents in various places. The format Flex/Bison take is very similar to the syntax used in syntax standards documents, so it should be fairly straightforward to implement a full C parser. For BASIC and Java I guess we just play it by ear...! My understanding is that the grammar specification should be fairly well isolated from the native byte-code. The byte code looks sufficiently low-level to be flexible. We know it's possible to implement the current OOPIC scripting language constructs in OOPIC byte code, after all. Perhaps we'll discover things that are hard or even impossible to implement in byte code, but we may only find out when we try.... Neil -- Neil Durant <nd...@us...> |