notes.os2

来自「本工具提供一个词法分析器和语法分析器的集成开发环境」· OS2 代码 · 共 297 行

OS2
297
字号
14 April 94Version 1.20 of pcctsAt the moment this help file is available via anonymous FTP at        Node: marvin.ecn.purdue.edu        File: pub/pccts/1.20/NOTES.OS2Mail corrections or additions to Steve Robenalt <steve@molly.dny.rockwell.com>===============================================================================Notes on building PCCTS under OS/2 2.X with the C Set compilers.The supplied makefiles can be used to build PCCTS under OS/2 with minimaltrouble. First you need to edit the makefiles such that the Unix specificdefaults are commented out, then uncomment the lines which are specificto OS/2 and C Set/2 compilers as originally set up by Ed Harfmann. Notealso that you need to use the target list which reflects the appropriatenaming conventions. Some of the lines now need to be changed to reflectdifferences in conventions between the operating systems: 1) change forwardslashes in directories to backslashes, 2) change command line parametersfrom -option to /option (note that this applies to C Set, not ANTLR and DLGoptions), and 3) change rm to del for clean and scrub targets.To build ANTLR for the first time:note: I tried various combinations of "touch"ing files to try to prevent nmake      from using ANTLR to rebuild itself, and was unsuccessful.In the section labelled "Target list of PC machines", comment out thescan.c and antlr.c dependencies. This prevents nmake from trying to invokeANTLR to build itself. After you have built ANTLR successfully for the firsttime, you can uncomment these lines and it will build itself normally. (If youhad a working 1.10 installation before, you can also use the older binarieswhen building the new ones.)An example of the resulting makefile, with all the extra baggage for Unix, DOS,and OS/2 1.X is shown here:----- cut here -----## Makefile for ANTLR 1.20## SOFTWARE RIGHTS## We reserve no LEGAL rights to the Purdue Compiler Construction Tool# Set (PCCTS) -- PCCTS is in the public domain.  An individual or# company may do whatever they wish with source code distributed with# PCCTS or the code generated by PCCTS, including the incorporation of# PCCTS, or its output, into commerical software.# # We encourage users to develop software with PCCTS.  However, we do ask# that credit is given to us for developing PCCTS.  By "credit",# we mean that if you incorporate our source code into one of your# programs (commercial product, research project, or otherwise) that you# acknowledge this fact somewhere in the documentation, research report,# etc...  If you like PCCTS and have developed a nice tool with the# output, please mention that you developed it using PCCTS.  In# addition, we ask that this header remain intact in our source code.# As long as these guidelines are kept, we expect to continue enhancing# this system and expect to make other tools available as they are# completed.## ANTLR 1.20# Terence Parr# Purdue University# With AHPCRC, University of Minnesota# 1989-1994## Ported to Borland C++, IBM C-Set/2 and Microsoft 6.0 by# Ed Harfmann# Micro Data Base Systems# Lafayette, Indiana# - With updates by Steve Robenalt 4/94#SET=..\support\setPCCTS_H=..\h## C-Set/2 for OS/2#CC=iccCFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3 /DUSER_ZZSYNOUT_OBJ = /FoLIBS=ANTLR=..\bin\antlrDLG=..\bin\dlgOBJ_EXT = objantlr.exe: antlr.obj scan.obj err.obj bits.obj build.obj fset2.obj \        fset.obj gen.obj globals.obj hash.obj lex.obj main.obj \        misc.obj set.obj pred.obj dialog.obj        link386 @<<$** /NOI$@ /STACK:32768$(LIBS: = +^)$(DEF_FILE) $(LFLAGS) ;<<        copy *.exe ..\bin## *********** Target list of PC machines ***********## Don't worry about the ambiguity messages coming from antlr# for making antlr.c etc...  [should be 10 of them, I think]##antlr.c stdpccts.h parser.dlg tokens.h err.c : antlr.g#	$(ANTLR) antlr.gantlr.$(OBJ_EXT): antlr.c mode.h tokens.hscan.$(OBJ_EXT): scan.c mode.h tokens.h#scan.c mode.h: parser.dlg#	$(DLG) -C2 parser.dlg scan.cset.$(OBJ_EXT): $(SET)\set.c	$(CC) $(CFLAGS) /C $(OUT_OBJ)set.$(OBJ_EXT) $(SET)\set.c## what files does PCCTS generate (both ANTLR and DLG)#PCCTS_GEN=antlr.c scan.c err.c tokens.h mode.h parser.dlg stdpccts.h remap.hSRC=antlr.c scan.c err.c bits.c build.c fset2.c fset.c gen.c globals.c \	hash.c lex.c main.c misc.c $(SET)\set.c pred.c dialog.c## ****** These next targets are common to UNIX and PC world ********##clean up all the intermediate filesclean:	del *.$(OBJ_EXT) #remove everything in clean plus the PCCTS files generatedscrub:	del $(PCCTS_GEN) *.$(OBJ_EXT) ----- cut here -----To build DLG for the first time:Follow the same steps as were used to build ANTLR, changing the slashes andcommands, targets, and extensions for OS/2. Comment out the dependencies fordlg_p.c and dlg_a.c to prevent nmake from trying to invoke ANTLR and DLG tobuild DLG (unless you have 1.10 binaries).An example of the resulting makefile, with all the extra baggage for Unix, DOS,and OS/2 1.X is shown here:----- cut here -----## Makefile for DLG 1.20# Terence Parr# Purdue University# 1989-1993## Ported to IBM C-Set/2 and Microsoft 6.0 by# Ed Harfmann# Micro Data Base Systems# Lafayette, Indiana# - With updates by Steve Robenalt 4/94#SET=..\support\setPCCTS_H=..\h## C-Set/2 for OS/2#CC=iccCFLAGS= /I. /I$(SET) /I$(PCCTS_H) /Sa /W3OUT_OBJ = /FoLIBS=ANTLR=..\bin\antlrDLG=..\bin\dlgOBJ_EXT=objdlg.exe : dlg_p.obj dlg_a.obj main.obj err.obj set.obj support.obj \        output.obj relabel.obj automata.obj        link386 @<<$** /NOI$@ /STACK:32768$(LIBS: = +^)$(DEF_FILE) $(LFLAGS) ;<<        copy *.exe ..\binSRC = dlg_p.c dlg_a.c main.c err.c $(SET)\set.c support.c output.c \        relabel.c automata.c#dlg_p.c parser.dlg err.c tokens.h : dlg_p.g#	$(ANTLR) dlg_p.g#dlg_a.c mode.h : parser.dlg#	$(DLG) -C2 parser.dlg dlg_a.cdlg_p.$(OBJ_EXT) : dlg_p.c dlg.h tokens.h mode.h	$(CC) $(CFLAGS) /c dlg_p.cdlg_a.$(OBJ_EXT) : dlg_a.c dlg.h tokens.h mode.h	$(CC) $(CFLAGS) /c dlg_a.cmain.$(OBJ_EXT) : main.c dlg.h	$(CC) $(CFLAGS) /c main.cset.$(OBJ_EXT) : $(SET)\set.c	$(CC) /c $(CFLAGS) $(SET)\set.clint:	lint *.c#clean up all the intermediate filesclean:	del *.$(OBJ_EXT) ----- cut here -----Once you have built ANTLR and DLG successfully, you will also want to buildthe genmk utility, located at ~\pccts\support\genmk. The makefile in this directory is relatively simple to modify, so I won't repeat it here.At this point, you can test the executables by building one of the sampleprograms, such as the Pascal or C example under ~pccts\lang. The prototypemakefile which is in these directories will work fine as a base, with OS/2specific modifications as noted above. Note that the /Sa flag defines theANSI C mode of the compiler which is not the default. The default modedoes not define __STDC__ and will lead to lots of errors.A sample pascal makefile is shown below:----- cut here -----GRM =pascal.gLEX_FILE =pscan.dlgGSRC=pascal.c err.c pscan.c ttree.c adebug.cGOBJ=pascal.obj err.obj pscan.obj ttree.obj adebug.objPCCTS_GEN= pascal.c err.c $(LEX_FILE) pscan.c mode.h tokens.hSRC =$(GSRC) pmain.c sym.cOBJ =$(GOBJ) pmain.obj sym.objINCL = ..\..\hSYM = ..\..\support\symANTLR = ..\..\bin\antlrDLG = ..\..\bin\dlgCFLAGS=/I. /I$(INCL) /SaAFLAGS= -fl $(LEX_FILE) -ghpascal.exe : $(OBJ)	$(CC) $(CFLAGS) /Fopascal.exe $(OBJ)pascal.c $(LEX_FILE) : $(GRM)	$(ANTLR) $(AFLAGS) $(GRM)mode.h pscan.c : $(LEX_FILE)	$(DLG) -C2 $(LEX_FILE) pscan.cpmain.obj : pmain.c pascal.hpascal.obj : pascal.c mode.h tokens.hsym.obj : $(SYM)\sym.c	icc /c /Fo sym.obj $(CFLAGS) $(SYM)\sym.cerr.obj : err.cclean:	del $(PCCTS_GEN) *.obj----- cut here -----The C example can be built in much the same way.If you have problems compiling anything, I would appreciate hearing aboutit. I was able to get everything built and working without changing anyof the supplied or generated C code, so if you find that you need to makechanges to any code, I've probably written something up incorrectly.Please post comments to the mailing list for PCCTS at:	pccts-users@ahpcrc.umn.edusince I am most likely to see them there.- Steve Robenalt

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?