Manuscript Offprint

arXiv:2611.05168

DSL-Bench: Evaluating and Explaining LLM Code Generation Across Domain-Specific Languages

Zihan Zhou, Mingxi Ye, Yan Gao, Guipeng Wei, Zibin Zheng

Zihan Zhou, Mingxi Ye, Yan Gao, Guipeng Wei, and Zibin Zheng

Sun Yat-sen University

Abstract—Large language models (LLMs) are increasingly used in software-engineering workflows, making reliable evaluation of LLM code generation important. Existing benchmarks largely focus on general-purpose languages, yet software systems in a wide range of real-world application domains rely on domain-specific languages (DSLs) with their own syntax, semantics, and validation requirements. Benchmarks designed for individual DSLs provide useful domain-specific evidence, but their designs and metrics are difficult to compare across DSLs. We present DSL-Bench, an executable benchmark and analysis framework for cross-DSL code generation. Starting from 13,045 DSL-related papers, LLM-assisted open card sorting yields 18 representative application domains. For each domain, we select an evaluable DSL and instantiate a corresponding syntax checker and task-level semantic oracle. Evaluating 7 LLMs on 18 DSLs, we observe a mean syntax pass rate of 31.37% and a mean semantic pass rate of only 11.64%, demonstrating a large gap between syntax acceptance and semantic correctness. A variance decomposition shows that differences among DSLs account for 76.99% of the variation in semantic pass rate, whereas differences among models account for 7.86%. To characterize this variation, we analyze four DSL-level factors. Knowledge Demand shows the largest negative association with semantic correctness (r=−0.508r=-0.508). To assess intervention strategies, we test prompt engineering across all 18 DSLs and additionally evaluate five methods on five targeted DSLs. Prompt engineering yields uneven gains. In the five targeted DSLs, the strongest targeted method, RAG-Refinement, improves semantic correctness by 16.29 percentage points on average. We further derive diagnostic capability profiles and DSL-Profiler summaries for interpreting data-scarce DSLs. These results show that cross-DSL code generation is limited by toolchain-specific semantic bottlenecks and should be evaluated beyond syntax-level acceptance.

Index Terms—Domain-specific languages, code generation, large language models, benchmark, semantic validation

I. INTRODUCTION

Existing large language model (LLM) code generation benchmarks mainly evaluate general-purpose programming languages (GPLs). As LLMs are increasingly used to generate, repair, and assist with code, these benchmarks have become important for comparing models, exposing failure modes, and guiding coding agents. Benchmarks such as HumanEval, MBPP, APPS, MultiPL-E, DS-1000, and repository-level repair suites have shaped how the community measures LLM coding capability [1]–[8]. Subsequent work has extended this evaluation landscape to broader domains, richer context, different code granularities, stronger tests, and contamination control [9]–[11].

Evaluating LLM performance on domain-specific language (DSL) code generation is also important, since a wide range of real-world software-engineering domains rely on DSLs. A DSL is a programming language tailored to a particular application domain, trading generality for domain-specific expressiveness [12]. DSLs appear in hardware design, formal verification, infrastructure configuration, database and graph querying, workflow modeling, behavior modeling, and scientific computing. Examples include Verilog for hardware design [13], Lean for theorem proving [14], and Cypher for graph queries [15]. A DSL is not simply a low-resource GPL or a GPL with a domain library. It encodes domain abstractions, toolchain constraints, and semantic rules directly into the target notation.

Evaluating DSL code generation is difficult because DSL correctness is tied to domain-specific semantics and toolchains. For GPL benchmarks, generated programs are often evaluated through execution tests in relatively common programming environments, but test strength still affects the reliability of the conclusions [16], [17]. For DSLs, the evaluator often needs a domain-specific checker or oracle. Verilog generation depends on hardware simulation, Lean and Dafny depend on proof checking, infrastructure-as-code depends on resource and configuration constraints, and Cypher depends on graph-query results [13]–[15], [18], [19].

Although a few benchmarks have been proposed for specific DSLs, cross-DSL LLM behavior remains unclear. Prior work has studied hardware description [13], theorem proving [14], [18], infrastructure configuration [19], smart contracts [20], graph query [15], and other DSL settings. These benchmarks are designed around their own tasks, oracles, metrics, and model sets. As a result, they cannot easily show how LLM performance varies across DSLs, which DSL properties explain this variation, or which improvement strategies work under different DSL bottlenecks.

Therefore, evaluation results are needed from multiple DSLs under the same set of LLMs and testing conditions. Improvement methods also need to be tested across DSLs, so that their cross-DSL effects can be analyzed.

To meet this need, we present DSL-Bench, an executable benchmark and analysis framework for LLM code generation across DSLs. DSL-Bench is constructed through a literature-based domain selection process and executable benchmark design. Starting from 13,045 DSL-related papers, we identify representative application domains and select 18 evaluable DSLs. For each DSL, we instantiate or adapt a syntax checker and a task-level semantic oracle, then evaluate the same set of LLMs under the same testing conditions. DSL-Bench also analyzes DSL-level factors and tests improvement methods across DSLs, so that baseline performance and intervention effects can be studied together.

Figure 1 summarizes the overall DSL-Bench workflow and main outputs.

The results show that syntax acceptance substantially overestimates task-level correctness. Across the 18 DSLs and seven evaluated LLMs, the mean syntax pass rate is 31.37%, while the mean semantic pass rate is only 11.64%. LLM performance is also strongly shaped by the target DSL. Differences among DSLs account for 76.99% of semantic pass-rate variation, compared with 7.86% for differences among models. Among the four DSL-level factors analyzed in this study, the Knowledge Demand factor has the strongest negative association with semantic correctness (r = -0.508). Improvement gains are also bottleneck-dependent. Prompt engineering gives uneven gains across DSLs, while RAG-Refinement is the most effective targeted method in the five targeted DSLs. These analyses further support diagnostic model capability profiles and a DSL-Profiler summary for data-scarce DSL triage.

In summary, this paper makes the following contributions:

We build DSL-Bench, an executable benchmark covering 18 representative DSLs, with syntax checkers and task-level semantic oracles for evaluating the same set of LLMs under the same testing conditions.

  • We provide cross-DSL evidence on LLM code generation, showing a large gap between syntax acceptance and task-level semantic correctness and showing that performance varies more by DSL than by model.

  • We analyze DSL-level factors and improvement methods, showing that Knowledge Demand is strongly associated with lower semantic correctness and that method gains are shaped by DSL-specific knowledge and semantic bottlenecks.

  • We derive diagnostic model capability profiles and DSL-Profiler summaries for triaging data-scarce DSLs.

The remainder of this paper is organized as follows. Section II gives the background needed for DSL-Bench. Section III describes the construction of DSL-Bench. Section IV presents the baseline evaluation setup and results. Section V analyzes the observed performance variation, and Section VI evaluates improvement methods under DSL bottlenecks. Section VII discusses threats to validity, Section VIII reviews related work, and Section IX concludes.

References (65)