Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: gah4 Newsgroups: comp.compilers Subject: Re: How do you create a grammar for a multi-language language? Date: Sun, 6 Mar 2022 14:36:01 -0800 (PST) Organization: Compilers Central Lines: 31 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-03-011@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" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="72642"; mail-complaints-to="abuse@iecc.com" Keywords: parse, design Posted-Date: 06 Mar 2022 18:22:54 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <22-03-010@comp.compilers> Xref: csiph.com comp.compilers:2916 On Sunday, March 6, 2022 at 9:06:34 AM UTC-8, Christopher F Clark wrote: (snip) > However, you are actually solving a "simpler" problem. And, 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. That works when the outer language is parsed first. For PHP, and I believe the C preprocessor, the inner language is parsed first, so the parser has to ignore everything, including quoting, in the outer language. I don't believe I ever tried preprocessor statements inside C string constants, but as far as I know, it works. One has to be careful to avoid ambiguities between the two, or are created with the combination of the two languages. [PHP effectively treats material between ?> and