home *** CD-ROM | disk | FTP | other *** search
/ cs.rhul.ac.uk / www.cs.rhul.ac.uk.zip / www.cs.rhul.ac.uk / pub / rdp / old_versions / rdp1_2.doc < prev    next >
Text File  |  1994-11-14  |  18KB  |  369 lines

  1. This is the RDP V1.20 release distribution. To install RDP look in the
  2. makefile and ensure that the blocks of options at the top are commented out
  3. correctly for either Borland C on MS-DOS or GCC on Unix as the fancy takes
  4. you. Then type 'make' and stand well back. 
  5.  
  6. If you use another ANSI compiler then you should be able to build RDP after
  7. you have defined suitable compiler switch options in the makefile. I'd really
  8. like to hear about any problems you have with, say, Microsoft C or your Unix
  9. vendor's C compiler.
  10.  
  11. Further documentation may be found in Postscript form in subdirectory 'doc'.
  12.  
  13. ** RDP release version 1.20 flyer. Adrian Johnstone 6 November 1994 **
  14.  
  15. The second maintenance release of RDP (version 1.2) is now available via ftp
  16. from cscx.cs.rhbnc.ac.uk (134.219.200.45) in directory /pub/rdp. Get
  17. rdp1_2.zip if you are an MS-DOS user or rdp1_2.tar if you are a Unix user. I
  18. have not compressed the Unix version because some people have been having
  19. trouble decompressing the file - is there a bug in OSF/1 compress?
  20.  
  21. If you would like your name added to a mailing list which will keep you up to
  22. date with RDP developments please mail me at the address given at the end of
  23. this message.
  24.  
  25. I'd like to thank the many people who have tried RDP and sent me encouraging
  26. messages, suggestions for improvements and bug reports, in particular Andy
  27. Betts (previously of UCL, now at Inmos) and my students on course CS347 at RHUL.
  28.  
  29. *** Important note ***
  30.  
  31. I have made three fundamental changes at this release. Firstly NUMBER is now
  32. called INTEGER (and yes, I have added a REAL primitive too). A global search
  33. and replace of NUMBER for INTEGER will fix this for you.
  34.  
  35. More seriously, I and several others had become very frustrated with
  36. endlessly having to quote semantic action strings on a line by line basis. In
  37. addition, the use of \ as an escape and " as a code delimiter was a real bad
  38. idea because of the clash with C string use. As of this release, all semantic
  39. actions need to be enclosed in [* ... *] instead of " ... ". Many apologies
  40. for the need to change your files, but I think you will find the new format a
  41. lot easier to use.
  42.  
  43. Finally, the layout of the symbol table data type symbol__ has been changed.
  44. The id, token and symbol table links are as before. All other data elements
  45. are in a union called data. I have predefined integer, real, character and
  46. void pointer and in params.h constructed typedefs to allow parameterisation.
  47. The main change that you will have to apply is to change all occurrences in
  48. your semantic actions of '->number' to ->data.i. 
  49.  
  50. ** Improvements in this version include **
  51.  
  52. NEW FEATURES
  53.  
  54. 1. I wrote a user manual.
  55.  
  56. 2. I have also written the first draft of a manual describing the support
  57. routines, in particular the symbol table and how to implement nested scope
  58. routines. 
  59.  
  60. 3. The support routine source and header files are now held in a separate
  61. subdirectory so that a single copy can be centrally held on a multiuser
  62. system. 
  63.  
  64. 4. All identifiers in a BNF file (both production names and attribute names)
  65. are now checked against a list of C++ reserved words and common library
  66. names, so a production called, say, 'register' will be spotted before you get
  67. to the C compilation stage. You can add extra names to the check list by
  68. inserting them into the initialiser for array rdp__reserved_words in
  69. rdp_aux.c, and recompiling.
  70.  
  71. 5. RDP and its generated scanners now report exactly which tokens they were
  72. expecting when a syntax error occurs rather than just referring to the name of
  73. the follow set.
  74.  
  75. 6. RDP now checks for unused productions, and issues a warning message if it
  76. finds any. Unused productions are suppressed in the C parser.
  77.  
  78. 7. A production consisting of just a sequence of semantic actions is now
  79. allowed. The body of such a production will be inserted in-line whenever it is
  80. referenced in the grammar. This allows large semantic actions to be placed
  81. away from the actual grammar rule. By convention, names of the form _1, _2 and
  82. so on are used for semantic productions but you are free to adopt your own
  83. style if you wish. See the user manual for suggestions on how to use this
  84. feature. Thanks to Andy Betts for his suggestions which led to this idea.
  85.  
  86. 8. Generated code is now C++ clean, i.e. I have changed identifier names that
  87. clash with C++ reserved words.
  88.  
  89. 9. The NUMBER scanner primitive has been replaced by INTEGER
  90.  
  91. 10. INTEGER now returns a variable of typedef integer which is defined in
  92. symbol.h.
  93.  
  94. 11. INTEGER now recognises C-style hexadecimal numbers such as 0xFE
  95.  
  96. 12. The HEX_DOLLAR directive has been removed as it is now redundant.
  97.  
  98. 13. A REAL scanner primitive has been added. It will parse C-style floating
  99. point numbers, returning a variable of typedef real which is defined in
  100. symbol.h.
  101.  
  102. 14. Symbol table structure symbol__ has changed. You may need to change your
  103. semantic actions to a slightly different form.
  104.  
  105. 15. The text strings relating to numbers are now left in the text table and
  106. pointed to by scan__sym->id. This is to allow 64-bit users to pull out the
  107. digits and construct 64-bit constants. 
  108.  
  109. 16. Semantic actions are now delimited by [* ... *] instead of  " ... ". This
  110. reduces the need to quote and also allows actions to run over several lines
  111. without needing to separately quote each line.
  112.  
  113. 17. Consecutive semantic actions are now spliced together in the output so that
  114. the actions [* **] [*] *] appear in the output as ' *] '. This avoids the need
  115. for an escape character in semantic actions.
  116.  
  117. 18. A -p (parser only) option has been added to rdp and rdp_gen. When set,
  118. RDP suppresses the writing out of semantic actions, so you get a pure parser
  119. that will just syntax check your source file.
  120.  
  121. 19. All echoing now goes to the stream MESSAGES which is defined in params.h
  122. to be stderr. You can send them somewhere else (such as stdout) by changing
  123. this definition and recompiling everything. 
  124.  
  125. 20. A -f (filter mode) option has been added as a standard option. When set,
  126. RDP and RDP generated parsers read from stdin and write to stdout. Note that
  127. all options are read strictly left to right, and so a subsequent -o option
  128. will override the use of stdout, and a subsequent filename (i.e. any
  129. parameter without a leading - sign) will override the use of stdin.
  130.  
  131. 21. The STRING_ESC primitive now recognises all C-style escape sequences (but
  132. not trigraph sequences - does anybody want them?)
  133.  
  134. 22. COMMENT_LINE and COMMENT_LINE_VISIBLE primitives have been added which
  135. can be used to parse Ada-style comments which start with a token and continue
  136. to the end of the line. (Actually, these were in version 1.1 but I forgot to
  137. document them).
  138.  
  139. 23. The OPTION directive now has an optional semantic action. If missing,
  140. then a line is generated for the help message only. This is useful for adding
  141. text only lines to the help message.
  142.  
  143. 24. RDP generated parsers now announce both when they were generated, and
  144. when they were last compiled when -v is used or if an error occurs.
  145.  
  146. 25. In verbatim mode, if no continuation tokens are needed, this is announced.
  147.  
  148. 26. Parameters have been collected together into header file params.h in
  149. subdirectory rdp_supp. In particular, the datatypes corresponding to INTEGER,
  150. REAL and so on are typedef'ed in here, and you can also define printf()
  151. format strings for them. If you change the typedef's you MUST update the
  152. corresponding FORMAT strings because RDP may use these types internally, and
  153. printing of parser files will break if you create a mismatch between the type
  154. and its FORMAT string.
  155.  
  156. 27. Pascal alternate style comments (*...*) are now accepted by the Pascal 
  157. parser.
  158.  
  159. BUG FIXES 
  160.  
  161. 28. When no SUFFIX directive is used, RDP generated parsers no longer append
  162. a period (.) to the source file name. This bug slipped through because I
  163. develop on MS-DOS, where filenames test and test. mean the same thing.
  164. Several Unix users castigated me for this, and quite right too.
  165.  
  166. 29. Various aspects of the output indentation code have been cleaned up so
  167. that the output indentation is now reliable and supports sequences of code
  168. items. 
  169.  
  170. 30. A bug which meant that the -t and -T options on generated parsers did not
  171. work has been fixed (Thanks to Andy Betts for diagnosing this one).
  172.  
  173. 31. A very obscure bug that led to continuation tokens not being generated
  174. for the lexically first token has been fixed. (Double thanks to Andy Betts
  175. for finding this one).
  176.  
  177. 32. A very stupid bug that led to line echoing being suppressed before the
  178. first token was encountered, so that initial comments were lost, has been
  179. fixed. How come nobody else noticed this?
  180.  
  181. 33. At the end of a text mode section, the unused file variable was being
  182. fclose'd. Thanks to Simon Richardson for finding this one.
  183.  
  184. 34. When not in verbose mode, generated parsers might end up with sets that
  185. were not big enough to hold a list of tokens. This potentially very serious
  186. bug has now been fixed.
  187.  
  188. 35. I added a MATHS macro to the makefile so that the many Unix systems that
  189. require -lm to be the last option on a link line can be made happy. Apologies
  190. to the approximately one zillion people that told me about this: Ultrix and
  191. OSF/1 don't seem to mind...
  192.  
  193. 36. I added a HERE macro to the makefile which prepends ./ (or .\ on MS-DOS)
  194. to all executable invocations for users that don't have . in their path.
  195.  
  196. 37. The default rule in the makefile for compilation has been changed from
  197. .c.o to .c$(OBJ).
  198.  
  199. 38. Previously, errors that were only reported after EOF had been read on the
  200. outermost file caused a variety of garbage error messages and even core dumps.
  201. I've fixed this by not discarding the outermost file descriptor. Thanks in
  202. particular to Jason Weston and Mark Stitson for supplying files that
  203. illustrated this problem.
  204.  
  205. 39. Unbelievably, iteration brackets {...} were not being checked for
  206. disjoint first and follow sets. This is because I had been adding the first
  207. sets to the follow sets to make the error handling work. Of course, this
  208. generates first/follow errors for all iterations, so I disabled he error
  209. checking...  The correct solution was to do the checking, then add first to
  210. follow for iterations and then reclose the follow sets. I'd like to apologise
  211. to my 1994 compilers class for causing several of them to present me
  212. with incorrect solutions as a result of this bug. I'd like to, but I won't,
  213. because anyone who thinks p ::= 'x' {'a' 'b'} 'a'. is LL(1) doesn't deserve an
  214. apology. 
  215.  
  216.  
  217. **** Features for future versions
  218.  
  219. The next version (1.3) will support inherited attributes, including the
  220. passing of production names into productions allowing macro style grammars in
  221. the style of PRECC. I'd like to thank the authors of PRECC (Jonathan Bowen and
  222. ...) for their help and advice. While I'm at it, I'd also like to thank
  223. Terence Parr (the author and maintainer of PCCTS) for his helpful comments. 
  224.  
  225. I have a C grammar derived directly from the ANSI grammar in Kernighan and
  226. Ritchie second edition. It isn't too well tested at the moment, so I didn't
  227. want to release it at this time. If you are very anxious to try using RDP
  228. with this C grammar, then mail me and I'll send you what I have. I also have
  229. a couple of other grammars for C that have been hacked out of the LL(1) C
  230. grammars available on the net. Look on cscx.cs.rhbnc.ac.uk (134.219.200.45)
  231. in  directory /pub/cgrammar
  232.  
  233. I am developing a replacement for Toy which is a true C subset (called,
  234. provisionally, C--). This will be supplied as an interpreter and there will be
  235. changes to the as yet undocumented interpreter and macro hooks in the scanner.
  236.  
  237. I have had the ISO standard Pascal grammar typed in, which is very different
  238. to the one in this release. In particular it includes productions for
  239. conformant array parameters. I will distribute the new grammar at version 1.3.
  240. Right now it still has an LL(1) conflict which I am trying to resolve
  241. elegantly. If you want an early version, email me. 
  242.  
  243. RDP V1.30 should be out before the end of 1994.
  244.  
  245.  
  246. A future major release (V2.00) will support scanner productions which
  247. supercede the various programmable tokens used at the moment. RDP will then
  248. write out a customised scanner for each language in exactly the same way that
  249. it currently writes out parsers. These generated scanners will look just like
  250. the existing scanner (i.e. they will NOT be DFA based) so that they can be
  251. debugged easily. A set of scanner productions equivalent to the current
  252. scanner will be supplied.
  253.  
  254. Also at V2.00, I hope to support permutation phrases, as described in a
  255. recent edition of LOPLAS.  
  256.  
  257. Perhaps at V2.00, you will be able to selectively allow backtracking so
  258. allowing LL(k) grammars to be parsed. If you need this a lot you should be
  259. looking at PCCTS or PRECC not RDP.
  260.  
  261. RDP V2.00 will not be available until 1995.
  262.  
  263. Finally (surprise, surprise) a textbook on code generation for modern
  264. processors, using RDP to construct the compiler front ends, will appear
  265. eventually. Anybody interested in beta-testing the book might like to get in
  266. touch, but we're not expecting to make much progress on it until the Spring of
  267. 1995.
  268.  
  269.  
  270. **** Here follows a thumbnail sketch of RDP ****
  271.  
  272. RDP - a recursive descent parser generator
  273.  
  274. RDP compiles attributed LL(1) grammars decorated with C-language semantic
  275. actions into recursive descent compilers. RDP is written in strict ANSI C and
  276. produces strict ANSI C. RDP was developed using Borland C 3.1 on a PC and has
  277. also been built with no problems on Alpha/OSF-1, DECstation/Ultrix Sun
  278. 4/SunOS and NetBSD 0.9 hosts all using GCC. The definition of strict ANSI
  279. here means  compiling with 
  280.  
  281. gcc -Wmissing-prototypes -Wstrict-prototypes -fno-common -Wall -ansi -pedantic
  282.  
  283. and getting no warning messages. 
  284.  
  285. RDP also compiles with Borland Turbo-C and Microsoft C version 7.0 although
  286. you may get some bitfield alignment warnings, 
  287.  
  288. RDP is C++ `clean' i.e. there are no identifiers used that clash with C++
  289. reserved words. RDP generated code has been used with g++ applications, and
  290. compiles with g++ and the Borland C++ (as opposed to ANSI) compiler.
  291.  
  292. RDP itself and the language processors it generates use standard symbol, set
  293. and scanner modules. The RDP scanner is programmed by loading tokens into the
  294. symbol table at the start of each run. In principle, the RDP scanner can be
  295. used to support runtime extensible languages, such as user defined operators
  296. in Algol-68, although nobody has had the nerve to try this yet.
  297.  
  298. RDP produces complete runnable programs with built-in help information and
  299. command line switches that are specified as part of the EBNF file. In this
  300. sense RDP output is far more shrink-wrapped than the usual parser generators
  301. which helps beginning students. RDP can generate itself which is a nice
  302. demonstration of the bootstrapping technique used for porting compilers to
  303. new architectures.
  304.  
  305. I wrote RDP because in October I started giving a course on compiler design.
  306. I don't think the world needs another course on parsing techniques and am
  307. really interested in code generation for exotic processors, so I tried to
  308. produce a compact parser generator that would enable undergraduates to rip
  309. through the syntax and standard code generation parts of the syllabus in a
  310. few weeks, thus leaving me time to get into the black arts of code scheduling
  311. and optimisation.
  312.  
  313. What you get.
  314.  
  315. o An implementation of Pascal style set-handling in C.
  316.  
  317. o A hash-coded symbol table with support for scoping and arbitrary user data.
  318.  
  319. o A programmable high-speed scanner with integrated error handling and
  320.   hooks for macros (RDP is being used to generate assemblers for two novel
  321.   microprocessors in addition to the usual applications of LL(1) parsers).
  322.  
  323. o The source to a hand-coded version of the RDP translator. RDP checks that
  324.   the source grammar is LL(1) and explains exactly why a non-LL(1) grammar
  325.   is unacceptable. RDP does not attempt to rework a grammar by itself.
  326.  
  327. o A decorated EBNF file describing RDP that may be processed by the
  328.   hand-coded RDP translator to produce a machine generated version of RDP.
  329.   This is good for boggling undergraduate's minds with.
  330.  
  331. o A decorated EBNF file describing an interpreter for a language called TOY.
  332.  
  333. o An EBNF file describing Pascal which generates a parser for the Pascal 
  334.   language. 
  335.  
  336. o A pre-built RDP executable for MS-DOS.
  337.  
  338. o Sources, makefiles and Borland 3.1 project files for everything which
  339.   you may use freely on condition that you send copies of any modifications,
  340.   enhancements and ill-conceived changes you might make back to me so that
  341.   I can improve RDP.
  342.  
  343. o Manuals
  344.  
  345. What you don't get.
  346.  
  347. o Tutorial information on parsing and compiling (try Wirth's Algorithms +
  348.   Data Structures = Programs, Chapter 5 or your favourite compiler book).
  349.   Maybe by the end of next year there'll be a book by me.
  350.  
  351. o Warranties. This code has only just escaped from my personal toolkit.
  352.   I've put a lot of effort into making it fit for others to use, but in
  353.   the very nature of compiler compilers it is hard to test all the angles,
  354.   and the Garbage In - Garbage Out principle holds to the highest degree:
  355.   if you write ill-formed semantic actions you won't find out until you try
  356.   and compile the parser that RDP wrote for you. On the plus
  357.   side, RDP has now been used pretty ferociously by several people
  358.   and has stood up very well. It does seem to be pretty stable, and I will
  359.   continue to respond to bug reports.
  360.  
  361.  
  362.                                       Adrian
  363.  
  364. ***
  365. Comments, queries and requests for code to
  366.  
  367. Dr Adrian Johnstone, CS Dept, Royal Holloway, University of London
  368. Email: adrian@dcs.rhbnc.ac.uk
  369.