/* ============ PR_CompileFile compiles the 0 terminated text, adding defintions to the pr structure ============ */ qboolean PR_CompileFile (char *string, char *filename) { if (!pr.memory) Error ("PR_CompileFile: Didn't clear"); PR_ClearGrabMacros (); // clear the frame macros pr_file_p = string; s_file = CopyString (filename); pr_source_line = 0; PR_NewLine (); PR_Lex (); // read first token while (pr_token_type != tt_eof) { if (setjmp(pr_parse_abort)) { if (++pr_error_count > MAX_ERRORS) return false; PR_SkipToSemicolon (); if (pr_token_type == tt_eof) return false; } pr_scope = NULL; // outside all functions PR_ParseDefs (); } return (pr_error_count == 0); }
/* * ============== * PR_LexWhitespace * ============== */ void PR_LexWhitespace(void) { int c; while (1) { /* * skip whitespace */ while ((c = *pr_file_p) <= ' ') { if (c == '\n') PR_NewLine(); if (c == 0) return; /* * end of file */ pr_file_p++; } /* * skip // comments */ if (c == '/' && pr_file_p[1] == '/') { while (*pr_file_p && *pr_file_p != '\n') pr_file_p++; PR_NewLine(); pr_file_p++; continue; } /* skip / * * / comments */ if (c == '/' && pr_file_p[1] == '*') { do { pr_file_p++; if (pr_file_p[0] == '\n') PR_NewLine(); if (pr_file_p[1] == 0) return; } while (pr_file_p[-1] != '*' || pr_file_p[0] != '/'); pr_file_p++; continue; } break; /* * a real character has been found */ } }