× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Alan Campin <Alan.Campin@xxxxxxx> wrote:
. . . but nothing like what I just read about the descent parser, nothing that complex. How do you implement?

A Recursive Descent parser is not, as far as I'm aware, something you would normally get out of YACC, or BISON, or other parser generators; it is, however, the sort of parser that's applicable to any language that can be represented as a BNF grammar, as well as fairly easy to hand-code, so long as either (1) the language supports n-level recursive calls of some sort of subroutine with dynamically-scoped local variables (obviously in RPG, it would be a "procedure call," rather than an EXSR, just as in the QBASICs, it would be a CALL rather than a GOSUB), or (2) the language to be parsed is simple enough that actual recursion is either unnecessary or limited to tail-recursion.

At any rate, to do it in ILE RPG, you're best off writing your scanner in ILE C, and doing a cross-module, cross-language function call to get your tokens. Then you just need to draw up a BNF grammar of your language, and then write a recursive subroutine for each production in the grammar. Then you just stick your semantics, either direct action for an interpreter, or code generation for a compiler, into the production routines.

Why do it in ILE RPG? Well, if it has to look up a lot of things in a lot of database files, and/or its semantic actions affect a lot of database files, RPG's database access is somewhat more convenient than C's. Moreover, if you're clever, you just might be able to use The Cycle as your outermost loop.

--
JHHL

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.