common: prevent buffer overflow
[supercollider.git] / include / lang / PyrLexer.h
blob70645a73a1f04746406f62e7a489cc1adbbf3d98
1 /*
2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
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.
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.
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
22 #ifndef _PYRLEXER_H_
23 #define _PYRLEXER_H_
25 #include "PyrSymbol.h"
26 #include "SC_Export.h"
27 #include "SCBase.h"
29 extern int charno, lineno, linepos;
30 extern int *linestarts;
32 struct ClassExtFile {
33 struct ClassExtFile *next;
34 PyrSymbol *fileSym;
35 int startPos, endPos, lineOffset;
38 typedef struct classdep {
39 struct classdep *next;
40 struct classdep *superClassDep;
41 struct classdep *subclasses;
42 PyrSymbol *className;
43 PyrSymbol *superClassName;
44 PyrSymbol *fileSym;
45 int startPos, endPos, lineOffset;
46 } ClassDependancy;
48 extern PyrSymbol *gCompilingFileSym;
50 ClassDependancy* newClassDependancy(PyrSymbol *className, PyrSymbol *superClassName,
51 PyrSymbol *fileSym, int startPos, int endPos, int lineOffset);
52 bool parseOneClass(PyrSymbol *fileSym);
53 void initPassOne();
54 void finiPassOne();
55 bool passOne();
56 void buildDepTree();
57 void traverseFullDepTree();
58 void traverseDepTree(ClassDependancy *classdep, int level);
59 void traverseFullDepTree2();
60 void traverseDepTree2(ClassDependancy *classdep, int level);
61 void compileClassExtensions();
62 void compileClass(PyrSymbol *fileSym, int startPos, int endPos, int lineOffset);
64 SC_DLLEXPORT_C void runLibrary(PyrSymbol* selector);
66 void interpretCmdLine(const char *textbuf, int textlen, char *methodname);
69 int input();
70 int input0();
71 void unput(int c);
72 void unput0(int c);
74 void finiLexer() ;
75 bool startLexer(char* filename) ;
76 void startLexerCmdLine(char *textbuf, int textbuflen);
77 int yylex() ;
78 void yyerror(const char *s) ;
79 void fatal() ;
80 bool isValidSourceFileName(char *filename);
81 bool passOne_ProcessOneFile(const char *filename, int level);
83 extern void asRelativePath(char *inPath,char *outPath);
85 void initLexer();
86 void init_SuperCollider();
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);
100 void postErrorLine(int linenum, int start, int charpos);
101 bool scanForClosingBracket();
102 void parseClasses();
104 extern int parseFailed;
105 extern bool compilingCmdLine;
106 extern bool compilingCmdLineErrorWindow;
107 extern bool compiledOK;
109 #define MAXYYLEN 8192
111 extern int gNumCompiledFiles;
112 extern int gClassCompileOrderNum;
113 extern ClassDependancy **gClassCompileOrder;
114 extern char curfilename[PATH_MAX];
116 extern int runcount;
118 extern const char *binopchars;
119 extern char yytext[MAXYYLEN];
120 extern char curfilename[PATH_MAX];
122 extern int yylen;
123 extern int lexCmdLine;
124 extern bool compilingCmdLine;
125 extern bool compilingCmdLineErrorWindow;
126 extern long zzval;
128 extern int lineno, charno, linepos;
129 extern int *linestarts;
130 extern int maxlinestarts;
132 extern char *text;
133 extern int textlen;
134 extern int textpos;
135 extern int parseFailed;
136 extern bool compiledOK;
137 extern int radixcharpos, decptpos;
139 int rtf2txt(char* txt);
140 int html2txt(char* txt);
141 #endif