preprocessor.cxx

changeset 36
a8838b5f1213
parent 33
fd35f6cb5f28
child 48
976c57f153b3
equal deleted inserted replaced
35:3d3f6ed40171 36:a8838b5f1213
63 if (c != d) { 63 if (c != d) {
64 ParserError ("expected `%c`, got `%d`", c, d); 64 ParserError ("expected `%c`, got `%d`", c, d);
65 } 65 }
66 } 66 }
67 67
68 // ============================================================================
68 // Reads a word until whitespace 69 // Reads a word until whitespace
69 str ScriptReader::PPReadWord (char &term) { 70 str ScriptReader::PPReadWord (char &term) {
70 str word; 71 str word;
71 while (1) { 72 while (1) {
72 char c = PPReadChar(); 73 char c = PPReadChar();
77 word += c; 78 word += c;
78 } 79 }
79 return word; 80 return word;
80 } 81 }
81 82
83 // ============================================================================
84 // Preprocess any directives found in the script file
82 void ScriptReader::PreprocessDirectives () { 85 void ScriptReader::PreprocessDirectives () {
83 size_t spos = ftell (fp[fc]); 86 size_t spos = ftell (fp[fc]);
84 if (!DoDirectivePreprocessing ()) 87 if (!DoDirectivePreprocessing ())
85 fseek (fp[fc], spos, SEEK_SET); 88 fseek (fp[fc], spos, SEEK_SET);
86 } 89 }
87 90
88 /* Returns true if the pre-processing was successful, false if not. 91 /* ============================================================================
92 * Returns true if the pre-processing was successful, false if not.
89 * If pre-processing was successful, the file pointer remains where 93 * If pre-processing was successful, the file pointer remains where
90 * it was, if not, it's pushed back to where it was before preprocessing 94 * it was, if not, it's pushed back to where it was before preprocessing
91 * took place and is parsed normally. 95 * took place and is parsed normally.
92 */ 96 */
93 bool ScriptReader::DoDirectivePreprocessing () { 97 bool ScriptReader::DoDirectivePreprocessing () {

mercurial