EUVIMEDEUVIMED entdecken
Open Access · CC BY 4.0

Cascaded Neurosymbolic Code Generation for Niche DSLs: Preserving Chain-of-Thought in Grammar-Constrained Decoding

Rubén Ruiz-Torrubiano, Himanshu Buckchash, Sarita Paudel, Deepak Dhungana

Software · 28.07.2026 · 5 (3) · 33

DOI: 10.3390/software5030033 ↗

Kurz gefasst

Fachartikel in der Zeitschrift Software, online erschienen am 28.07.2026. Verfasst von Rubén Ruiz-Torrubiano und 3 weiteren Autor:innen. Die Arbeit nennt 28 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY 4.0).

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

Domain-Specific Languages (DSLs) are essential in software engineering for safely expressing complex domain logic. However, Large Language Models (LLMs) struggle to generate syntactically and semantically correct code for niche DSLs due to sparse representation in pre-training corpora. While Grammar-Constrained Decoding (GCD) resolves syntactic hallucinations by masking logits through a formal Context-Free Grammar (CFG), empirical evidence shows that strict GCD disrupts the autoregressive Chain-of-Thought (CoT) reasoning of modern models, frequently forcing them into irreversible semantic dead-ends. To overcome the friction between internal neural reasoning and external symbolic constraints, we propose a Dual-Phase Cascaded Neurosymbolic framework. In the first phase, the model is provided with dynamically injected grammar rules and is permitted to reason unconstrained, producing an optimistic code draft. If the draft fails native compiler checks, the system enters a second phase: it preserves the successful semantic reasoning from Phase 1 but re-generates the code under strict GCD enforcement. This cascaded architecture utilizes the formal FSM not as an adversarial constraint, but as a localized syntax repair engine guided by the model’s own prior reasoning. We construct a comprehensive benchmark of 100 MiniZinc constraint programming tasks and evaluate our approach using a pass@k metric with a strict semantic LLM judge. Our findings demonstrate that this dual-phase “think-then-constrain” approach significantly outperforms zero-shot, pure few-shot, and pure GCD baselines, achieving highly reliable, training-free code generation for unseen DSLs.

Zitieren

APA

Ruiz-Torrubiano, R., Buckchash, H., Paudel, S., & Dhungana, D. (2026). Cascaded Neurosymbolic Code Generation for Niche DSLs: Preserving Chain-of-Thought in Grammar-Constrained Decoding. Software, 5(3), 33. https://doi.org/10.3390/software5030033

Vancouver

Ruiz-Torrubiano R, Buckchash H, Paudel S, Dhungana D. Cascaded Neurosymbolic Code Generation for Niche DSLs: Preserving Chain-of-Thought in Grammar-Constrained Decoding. Software. 2026;5(3):33. doi:10.3390/software5030033

BibTeX
@article{RuizTorrubiano2026,
  author = {Ruiz-Torrubiano, Rubén and Buckchash, Himanshu and Paudel, Sarita and Dhungana, Deepak},
  title = {Cascaded Neurosymbolic Code Generation for Niche DSLs: Preserving Chain-of-Thought in Grammar-Constrained Decoding},
  journal = {Software},
  year = {2026},
  volume = {5},
  number = {3},
  pages = {33},
  doi = {10.3390/software5030033}
}
Kostenlos starten →