I am implementing a C preprocessor in C...
I have the three functions:
- trigraph replacing function
- Line splicing function
- comment removing function
However these functions work separately on files i.e.
First function will take a file and replace the trigraphs producing a temp-file1 as output
Second function will take temp-file1 as input and splice the lines and produce another temp-file2.
Third function will take temp-file2 as input and remove comment and produce yet another temp-file3.
And now the main preprocessing tasks will be performed on temp-file3 and a .i file will be produced as final output.
Now, I have 3 options :
- Use temp files
- use pipes
- instead of intermediate temp-files or pipes use strings(i.e. whole temp-file1, 2 and 3 will be three big strings!!)
I have three doubts...
- Option 1 seems less efficient than option2
- option 2 seems to be perfect but will I be limited by size of that unnamed pipe? (since I have single process i.e. function 1 2 & 3 will be called one after another) What if temp output size > pipe's total capacity?
- option 3... Is it efficient, easy over previous two?
Please tell me, Which option should I choose?