Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!samsung!usc!cs.utexas.edu!rutgers!cmcl2!acf5!sabbagh From: sabbagh@acf5.NYU.EDU (sabbagh) Newsgroups: comp.lang.forth Subject: Re: writing a C interpreter in Forth? Message-ID: <1017@acf5.NYU.EDU> Date: 8 Jan 90 18:05:45 GMT References: <9001070938.AA07304@jade.berkeley.edu> Reply-To: sabbagh@acf5.UUCP () Organization: New York University Lines: 23 In article <9001070938.AA07304@jade.berkeley.edu> Forth Interest Group International List writes: >I wrote a C lexical scanner in Forth. It was fairly easy and quite >small. Scanning is easy; parsing is a bit harder. Probably the >easiest way to do a C parser in Forth would be to take a yacc grammar >of C and run it through yacc to get the state tables. Then duplicate >the effect of the (quite small) yacc table walking machine in Forth. Why not implement it as recursive descent? Need to left factor the grammar, but Forth is inherently suitable, since the word definitions could be made to look like the grammar. I wrote a small interpreter this way a while back. The C language is well-suited to this approach; the PCC compiler (Steve Johnson?) used it in parsing. Hadil G. Sabbagh E-mail: sabbagh@csd27.nyu.edu Voice: (212) 998-3125 Snail: Courant Institute of Math. Sci. 251 Mercer St. New York,NY 10012 186,282 miles per second -- it's not just a good idea, it's the law!