Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.compilers > #2911
| From | Roger L Costello <costello@mitre.org> |
|---|---|
| Newsgroups | comp.compilers |
| Subject | Re: How do you create a grammar for a multi-language language? |
| Date | 2022-03-05 22:29 +0000 |
| Organization | Compilers Central |
| Message-ID | <22-03-006@comp.compilers> (permalink) |
| References | <22-03-004@comp.compilers> |
Kartik Agaram wrote: * I'd re-ask the question in the context of the concrete languages you're considering. I am working with a team to develop a new language and our current thinking is that the language will use the XPath language for navigating through documents and the CSS language for expressing sets of match/action pairs. This idea of multi-language languages is very common within the XML community. For example, the XSLT language uses (hosts) the XPath language. Here is an excerpt to illustrate: select="/Bookstore/Book[1]/Title" The expression /Bookstore/Book[1]/Title is an XPath expression, the other parts are XSLT. So, the format of the select statement is: select="XPath" See how XSLT hosts XPath? That is, one language (XSLT) is using another language (XPath). Another XML language called XML Schema hosts two languages: the regex language and the XPath language. How do compiler experts create grammars for multi-language languages? /Roger From: Kartik Agaram <ak@akkartik.com> Sent: Saturday, March 5, 2022 4:58 PM Subject: [EXT] Re: How do you create a grammar for a multi-language language? The first way is unlikely to work. Inlining one grammar into another is overwhelmingly likely to result in garbage. If you're lucky it'll recognize one of the languages and ignore the productions of the other. More likely it'll recognize a single language that's an uncontrollable melange of both. In the worst case it'll seem to work but fail in strange corner cases. In general, I think you under-estimate the difficulty of this problem, and how easy it is for two languages to be fundamentally incompatible. The first question isn't "what's the cleanest way to do this for arbitrary languages?" but "is it even possible for these two languages?" followed by "is it worth the trouble?" So I'd re-ask the question in the context of the concrete languages you're considering. [XSLT is written in XML. Conceptually at least, first you parse the XML using an XML grammar, then you parse the XSLT using the XSLT grammar. -John]
Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar
How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-03 13:57 +0000
Re: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-05 22:29 +0000
Re: How do you create a grammar for a multi-language language? "Kartik Agaram" <ak@akkartik.com> - 2022-03-05 16:55 -0800
RE: How do you create a grammar for a multi-language language? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-06 15:37 +0200
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 14:36 -0800
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 16:50 -0800
RE: How do you create a grammar for a multi-language language? Roger L Costello <costello@mitre.org> - 2022-03-06 23:32 +0000
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-05 21:10 -0800
Re: How do you create a grammar for a multi-language language? "Robin Vowels" <robin51@dodo.com.au> - 2022-03-07 13:39 +1100
Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-06 12:23 +0100
Re: How do you create a grammar for a multi-language language? Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-03-07 05:08 +0100
Re: How do you create a grammar for a multi-language language? gah4 <gah4@u.washington.edu> - 2022-03-06 21:22 -0800
Keywords and Reserved Words Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-03-08 21:46 +0200
Re: Keywords and Reserved Words gah4 <gah4@u.washington.edu> - 2022-03-09 00:31 -0800
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 10:00 +1100
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 09:55 +1100
Re: Keywords and Reserved Words in Fortran Thomas Koenig <tkoenig@netcologne.de> - 2022-03-10 07:07 +0000
Re: Keywords and Reserved Words "Robin Vowels" <robin51@dodo.com.au> - 2022-03-10 11:59 +1100
csiph-web