[bitc-dev] thoughts on mixfix
erights at gmail.com
Wed Mar 11 12:36:24 EDT 2009
On Wed, Mar 11, 2009 at 9:02 AM, Jonathan S. Shapiro <shap at eros-os.com> wrote:
> I have been thinking hard about the problems of mixfix. Not so much
> the parsing as the potential for confusion. I have a hair-brained
> idea, and I want to float it so we can shoot it down.
I like this idea a lot, and would instead like to shoot it up.
> Second, we introduce a syntactic form:
> with syntax <grammar-name> <expr>
> with the intended meaning that the named grammar defines *all*
> infix/prefix/... notation that is live in <expr>.
Both E's quasiliterals and PLT Scheme's module system suggests a
natural extension of this idea:
with syntax <language-transformer-name> <expr>
where <language-transformer-name> effectively names the language
<expr> is written in, by actually naming a parser-and-translator which
parses the text of <expr> and translates/expands it to the BitC kernel
> Third, we introduce a second syntactic form:
> use syntax <grammar-name>
> with the intended meaning that the start production of <grammar-name>
> should be merged with the currently active start production (it is an
> error if this results in ambiguities). The preamble would issue "use"
> statements for the customary grammars of arithmetic and boolean
Your operators for combining mixfix definitions and checking them for
ambiguity could then be generalized to combining BNF-based grammar and
expansion definitions and checking those for ambiguity. More
importantly, it allows the easy embeddings of DSLs with specialized
The hard issue, which E's quasiliterals "solve" with an unpleasant bit
of common surface syntax, is how to allow such nested language
embeddings to share a single cross-language lexical scope, where a
human reader can understand these scope relationships even if they are
not familiar with some of the languages being embedded. This helps
code reviews and auditability.
> Yes, this proposal requires that people introducing new syntax
> actually put in some design effort. I tend to view that as a *good*
Text by me above is hereby placed in the public domain
More information about the bitc-dev