Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Roger L Costello Newsgroups: comp.compilers Subject: RE: How do you create a grammar for a multi-language language? Date: Sun, 6 Mar 2022 23:32:13 +0000 Organization: Compilers Central Lines: 23 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-03-012@comp.compilers> References: <22-03-004@comp.compilers> <22-03-006@comp.compilers> <22-03-010@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="81037"; mail-complaints-to="abuse@iecc.com" Keywords: parse, design Posted-Date: 06 Mar 2022 18:49:53 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Content-Language: en-US Xref: csiph.com comp.compilers:2917 Chris Clark wrote: > the standard approach to that is to embed the > second language as a "string" in the outer language. > Many languages (and their compilers/interpreters) > do that. That's exactly what your XSLT case > does. The XPATH code is simply a string in the > XSLT language, and the XSLT language doesn't > attempt to parse it. It simply hands the code > off to an XPATH parser when in knows the string > is XPATH code. Okay, so there would be one grammar for XSLT, a second (independent) grammar for XPath. The grammar for XSLT just treats the XPath portions as strings. The grammar for XPath ignores the XSLT portions. So the input is processed in a pipeline fashion. Is that correct? But, but, but, ... how would an Abstract Syntax Tree be constructed when the input is processed in a pipeline? /Roger [I believe the answer is "incrementally." You can run the parsers sequentially or you can run them as coroutines. I don't think it makes much difference unless the intermediate version is extremely huge, but that's rarely a problem with XML. -John]