From: | gah4 <gah4@u.washington.edu> |
Newsgroups: | comp.compilers |
Date: | Sat, 5 Mar 2022 21:10:46 -0800 (PST) |
Organization: | Compilers Central |
References: | <AdgvBM3tabuoXFasQLiTikka5cGndQ==> 22-03-004 |
Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="88045"; mail-complaints-to="abuse@iecc.com" |
Keywords: | parse, design |
Posted-Date: | 06 Mar 2022 12:01:52 EST |
In-Reply-To: | 22-03-004 |
On Saturday, March 5, 2022 at 1:50:24 PM UTC-8, Roger L Costello wrote:
> 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?
A little it depends on how the two go together.
A not so unusual way to write compilers years ago, was recursive descent
for statements, and operator precedence for expressions. The recursive
descent parser calls the operator precedence parser when it needs an
expression to be parsed.
Some mixed languages can be parsed separately.
The C preprocessor, originally a separate pass, but now usually implemented
together with the rest of the C compiler, processes its statements, and passes
everything else through. It does that well enough, that it is commonly used
with Fortran. (The traditional version, not the newer one.)
PHP is designed to recognize its syntax, and ignore everything else, which
is normally html, but could be another language.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.