The CoCompiler: DSL Lifting via Relational Compilation

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Spargo, Naomi, Cuéllar, Santiago, Daugherty, Jonathan, Phifer, Chris, Darais, David
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912674994978816
author Spargo, Naomi
Cuéllar, Santiago
Daugherty, Jonathan
Phifer, Chris
Darais, David
author_facet Spargo, Naomi
Cuéllar, Santiago
Daugherty, Jonathan
Phifer, Chris
Darais, David
contents Lifting low-level or legacy code into a domain-specific language (DSL) improves our ability to understand it, enables deeper formal reasoning, and facilitates safe modification. We present the CoCompiler, a bidirectional compiler and lifter between C and Lustre, a synchronous dataflow language used for reactive systems. The key insight behind the CoCompiler is that writing a compiler as a relation, rather than as a traditional function, yields a DSL lifter "for free". We implement this idea by rewriting the verified Lustre-to-C compiler Vélus in the Walrus relational programming language. This solves what we call the vertical lifting problem, translating canonical C into Lustre. To address the complementary horizontal problem-handling real-world C outside the compiler's image-we apply semantic-preserving canonicalization passes in Haskell. The resulting tool, the CoCompiler, supports lifting real reactive C code into Lustre and onward into graphical behavioral models. Our approach is modular, language-agnostic, and fast to implement, demonstrating that relational programming offers a practical foundation for building DSL lifters by repurposing existing compilers.
format Preprint
id arxiv_https___arxiv_org_abs_2510_00210
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle The CoCompiler: DSL Lifting via Relational Compilation
Spargo, Naomi
Cuéllar, Santiago
Daugherty, Jonathan
Phifer, Chris
Darais, David
Programming Languages
Lifting low-level or legacy code into a domain-specific language (DSL) improves our ability to understand it, enables deeper formal reasoning, and facilitates safe modification. We present the CoCompiler, a bidirectional compiler and lifter between C and Lustre, a synchronous dataflow language used for reactive systems. The key insight behind the CoCompiler is that writing a compiler as a relation, rather than as a traditional function, yields a DSL lifter "for free". We implement this idea by rewriting the verified Lustre-to-C compiler Vélus in the Walrus relational programming language. This solves what we call the vertical lifting problem, translating canonical C into Lustre. To address the complementary horizontal problem-handling real-world C outside the compiler's image-we apply semantic-preserving canonicalization passes in Haskell. The resulting tool, the CoCompiler, supports lifting real reactive C code into Lustre and onward into graphical behavioral models. Our approach is modular, language-agnostic, and fast to implement, demonstrating that relational programming offers a practical foundation for building DSL lifters by repurposing existing compilers.
title The CoCompiler: DSL Lifting via Relational Compilation
topic Programming Languages
url https://arxiv.org/abs/2510.00210