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

Roger L Costello <costello@mitre.org>
Thu, 3 Mar 2022 13:57:55 +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? ak@akkartik.com (Kartik Agaram) (2022-03-05)
Re: How do you create a grammar for a multi-language language? gah4@u.washington.edu (gah4) (2022-03-05)
Re: How do you create a grammar for a multi-language language? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2022-03-06)
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? gah4@u.washington.edu (gah4) (2022-03-06)
[11 later articles]
| List of all articles for this month |

From: Roger L Costello <costello@mitre.org>
Newsgroups: comp.compilers
Date: Thu, 3 Mar 2022 13:57:55 +0000
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="16318"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, question
Posted-Date: 05 Mar 2022 16:50:21 EST
Thread-Topic: How do you create a grammar for a multi-language language?
Thread-Index: AdgvBM3tabuoXFasQLiTikka5cGndQ==
Content-Language: en-US

Hello Compiler Experts!


Suppose you are creating a grammar for a language that hosts other languages.
For example, the (parent) language hosts the regular expression language and
the XPath language. How do you create a grammar for a multi-language language?
I can imagine two approaches:


1. Create the grammar for the parent language and copy and paste into it the
grammars of the hosted languages. Copy-and-paste doesn't sound appealing.


2. Create a grammar just for the parent language. Then, create a parsing
pipeline: parse the input first with the grammar for the parent language, then
parse the input with the grammar for one hosted language, then parse the input
with the grammar for the second hosted language, and so forth. I have no idea
how this would work; e.g., how would an abstract syntax tree be constructed?


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


/Roger


Post a followup to this message

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