Talk:Compiler/Simple file inclusion pre processor: Difference between revisions

Two preprocessor tasks
(Two preprocessor tasks)
Line 39:
:::The [[Self-hosting compiler]] task is a much harder, language specific task - it doesn't for example, say write a C compiler in your language. The [[Compiler/lexical_analyzer]] and related tasks are about writing a compiler for a simple C like language. The Algol 68 pre-processor in Algol 68 is similar in size to one of those tasks, so I think this task is not too large for an RC task.
:::Also, I doubt that a C pre-processor written in anything but C would get much use for anything other than bootstrapping... --[[User:Tigerofdarkness|Tigerofdarkness]] ([[User talk:Tigerofdarkness|talk]]) 21:42, 6 June 2021 (UTC)
I believe our sample language could use one line: #include "file" and #define call value. Usage could be:
~~ Header.h ~~
#define area(h, w) h*w
 
~~ Source.t ~~
#include "Header.h"
#define width 5
#define height() 6
area = #area(height, width)#;
 
yielding code output of:
area = 6*5;
 
Or:
/* Include Header.h */
/* Define area(h, w) as h*w */
/* End Header.h */
/* Define width() as 5 */
/* Define height() as 6 */
/* Use area, height, and width */
area = 6*5;
 
This should be in addition to the existing preprocessor definition as both are useful demonstrations. This new one providing identical language support to our sample language in multiple source languages.