RE: How do you create a grammar for a multi-language language?

Roger L Costello <costello@mitre.org>
Sun, 6 Mar 2022 23:32:13 +0000

          From comp.compilers

Related articles
How do you create a grammar for a multi-language language? costello@mitre.org (Roger L Costello) (2022-03-03)
Re: How do you create a grammar for a multi-language language? costello@mitre.org (Roger L Costello) (2022-03-05)
RE: How do you create a grammar for a multi-language language? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2022-03-06)
RE: How do you create a grammar for a multi-language language? costello@mitre.org (Roger L Costello) (2022-03-06)
| List of all articles for this month |
From: Roger L Costello <costello@mitre.org>
Newsgroups: comp.compilers
Date: Sun, 6 Mar 2022 23:32:13 +0000
Organization: Compilers Central
References: 22-03-004 22-03-006 22-03-010
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
Content-Language: en-US

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]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.