1 2 Microsoft Visual C Stuff 3 4 5 [Tom Moog 2-Oct-98 6 7 Users of Microsoft Visual C++ should download a separate 8 ready-to-run zip file from my web site. It contains 9 binaries, static library, and a sample project. 10 ] 11 12 [ 13 Two notes added by Tom Moog 23-Sep-97. I believe the *.dsp and 14 *.mak files that were once at the end of this file are now obsolete. 15 16 The following MSVC .dsp and .mak files for pccts and sorcerer 17 were contributed by Stanislaw Bochnak (S.Bochnak (a] microtool.com.pl) 18 and Jeff Vincent (jvincent (a] novell.com) 19 20 PCCTS Distribution Kit 21 ---------------------- 22 pccts/antlr/AntlrMSVC50.dsp 23 pccts/antlr/AntlrMSVC50.mak 24 25 pccts/dlg/DlgMSVC50.dsp 26 pccts/dlg/DlgMSVC50.mak 27 28 pccts/support/genmk/watgenmk.mak 29 pccts/support/msvc.dsp 30 31 Sorcerer Distribution Kit 32 ------------------------- 33 pccts/sorcerer/SorcererMSVC50.dsp 34 pccts/sorcerer/SorcererMSVC50.mak 35 36 pccts/sorcerer/lib/msvc.dsp 37 38 I do not have an MS based computer. If you discover problems 39 please report them so as to save trouble for others in the future. 40 ] 41 42 [ 43 Modified by Terence Parr (September 1995) to change .C to .cpp 44 ] 45 46 [ 47 This file contains notes on MSVC for Windows NT console execs by Dave 48 Seidel and an explanation of flags etc.. by John Hall; good luck, 49 Terence 50 ] 51 52 =============================================================================== 53 Date: Sat, 31 Dec 1994 11:40:36 -0500 (EST) 54 From: David Seidel <75342.2034 (a] compuserve.com> 55 56 I've succesfully build 1.31b3 with djgpp for DOS and MSVC 2.0 for Windows 57 NT. The only (minor) problem I had was that GNU make (version 3.71, in the 58 djgpp port) complained about "multiple targets" in both the antlr and dlg 59 makefiles. I got around the error by, in each makefile, commenting out the 60 $(SRC) dependency, for example: 61 62 antlr: $(OBJ) #$(SRC) 63 64 I don't know why this is happenning, since you haven't changed that part of 65 the makefile at all, and I think this used to work ok... 66 67 Here are the makefiles I built from within the MSVC 2.0 environment for antlr 68 and dlg and Windows NT console executables. Please feel free to pass them 69 on. Of course, as soon as 1.31 "goes gold", I will send you nice new 70 binaries. I'm not going to bother to keep doing both Borland and djgpp for 71 DOS however. Instead, I'll just keep the djgpp version up to date and also 72 provide WinNT binaries. 73 74 Dave 75 =============================================================================== 76 77 How to port PCCTS 1.10 (and 1.32 hopefully) to Visual C++ 78 79 By 80 81 John Hall <jhall (a] ivy.wpi.edu> 82 83 Here is how to compile an ANTLR grammar in Visual C++. These steps 84 describe how to have your ANTLR grammar parse the input file the user 85 selects when they choose File Open in your Windows application. (Even 86 if you aren't using Visual C++, the steps should be portable enough to 87 other compilers.) 88 89 * Make sure that ANTLR and DLG generate ANSI code (use the -ga 90 switch). 91 92 * Set the following compiler flags in Visual C++ (these are in the 93 Memory Model category of the compiler options in the Project 94 Options menu): 95 96 FLAG MEANING 97 ==== ============================================================== 98 /AL Large memory model (multiple data segments; data items must be 99 smaller than 64K). 100 101 /Gtn Allocates all items whose size is greater than or equal to n 102 in a new data segment. (I let n be 256: /Gt256.) 103 104 /Gx- All references to data items are done with far addressing in 105 case they are placed in a far segment. 106 107 * Add the following member variable to the attributes section of your 108 derived CDocument class (you will need to make sure you also 109 include stdio.h): 110 111 FILE *fp; 112 113 * Add the following method to your derived CDocument class: 114 115 BOOL CAppDoc::OnOpenDocument(const char* pszPathName) 116 { 117 // Call CDocument's OnOpenDocument to do housekeeping for us 118 // DON'T add anything to the loading section of Serialize 119 if (!CDocument::OnOpenDocument(pszPathName)) 120 return FALSE; 121 122 // Open input file 123 if ((fp = fopen(pszPathName, "r")) == NULL) 124 return FALSE; 125 126 // Parse input file 127 ANTLR(start(), fp); 128 129 // Close input file 130 fclose(fp); 131 return TRUE; 132 } 133 134 (Note: additional code may be necessary, depending on your parser. 135 For example, if your parser uses PCCTS's symbol table library, you 136 will need to insert calls to zzs_init and zzs_done.) 137 138 * Compile the generated C files as C++ files. (I renamed the files 139 to have a .CPP extension to fool Visual C++ into thinking they were 140 C++ files. One might also use the /Tp switch, but that switch 141 requires you separately include the filename.) [I used this step 142 as an easy out for all the external linking errors I was getting 143 that I couldn't fix by declaring things extern "C".] 144 145 * Make sure the __STDC__ portion of the generated files gets 146 compiled. (Either define __STDC__ yourself or else change all 147 occurrences of __STDC__ to __cplusplus in the generated files. You 148 can define __STDC__ in the Preprocessor category of the compiler 149 options.) 150 151 ================================================================ 152 = Note 23-Sep-97: This is probably not necessary any more. = 153 = With 1.33MRxxx the use of __STDC__ was replaced with the = 154 = macro __USE_PROTOS to control the compilation of prototypes. = 155 ================================================================ 156 157 That last step is important for Visual C++, but may not apply to other 158 compilers. For C++ compilers, whether __STDC__ is defined is 159 implementation dependent (ARM, page 379). Apparently, Visual C++ does 160 not to define it; it also does not support "old style" C function 161 definitions (which is okay, according to page 404 of the ARM). Those 162 two things together caused problems when trying to port the code. 163 When it saw this: 164 165 #ifdef __STDC__ 166 void 167 globals(AST **_root) 168 #else 169 globals(_root) 170 AST **_root; 171 #endif 172 173 it skipped the __STDC__ section and tried to process the "old style" 174 function definition, where it choked. 175 176 When you finally get your parser to compile and link without error, 177 you may get General Protection Fault errors at run time. The problem 178 I had was that a NULL was passed to a variable argument function 179 without an explicit cast. The function grabbed a pointer (32-bits) 180 off the stack using va_arg, but the NULL was passed silently as the 181 integer 0 (16 bits), making the resulting pointer was invalid. (This 182 was in PCCTS's sample C parser.) 183 184 There is one other thing I might suggest to help you avoid a run-time 185 error. Make sure you redefine the default error reporting function, 186 zzsyn. To do this, put "#define USER_ZZSYN" in your #header section 187 and put your own zzsyn somewhere. You can then pop up a MessageBox or 188 print the error to some output window. 189 =============================================================================== 190