From pa.dec.com!decwrl!uunet!sparky!kent Mon Aug 5 13:21:52 PDT 1991 Article: 2546 of comp.sources.misc Newsgroups: comp.sources.misc Path: pa.dec.com!decwrl!uunet!sparky!kent From: Parag Patel Subject: v21i044: wacco - A C++ LL parser generator, Patch02 Message-ID: <1991Jul26.213550.2871@sparky.IMD.Sterling.COM> X-Md4-Signature: 93d66e775d87fd9a19614e1a74ba695c Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield) Organization: Sterling Software, IMD Date: Fri, 26 Jul 1991 21:35:50 GMT Approved: kent@sparky.imd.sterling.com Lines: 135 Submitted-by: Parag Patel Posting-number: Volume 21, Issue 44 Archive-name: wacco/patch02 Patch-To: wacco: Volume 19, Issue 88-93 Environment: C++, UNIX This is a small patch to convert wacco 1.2 to 1.3. There is a nasty bug which dumps core when code fragments within {} curlies are bigger than 1024 bytes. Oops. "Sorry about that, chief!" This patch kills the bug. Wacco is basically an LL(1) parser generator. Wacco generates recursive-descent C++ code from an input file. The wacco file.w looks a lot like a yacc(1) input file, but with a lot more syntactic sugar added. Since the parser generated recurses, you can do attribute-driven parsing easily and even pass information into rules which could alter the parse. Wacco should port and run easily on most C++ systems. It does need C++ 2.0 of some flavor. It's been successfully built on HP-UX s300 and s800 systems, Sparc, and 4.3BSD running on HP hardware. The code is somewhat commented. Feel free to hack away, add new features, or fix my screwups. If you make mods you feel are useful, or fix some bug, please send me the cdiffs so I can make them available to others too. Parag Patel -- Parag ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 07/25/1991 18:11 UTC by parag@tin # Source directory /parag/tools/wacco # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 2365 -rw-r--r-- patch-1.2-1.3 # # ============= patch-1.2-1.3 ============== if test -f 'patch-1.2-1.3' -a X"$1" != X"-c"; then echo 'x - skipping patch-1.2-1.3 (File already exists)' else sed 's/^X//' << 'SHAR_EOF' > 'patch-1.2-1.3' && *** tmp/README Mon May 20 19:38:39 1991 --- README Tue Jul 23 17:49:50 1991 *************** *** 1,4 ! $Header: README,v 1.10 91/05/20 20:38:40 hmgr Exp $ X X Copyright (c) 1991 by Parag Patel. All Rights Reserved. X You can do what you wish with this as long as X --- 1,4 ----- ! $Header: README,v 1.11 91/07/23 18:49:49 hmgr Exp $ X X Copyright (c) 1991 by Parag Patel. All Rights Reserved. X You can do what you wish with this as long as *************** *** 75,77 X bug in gen.C fixed where the string "(null)" was generated on Sparc X because I was passing NULL to printf() X some typos fixed in wacco.doc example but NOT in wacco.doc.{iw,ps} X --- 75,79 ----- X bug in gen.C fixed where the string "(null)" was generated on Sparc X because I was passing NULL to printf() X some typos fixed in wacco.doc example but NOT in wacco.doc.{iw,ps} + + 1.3 fixed bug in gen.C which wouldn't dump user code bigger than 1024 bytes *** tmp/gen.C Tue Jul 23 17:46:15 1991 --- gen.C Tue Jul 23 17:49:58 1991 *************** *** 1,5 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcs_id[] = "$Header: gen.C,v 1.30 91/05/20 13:18:31 hmgr Exp $"; X X #include "defs.h" X #include "toks.h" X --- 1,5 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. ! static const char rcs_id[] = "$Header: gen.C,v 1.31 91/07/23 18:49:55 hmgr Exp $"; X X #include "defs.h" X #include "toks.h" *************** *** 172,178 X putf("#line %d \"%s\"\n", code->line, inputfile); X else X putf("/* #line %d */\n", code->line); ! putf("%s%s;\n", pre, code->code); X if (genlineinfo) X putf("#line %d \"%s\"\n", curr_lineno + 1, currfile); X } X --- 172,180 ----- X putf("#line %d \"%s\"\n", code->line, inputfile); X else X putf("/* #line %d */\n", code->line); ! putf("%s", pre); ! fputs(code->code, fp); // if this is bigger than 1024, putf() fails ! putf(";\n"); X if (genlineinfo) X putf("#line %d \"%s\"\n", curr_lineno + 1, currfile); X } *** tmp/version.C Mon May 20 12:18:33 1991 --- version.C Tue Jul 23 17:49:52 1991 *************** *** 1,3 X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. X ! static char *const whatid = "@(#)wacco 1.2 (20 May 1991)"; X --- 1,3 ----- X // Copyright (c) 1991 by Parag Patel. All Rights Reserved. X ! static char *const whatid = "@(#)wacco 1.3 (23 July 1991)"; SHAR_EOF chmod 0644 patch-1.2-1.3 || echo 'restore of patch-1.2-1.3 failed' Wc_c="`wc -c < 'patch-1.2-1.3'`" test 2365 -eq "$Wc_c" || echo 'patch-1.2-1.3: original size 2365, current size' "$Wc_c" fi exit 0 exit 0 # Just in case...