44 #include <stdio.h> |
44 #include <stdio.h> |
45 #include "str.h" |
45 #include "str.h" |
46 #include "objwriter.h" |
46 #include "objwriter.h" |
47 #include "commands.h" |
47 #include "commands.h" |
48 |
48 |
|
49 #define MAX_FILESTACK 8 |
|
50 |
49 class ScriptReader { |
51 class ScriptReader { |
50 public: |
52 public: |
51 // ==================================================================== |
53 // ==================================================================== |
52 // MEMBERS |
54 // MEMBERS |
53 FILE* fp; |
55 FILE* fp[MAX_FILESTACK]; |
54 str filepath; |
56 char* filepath[MAX_FILESTACK]; |
55 unsigned int pos; |
57 int fc; |
56 unsigned int curline; |
58 |
57 unsigned int curchar; |
59 unsigned int pos[MAX_FILESTACK]; |
|
60 unsigned int curline[MAX_FILESTACK]; |
|
61 unsigned int curchar[MAX_FILESTACK]; |
|
62 long savedpos[MAX_FILESTACK]; // filepointer cursor position |
58 str token; |
63 str token; |
59 int commentmode; |
64 int commentmode; |
60 |
65 |
61 // ==================================================================== |
66 // ==================================================================== |
62 // METHODS |
67 // METHODS |
63 // scriptreader.cxx: |
68 // scriptreader.cxx: |
64 ScriptReader (str path); |
69 ScriptReader (str path); |
65 ~ScriptReader (); |
70 ~ScriptReader (); |
|
71 void OpenFile (str path); |
|
72 void CloseFile (unsigned int u = MAX_FILESTACK); |
66 char ReadChar (); |
73 char ReadChar (); |
67 char PeekChar (int offset = 0); |
74 char PeekChar (int offset = 0); |
68 bool Next (); |
75 bool Next (bool peek = false); |
69 str PeekNext (); |
76 str PeekNext (); |
70 void Seek (unsigned int n, int origin); |
77 void Seek (unsigned int n, int origin); |
71 void MustNext (const char* c = ""); |
78 void MustNext (const char* c = ""); |
72 void MustString (); |
79 void MustString (); |
73 void MustNumber (); |
80 void MustNumber (); |
82 |
89 |
83 // parser.cxx: |
90 // parser.cxx: |
84 void BeginParse (ObjWriter* w); |
91 void BeginParse (ObjWriter* w); |
85 void ParseCommand (CommandDef* comm, ObjWriter* w); |
92 void ParseCommand (CommandDef* comm, ObjWriter* w); |
86 |
93 |
|
94 // preprocessor.cxx: |
|
95 void PreprocessDirectives (); |
|
96 void PreprocessMacros (); |
|
97 |
87 private: |
98 private: |
88 bool atnewline; |
99 bool atnewline; |
89 char c; |
100 char c; |
90 void ParserMessage (const char* header, char* message); |
101 void ParserMessage (const char* header, char* message); |
|
102 |
|
103 bool DoDirectivePreprocessing (); |
|
104 char PPReadChar (); |
|
105 void PPMustChar (char c); |
|
106 str PPReadWord (char &term); |
91 }; |
107 }; |
92 |
108 |
93 #endif // __SCRIPTREADER_H__ |
109 #endif // __SCRIPTREADER_H__ |