1 /* 2 SuperCollider real time audio synthesis system 3 Copyright (c) 2002 James McCartney. All rights reserved. 4 http://www.audiosynth.com 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 22 #pragma once 23 24 #include "PyrSlot.h" 25 #include "PyrSymbol.h" 26 #include "SC_Export.h" 27 #include "SCBase.h" 28 #include <boost/filesystem/path.hpp> 29 30 extern int charno, lineno, linepos; 31 extern int* linestarts; 32 33 struct ClassExtFile { 34 struct ClassExtFile* next; 35 PyrSymbol* fileSym; 36 int startPos, endPos, lineOffset; 37 }; 38 39 typedef struct classdep { 40 struct classdep* next; 41 struct classdep* superClassDep; 42 struct classdep* subclasses; 43 PyrSymbol* className; 44 PyrSymbol* superClassName; 45 PyrSymbol* fileSym; 46 int startPos, endPos, lineOffset; 47 } ClassDependancy; 48 49 extern PyrSymbol* gCompilingFileSym; 50 51 ClassDependancy* newClassDependancy(PyrSymbol* className, PyrSymbol* superClassName, PyrSymbol* fileSym, int startPos, 52 int endPos, int lineOffset); 53 bool parseOneClass(PyrSymbol* fileSym); 54 void initPassOne(); 55 void finiPassOne(); 56 bool passOne(); 57 void buildDepTree(); 58 void traverseFullDepTree(); 59 void traverseDepTree(ClassDependancy* classdep, int level); 60 void traverseFullDepTree2(); 61 void traverseDepTree2(ClassDependancy* classdep, int level); 62 void compileClassExtensions(); 63 void compileClass(PyrSymbol* fileSym, int startPos, int endPos, int lineOffset); 64 65 SCLANG_DLLEXPORT_C void runLibrary(PyrSymbol* selector); 66 67 void interpretCmdLine(const char* textbuf, int textlen, char* methodname); 68 69 70 int input(); 71 int input0(); 72 void unput(int c); 73 void unput0(int c); 74 75 void finiLexer(); 76 bool startLexer(char* filename); 77 void startLexerCmdLine(char* textbuf, int textbuflen); 78 int yylex(); 79 void yyerror(const char* s); 80 void fatal(); 81 bool isValidSourceFileName(const boost::filesystem::path& path); 82 bool passOne_ProcessOneFile(const boost::filesystem::path& path); 83 84 boost::filesystem::path relativeToCompileDir(const boost::filesystem::path&); 85 86 void initLexer(); 87 88 int processbinop(char* token); 89 int processident(char* token); 90 int processfloat(char* token, int sawpi); 91 int processint(char* token); 92 int processchar(int c); 93 int processintradix(char* s, int n, int radix); 94 int processfloatradix(char* s, int n, int radix); 95 int processhex(char* s); 96 int processsymbol(char* token); 97 int processstring(char* token); 98 int processkeywordbinop(char* token); 99 100 void postErrorLine(int linenum, int start, int charpos); 101 bool scanForClosingBracket(); 102 void parseClasses(); 103 104 extern int parseFailed; 105 extern bool compilingCmdLine; 106 extern bool compilingCmdLineErrorWindow; 107 extern bool compiledOK; 108 109 #define MAXYYLEN 8192 110 111 extern int gNumCompiledFiles; 112 extern int gClassCompileOrderNum; 113 extern ClassDependancy** gClassCompileOrder; 114 extern char curfilename[PATH_MAX]; 115 116 extern int runcount; 117 118 extern const char* binopchars; 119 extern char yytext[MAXYYLEN]; 120 extern char curfilename[PATH_MAX]; 121 122 extern int yylen; 123 extern int lexCmdLine; 124 extern bool compilingCmdLine; 125 extern bool compilingCmdLineErrorWindow; 126 extern intptr_t zzval; 127 extern intptr_t gParserResult; 128 129 extern int lineno, charno, linepos; 130 extern int* linestarts; 131 extern int maxlinestarts; 132 133 extern char* text; 134 extern int textlen; 135 extern int textpos; 136 extern int parseFailed; 137 extern bool compiledOK; 138 extern int radixcharpos, decptpos; 139 140 int rtf2txt(char* txt); 141 int html2txt(char* txt); 142