Synsema: Syntax-Guided Learning of Semantically Valid Programs
Levin Winter, Cong Li, Hao Sun, Zhendong Su
NeurIPS 2026
Abstract. Generating effective inputs for testing systems that process highly structured data, such as compilers, is difficult due to the combination of syntactic and semantic constraints. Traditional approaches rely on manually crafted rules that require deep domain expertise and are difficult to maintain, while modern machine learning methods have to learn syntax and semantics simultaneously, which is challenging. We present Synsema, a novel approach that combines insights from both worlds by reformulating the generation of semantically valid programs as a syntax-guided reinforcement learning task. With syntax guaranteed by construction, even a small, randomly initialized model can rapidly learn semantic constraints in a drastically reduced space, enabling effective compiler testing. We implement our approach in the context of Java and Rust, which both exhibit strict semantic requirements, and train an agent to generate interesting and well-formed programs using fine-grained semantic feedback. Applied to compiler testing, we systematically compare different syntax-guided generation procedures with an unconstrained baseline and show that, by restricting the sampling space, Synsema learns semantic rules efficiently. While an average of only 0.03% of programs generated by the baseline are semantically valid, Synsema produces a diverse set of programs with a 7.29% success rate that trigger 2.6x more compiler behaviors. In addition, Synsema discovered 5 previously unknown bugs in production compilers, validating the practical impact of our approach.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:44 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
The reviewers appear to accept the basic premise of the paper, specifically that learning programming language semantics can help generate compiler test cases. However, there are some substantial concerns:
The entire setup seems somewhat archaic. Would a modern LLM have made the problem irrelevant through its knowledge of Rust and Java? A success rate of 7.29% generated programs compilable seems low with modern technology.
The experiments measure compilability, not conformance to semantics. What evidence is there for learning semantics? Or, is this just not a goal and the only goal is to find programs that crash the compiler?
A stronger comparison with existing test generation techniques would help - does the technique discover bugs these previous techniques would not have discovered, and is there a quantitative measure somewhere that would make this argument more precise?
Better compiler coverage results would help as suggested by the reviewers.
The response period was very productive and reviewers were unanimous that this paper can be accepted. I strongly urge the authors to pay attention to the reviews and the responses as they prepare a revision as I anticipate that we can expect to see the paper significantly improved during the revision along the lines suggested in the reviews.
Final justification
Rebuttal answered reviewers questions and surfaced new interesting results that justify acceptance.
Read meta-review
Meta-review
The reviewers appear to accept the basic premise of the paper, specifically that learning programming language semantics can help generate compiler test cases. However, there are some substantial concerns:
The entire setup seems somewhat archaic. Would a modern LLM have made the problem irrelevant through its knowledge of Rust and Java? A success rate of 7.29% generated programs compilable seems low with modern technology.
The experiments measure compilability, not conformance to semantics. What evidence is there for learning semantics? Or, is this just not a goal and the only goal is to find programs that crash the compiler?
A stronger comparison with existing test generation techniques would help - does the technique discover bugs these previous techniques would not have discovered, and is there a quantitative measure somewhere that would make this argument more precise?
Better compiler coverage results would help as suggested by the reviewers.
The response period was very productive and reviewers were unanimous that this paper can be accepted. I strongly urge the authors to pay attention to the reviews and the responses as they prepare a revision as I anticipate that we can expect to see the paper significantly improved during the revision along the lines suggested in the reviews.
Final justification
Rebuttal answered reviewers questions and surfaced new interesting results that justify acceptance.
1 comment
- Rating
- 3/6
- Confidence
- 4/5
- Quality
- 2/4
- Clarity
- 3/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The authors argue that existing learning-based approaches must simultaneously learn both syntax and semantics, which is highly inefficient because syntactically valid programs occupy only a tiny fraction of the overall token space. To address this issue, the paper proposes SYNSEMA, a syntax-guided reinforcement learning framework that explicitly separates syntactic correctness from semantic learning. The key idea is to leverage a context-free grammar (CFG) to constrain the action space of an RL agent such that all generated programs are syntactically valid by construction. Under this formulation, the agent only needs to learn semantic constraints through compiler feedback. This paper presents an interesting integration of grammar-based generation and reinforcement learning for program synthesis and compiler fuzzing. The paper explores three grammar-guided generation mechanisms based on top-down (LL), bottom-up (LR), and chart-based (Earley) parsing algorithms, resulting in different action representations and constrained action spaces. Semantic learning is driven by compiler-derived rewards, including penalties based on compilation diagnostics and positive rewards derived from compiler coverage novelty. In experiments, the authors verify that constraining the generation process with syntax substantially reduces the search space and enables more effective learning of semantic validity compared to unconstrained token-level generation.
Strengths and weaknesses
Strengths
-
The paper presents a clean and intuitive formulation that separates syntactic validity from semantic learning by incorporating grammar constraints into the reinforcement learning process. The overall framework is easy to understand and well motivated for compiler testing.
-
The paper evaluates multiple grammar-guided generation strategies based on different parsing algorithms and demonstrates the practical utility of the approach on real-world compilers.
Weaknesses
-
A central claim of the paper is that the proposed framework learns program semantics. However, the evidence provided mainly demonstrates improved compilation success rates. The reward signal is entirely derived from compiler acceptance, diagnostics, and coverage information, making it unclear whether the model learns semantic concepts or simply learns to generate patterns that satisfy compiler-specific validity checks. More broadly, compilation success is a relatively weak proxy for semantic understanding.
-
It is unclear whether syntax-guided constraints need to be incorporated during training at all. Many modern constrained generation approaches enforce syntactic validity during decoding by masking invalid tokens according to a grammar while leaving the underlying model training unchanged. The paper does not provide evidence that integrating grammar constraints into the RL training process yields benefits beyond what could be achieved through inference-time constrained decoding alone. As a result, the necessity of the proposed training formulation remains insufficiently justified.
-
The experimental setting focuses exclusively on unconditional program generation. Without any specification, prompt, or downstream task, it is difficult to assess whether the model has learned meaningful semantic relationships beyond compiler acceptance patterns. Furthermore, unconditional generation substantially limits the practical applicability of the framework compared to more realistic program-generation settings where generation is conditioned on user intent, requirements, or existing code context.
-
The empirical evaluation is conducted using a randomly initialized GPT-2 model with only 124M parameters. Given that contemporary code generation systems are typically built upon substantially larger pretrained models, it remains unclear whether the observed findings would transfer to modern foundation models. Consequently, the practical relevance of the proposed approach in today's code-generation landscape is somewhat limited.
Questions
-
The proposed approach relies on context-free grammars and parser-specific structures (e.g., LL/LR productions and parsing tables). How were these grammars and parsing tables obtained for Rust and Java in practice? Were they directly derived from existing compiler specifications, automatically generated from publicly available grammar definitions, or manually adapted? Additionally, how much engineering effort is required when extending the framework to a new programming language?
-
A central claim of the paper is that the agent learns semantic constraints. Could the authors provide additional evidence that the learned behavior goes beyond merely generating compiler-accepted patterns? For example, are there analyses showing that the model learns specific semantic concepts (e.g., typing rules, scope resolution, ownership constraints) rather than simply exploiting frequent compilable structures?
-
What advantages are gained by incorporating grammar constraints during RL training rather than applying grammar-constrained decoding only at inference time? Have the authors considered or evaluated a baseline where the model is trained normally and syntax validity is enforced solely through decoding-time masking?
-
The experiments are conducted using a randomly initialized GPT-2 model with 124M parameters. Do the authors expect the proposed framework to remain beneficial when applied to modern pretrained code models or large language models that already possess substantial syntactic and semantic knowledge? If so, what modifications would be necessary to integrate SYNSEMA with such models?
Limitations
yes
Formatting concerns
N/a
3 comments
Thank you for your detailed review, and for finding our formulation clear and well motivated and our evaluation demonstrative of real-world utility.
Q1: Grammar efforts. Grammars specifying the syntax of programming languages are widely available [1]. Synsema is compatible with existing formats such as Yacc, which serve all three representations (Top-Down, Bottom-Up, Chart). Otherwise, another format or the official specification can be mechanically transformed into a supported one, taking a single person 1-3 hours per language. Our evaluation grammars are based on the official specifications.
Beyond a grammar, supporting a new language requires source coverage information and machine-readable compilation errors. We provide generic LLVM and JVM instrumentations for the former, and most compilers emit the latter out of the box. We estimate 1-3 days of effort per new language. Synsema’s implementation is reusable and can be easily extended to new targets.
Unlike traditional tools such as Csmith, RustSmith, or Rustlantis, no manual specification of the semantics is needed: the agents learn to conform to them through RL.
Q2/W1: Semantic features. Please refer to the AC rebuttal.
Q3/W2: Constrained decoding. “Training the model normally” could mean (1) conventional pre-training on a dataset, or (2) running Synsema’s RL loop without action masking. In either case, grammar-constrained decoding [2] is then applied at inference time.
-
The first is worth considering. However, constrained decoding usually creates a mismatch between the model’s learned distribution and the one induced by forced token selection [3]. This mismatch often degrades performance under complex constraints, particularly for instruction-tuned or small language models [4,5,6]. Recent work therefore augments it with few-shot examples [5,6,7], unconstrained decoding [5], or post-processing [8]. Applying these to compiler testing remains challenging: they mainly yield common, in-distribution programs, where compilers rarely fail.
-
The second is equivalent to applying constrained decoding to our existing baseline, which learned neither syntactic nor semantic constraints: only 336 of its programs compile, and these contain only trivial constructs, providing little learning signal. Constrained decoding on this policy is therefore unlikely to outperform the semantics-agnostic random policy from our AC rebuttal, which neither exercises interesting language features nor achieves comparable coverage. Receiving next to no positive reward, a normally trained RL agent cannot learn to conform to the semantics, so we expect the unmasked baseline with inference-time constrained decoding to behave similarly.
We integrated constrained decoding into the RL training loop itself, in both actors and learner: the actors perform inference and need action masking to guarantee syntactic validity, a core goal of our approach. The learner must apply the same masking to calculate the next optimal action, as its value estimates would otherwise depend on unreachable actions.
Q4/W4: Connection with SOTA LLMs. Yes, and we believe this is a very promising direction! SOTA LLMs have two advantages: more sophisticated architectures, which Synsema can directly leverage, and extensive pre- and post-training. Their understanding of a language’s semantics would help Synsema, but is not sufficient for compiler testing: they learn the distribution of common programs, which are less likely to expose compiler bugs. Synsema instead trains agents to generate semantically valid programs with no prior notion of what is typical, incentivizing them to explore and exploit all of a language's semantics which is a different objective.
W3: Unconditional program generation. We did not evaluate the conditional setting, as it falls outside the scope of our current evaluation. We do consider it a promising direction for extending Synsema to other scenarios, such as code completion! There, prompts, datasets, and pre-trained LLMs could all be integrated to generate semantically valid, interesting programs.
[1] ANTLR. Grammars-v4. https://github.com/antlr/grammars-v4.
[2] Geng et al. Grammar-Constrained Decoding for Structured NLP Tasks Without Finetuning. EMNLP23.
[3] Park et al. Grammar-Aligned Decoding. NeurIPS24.
[4] Schall et al. The Hidden Cost of Structure: How Constrained Decoding Affects Language Model Performance. RANLP25.
[5] Sakota et al. Combining Constrained and Unconstrained Decoding via Boosting: BoostCD and Its Application to Information Extraction. EMNLP25.
[6] Ferrazzi et al. Small LLMs for Medical NLP: A Systematic Analysis of Few-Shot, Constraint Decoding, Fine-Tuning and Continual Pre-Training in Italian. LREC26.
[7] Poesia et al. Synchromesh: Reliable Code Generation from Pre-Trained Language Models. ICLR22.
[8] Princis et al. TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation. PLDI26.
Thank you for the response and the additional clarifications. However, the rebuttal does not sufficiently address my concerns regarding the comparison with current LLM-based constrained decoding methods and the corresponding performance evaluation. In its current form, I do not think the paper meets the standard for acceptance at NeurIPS. Therefore, I will maintain my original rating.
Thank you for the feedback. We understand that further comparison with current LLM-based grammar-constrained decoding methods would be helpful and therefore extended our analysis of the existing experiments with DeepSeek, Gemma, and the Fuzz4All harness, originally presented in the Comparing with LLM-based baselines section of our response to the AC. Our new findings show that inference-time-only constrained decoding is less effective in our scope, i.e., generating effective test cases for compiler testing:
-
In the absence of grammar-constrained decoding, both DeepSeek and Gemma already generated over 99% syntactically valid programs, suggesting that such constraints offer limited benefit for modern LLMs. Therefore, we have no reason to expect different results had these experiments used grammar-constrained decoding.
-
Moreover, despite being syntactically valid, the DeepSeek- and Gemma-generated programs tend to be relatively common compared with
rustc’s regression test suite, Synsema-generated programs, and Synsema-discovered bugs, even when steered by the Fuzz4All harness to encourage uncommon test cases effective for compiler testing. To investigate this, we estimate the likelihood of semantically valid Rust programs generated by Synsema, Gemma, and DeepSeek. As a proxy for the distribution of developer-written programs, we use the pretrained base model of Qwen3-8B, which is not used in any of our experiments, and compute the program’s negative log-likelihood (NLL) in nats/token. The table below reports the median NLL for programs with similar lengths, where higher NLL indicates that a program is less likely under the model. Perplexity = exp(NLL), so a difference of 0.1 nats/token corresponds to roughly a 10% difference in perplexity.Length Synsema Gemma DeepSeek Syn. Bug Rust Tests <16 6.11 - - 7.31 5.52 16 - 31 4.71 - - 5.62 3.67 32 - 63 3.57 - - 4.16 2.26 64 - 127 2.51 - 1.87 3.10 1.62 128 - 255 1.85 0.74 0.92 1.91 1.16 256 - 511 1.33 0.63 0.69 1.58 0.67 Note:
- We exclude programs dominated by macro definitions because unexpanded macro bodies contain arbitrary token sequences that naturally lead to high NLL/perplexity.
- We filter out buckets with fewer than 10 samples, as the data is otherwise unrepresentative.
We find that, compared to
rustc’s regression tests (see the “Rust Tests” column), Synsema-generated programs consistently have higher NLL/perplexity, while programs generated by Gemma and DeepSeek using Fuzz4All tend to have lower NLL/perplexity. This suggests that Synsema explores program regions less likely explored by a modern pretrained LLM and that, even when using a SOTA fuzzing harness, LLMs tend to generate more common programs.Our findings are further validated when examining the NLL/perplexity of Synsema-generated programs that cause
rustcto crash or time out (see the “Syn. Bug” column). This set of programs has the highest median NLL/perplexity. This finding is consistent with our bug-finding results: Synsema found 14 unique bugs, including five previously unknown, whereas DeepSeek found one and Gemma found none. Together, these results provide preliminary evidence that Synsema explores less common regions of the program space and that this exploration is effective for exposing compiler bugs.
We will make these points clearer in our revision.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 2/4
- Originality
- 2/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper presents an approach for generating test cases, or inputs, for testing compilers. The challenge here is generating "good" inputs, that is, well-formed programs that exercise all code paths of the compiler.
The main idea is to force the generators to only produce well-formed programs. For most programming languages, getting accepted by a context-free grammar (CFG) is the most basic constraint. The CFG is used to constrain the next token -- thus, the action space is constrained so that only syntactically well-formed programs are ever generated. Generating syntactically well-formed programs is not enough, one needs to generate programs that also pass some semantic checks enforced by the compiler, and furthermore, generate programs that activate new code paths in the compiler. The compiler is used to generate a reward that is used in an RL loop to update the policy.
The paper evaluates this idea to test Rust and Java compilers. They report finding 5 new bugs in these compilers.
Strengths and weaknesses
The paper presents a potent technique for bug finding in compilers. The overall approach sounds reasonable and each constituent is reasonably justified. The evaluation results are good; in particular, the fact that the authors found 14 crashes out of which 5 are new crashes is indeed impressive and shows the value of the approach.
The approach for generating syntactically correct programs reminds me of the ICLR 2022 paper titled Synchromesh. The authors can consider discussing it - especially since it also "enforced" syntactic (and some semantic) correctness by constraining next token using CFG parsing technology.
One interesting aspect of this work is the "bi-modal" reward - when the compiler detects an error, the problematic tokens identified by the compiler are used to penalize the corresponding actions. On the other hand, when the compiler does not detect and error, the novelty score is assigned as a reward to the final action. This is intriguing since it is not clear how this will generalize to testing programs that are not compilers.
One aspect that was confusing when one starts reading the paper is the "circular" reasoning of "testing compilers" using the compiler itself. Suppose the compiler has a bug and did not implement the language specification correctly. Say, a program that was supposed to be type incorrect is incorrectly judged as type correct by the compiler. These kinds of bugs will not be revealed by Synsema, isn't it, because of circular reasoning -- the compiler is used as a specification while it is simultaneously being tested against some larger implicit specification. This point is a source of confusion initially.
Questions
-
How much work was it to gather "coverage" score from a compiler? Did you have to annotate the compiler to generate coverage information?
-
There is plenty of work on testing compilers (such as C compilers). Some of these works have been cited too. It is mentioned they rely on "complex generation logic" -- it will be good to know if they would have discovered these bugs, and if not, any particular reason why not?
-
The main argument against existing work is that they require "huge manual effort" -- it will be good to get some validation for that claim. Maybe by lines-of-code or developer effort reported, and compare that with the same metric here. This also brings us back to Question 1.
-
It is not clear what is the starting point here in terms of the model. Line 224 says "We employ GPT-2", and then Line 226 says "randomly initialized weights" and Line 344 says "we did not adopt any pretrained model". Isn't GPT-2 a pretrained model? Or did you only use that architecture as seems to be suggested by theat starting with random weight comment.
Other comments:
Figure 1: y * z . Shouldn't y also be inside a red box?
Limitations
Yes
Final justification
I thank the authors for their response. Overall, there is some merit in this work - it shows that one can learn a policy using RL based on compiler feedback to generate diverse programs that can expose compiler bugs. However, I am slightly less enthusiastic about the paper than before. The main reason is that the rebuttal breaks my mental model of the work. The RL approach here is rewarding syntactic correctness and code coverage. And this was shown to expose compiler crashes. But the experiments reported during the rebuttal show that a fuzzer powered by pretrained models can do better on the code coverage metric, but yet it fails to detect crashes. Given this new evidence, I am not sure why the proposed approach works. I think there is deeper analysis needed here into the detected crashes/bugs (as was also suggested by another reviewer) to get full clarity on the proposed approach.
Formatting concerns
No
1 comment
Thank you for your review and for recognizing Synsema’s value!
Q1. Coverage effort. Compilers must be instrumented to signal whenever a control-flow-graph edge is traversed. We used LLVM’s SanitizerCoverage for Rust and JaCoCo for Java; neither requires source-level annotations. Both are standard ecosystem tools, and much of our instrumentation code is reusable for other compilers written in C/C++ or Java, so supporting a new compiler should take only a few hours of engineering effort.
Q2. Bug discovery. The Rust bugs Synsema found are beyond the reach of existing rustc fuzzers. RustSmith [1] does not model the necessary semantic features, e.g. generics (see bug in Figure 5), while Rustlantis [2] operates on MIR, the intermediate representation of rustc, where source-level semantic features are already erased. The same holds for our Java bugs and javac fuzzers such as Hephaestus [3]. Extending these fuzzers would require substantial manual effort to encode the corresponding semantic constraints and ensure program validity. LLM-based fuzzers such as Fuzz4All [4] might also find these bugs, but the large search space (Figure 1) and their tendency to generate common programs make this unlikely within a practical time budget.
Q3. Manual effort. LoC of SOTA traditional compiler fuzzers:
| Compiler | Fuzzer | Venue | Language-Specific | LoC |
|---|---|---|---|---|
| gcc/clang | Csmith | PLDI’11 | Yes | 32K |
| gcc/clang | Reify | PLDI’26 | Yes | 7K |
| rustc | RustSmith | ISSTA’23 | Yes | 4.2K |
| rustc | Rustlantis | OOPSLA’24 | Yes | 7.3K |
| javac | Hephaestus | PLDI’22 | Yes | 12K |
| rustc+javac | Synsema | -- | No | 7.2K |
All of them are language-specific: they explicitly model their target language’s syntactic and semantic constraints. Only ~2K of Synsema’s 7.2K LoC are language-specific, mostly coverage-collection support and two YACC grammar files for Rust and Java.
Q4: GPT-2. Synsema uses GPT-2’s architecture, not a pretrained checkpoint, and the weights are randomly initialized. We will make this explicit in the revision.
Generalizing “bi-modal” reward. Thank you for this interesting question! Generalization is possible whenever errors (i.e. non-conformance to the semantics) can be mapped to specific parts of the input, which diagnostics usually allow: databases report which part of the SQL was invalid, file viewers report the byte they could not read, and crashing software emits a stacktrace. We are therefore confident the reward transfers to many diverse settings.
Synchromesh. Both Synchromesh and Synsema guarantee syntactic validity by construction via parsing techniques, but differ in how they constrain token generation and maintain semantic validity.
Synchromesh uses inference-time constrained decoding to ensure syntactic correctness and partially enforce semantic validity. While syntactic constraints can be derived automatically from grammars, Synchromesh still requires semantic constraints to be encoded manually. Constrained decoding also alters the pretrained model’s next-token distribution, potentially yielding lower-quality or invalid outputs [5,6]. Synchromesh mitigates this by adding semantically similar examples into the prompt.
In contrast, Synsema casts syntax-guaranteed program generation for compiler testing as an RL problem: it automatically derives syntactic constraints from grammars and uses compiler feedback to assess semantic validity. This enables Synsema to use a standard RL algorithm and a 124M model trained from scratch for five days on consumer-grade RTX 4090 GPUs. Despite this modest setup, Synsema generates semantically interesting programs and finds 14 unique bugs in two production-grade compilers, five previously unknown.
"Circular" reasoning. This is a great point, thank you for raising this! Synsema uses compiler feedback as a proxy for semantic validity, not as a complete language specification. Hence, if a compiler incorrectly accepts a semantically invalid program and exhibits no other observable failure, Synsema may miss it. This can be addressed by adding differential testing: disagreements between compiler implementations/versions or specification checkers then signal such conformance bugs. We will discuss this in the revision.
Figure 1. We will fix this, thank you!
[1] Sharma et al. RustSmith: Random Differential Compiler Testing for Rust. ISSTA23.
[2] Wang et al. Rustlantis: Randomized Differential Testing of the Rust Compiler. OOPSLA24.
[3] Chaliasos et al. Finding Typing Compiler Bugs. PLDI22.
[4] Xia et al. Fuzz4All: Universal Fuzzing with Large Language Models. ICSE24.
[5] Sakota et al. Combining Constrained and Unconstrained Decoding via Boosting: BoostCD and Its Application to Information Extraction. EMNLP25.
[6] Princis et al. TreeCoder: Systematic Exploration and Optimisation of Decoding and Constraints for LLM Code Generation. PLDI26.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 2/4
- Clarity
- 3/4
- Significance
- 2/4
- Originality
- 2/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper presents SYNSEMA, a syntax-guided reinforcement learning framework for generating semantically valid programs, with compiler testing as the main target application. The key idea is to separate syntax from semantics: context-free grammars and parser-derived action spaces ensure syntactic validity by construction, while an RL agent learns from compiler diagnostics and coverage feedback to generate programs that are more likely to compile and exercise diverse compiler behavior. The paper instantiates this idea with three syntax-guided agents based on top-down/LL, bottom-up/LR, and chart/Earley parsing, and evaluates them on Java and Rust compilers. The results show that SYNSEMA produces substantially more compilable programs than an unconstrained token-level RL baseline, improves compiler edge coverage, and discovers several previously unknown compiler bugs.
Strengths and weaknesses
Strengths
The paper studies an important and practical problem: generating valid and interesting programs for testing compilers and other systems that process highly structured inputs. The separation between syntactic validity and semantic validity is well motivated. Using grammars to reduce the action space is a natural way to avoid many early syntax failures, and using compiler diagnostics and coverage as feedback provides a useful learning signal for program generation.
The paper is also relatively clear in its presentation. The three action-space designs based on top-down, bottom-up, and chart parsing are explained well, and the comparison among these choices is a useful part of the paper. The implementation appears nontrivial, and the evaluation on both Rust and Java makes the empirical study more convincing than a single-language setup. The fact that the system finds previously unknown compiler bugs is a positive sign for its practical potential.
Weaknesses
1. The novelty over existing grammar-based generation and fuzzing methods is not sufficiently established.
Grammar-constrained program generation is a well-established idea in grammar-based fuzzing, semantic-aware program generation, and neural code generation. Recent work such as [1] further shows that grammar/AST-based code representations have been explored in billion-scale LLMs, not only for syntactic validity but also for improving semantic differentiation. In this context, SYNSEMA’s novelty appears to lie less in grammar-guided generation itself, and more in combining grammar-constrained action spaces with compiler diagnostic feedback, coverage-based rewards, and an RL loop for Java/Rust compiler testing. The paper would be stronger if it more explicitly clarified which component is the main technical contribution: the LL/LR/Earley action-space comparison, the mapping from compiler diagnostics to RL actions, the semantic-learning formulation, or the compiler-testing application.
2. The main baseline is too weak to support the stronger empirical claims.
The primary baseline is an unconstrained token-level RL agent trained from scratch. This baseline needs to learn both syntax and semantics only from compiler feedback. For languages such as Java and Rust, it is expected that such a model will generate mostly syntactically invalid programs. Therefore, the large improvement in compilable-program rate mainly shows that grammar guidance is useful compared with no grammar guidance for a from-scratch RL generator.
This is a valid and useful result, but it supports a narrower conclusion than the paper seems to suggest. It does not show that SYNSEMA is better than practical grammar-guided generators, grammar-aware coverage fuzzers, semantic-aware fuzzers, or existing compiler-testing tools. To better isolate the contribution of the RL policy, the paper should include stronger baselines such as grammar-guided random generation, grammar-guided coverage-based fuzzing without RL, and existing grammar/semantic-aware fuzzers where applicable. Without these comparisons, it is difficult to tell whether the main gains come from learning semantics, or simply from enforcing syntactic validity.
3. The paper does not compare against modern SOTA LLMs on program generation.
The paper motivates itself partly against language-model-based program generation, but the underlying model used in SYNSEMA is a randomly initialized GPT-2 124M model rather than a pretrained code LLM. Modern code LLMs already encode substantial syntax and semantic knowledge about Java and Rust. Although LLM sampling may have lower throughput, each generated sample may be more semantically meaningful or structurally complex.
Therefore, it remains unclear whether SYNSEMA would outperform SOTA LLM-based methods under a comparable practical budget. Useful baselines could include SOTA LLM sampling with compilation filtering, LLM-based compiler-error repair, LLM generation followed by coverage-guided selection, or LLM-based mutation of existing valid programs. The comparison should ideally be under matched wall-clock time or monetary budget. Without such baselines, the paper does not fully establish the practical advantage of SYNSEMA over modern LLM-based compiler testing.
4. The evidence for learning complex semantics is limited.
The paper often frames the task as learning semantic validity, especially for languages such as Rust with strict ownership, borrowing, lifetime, trait, and generic constraints. However, the main semantic metric is whether the generated program successfully compiles. Compilability is useful, but it is a coarse measure. A program can compile while avoiding most difficult semantic features, especially if the generator tends to produce short or simple programs.
The paper does not provide a feature-level analysis showing whether the generated valid programs actually exercise nontrivial semantic constraints. For Rust, it would be important to know how often valid generated programs contain ownership/borrowing interactions, lifetime annotations, trait bounds, generic constraints, macros, const generics, unsafe code, or other difficult language features. Without such analysis, the claim that the model learns semantics should be stated more conservatively. The current evidence mainly shows that the model learns to increase compiler acceptance under a grammar-constrained and bounded generation setup.
5. The compiler coverage results are promising but hard to interpret.
The paper reports relative improvements in edge coverage, which is useful. However, it does not report the total number of instrumented compiler edges or the corresponding coverage percentage. For large compilers such as rustc and javac, absolute edge counts are difficult to interpret without knowing the denominator. It is therefore unclear how deep the exploration is in absolute terms.
The evaluation would be more informative if it reported coverage percentage, coverage per wall-clock time, coverage per GPU-hour, and perhaps unique edges per unique valid program. These efficiency metrics are important because the baseline generates many more programs but most are invalid, while SYNSEMA generates fewer programs but with a much higher valid rate. The current results show improvement, but they do not fully clarify the practical testing efficiency of the method.
Overall, the implementation and empirical study is interesting, and the results do show that syntax guidance is highly beneficial for from-scratch RL-based program generation. However, the current evaluation does not yet fully establish novelty or practical superiority over existing grammar-guided, semantic-aware, or LLM-based compiler testing methods. The strongest supported conclusion is that grammar-guided action spaces substantially improve a from-scratch RL generator; broader claims about semantic learning and compiler-testing advantage need stronger baselines and deeper analysis.
[1] Liang, Q., Zhang, Z., Sun, Z., Lin, Z., Luo, Q., Yueyi, X., ... & Xiong, Y. (2025, July). Grammar-based code representation: Is it a worthy pursuit for llms?. In Findings of the Association for Computational Linguistics: ACL 2025 (pp. 15640-15653).
Questions
-
What is the precise technical novelty of SYNSEMA compared with existing grammar-based and grammar-aware fuzzing/program-generation methods?
-
Could the authors compare against modern LLM-based program generation under matched wall-clock time or monetary budget? Relevant baselines include LLM sampling with compilation filtering, LLM-based compiler-error repair, and LLM generation combined with coverage-guided selection or mutation.
-
Could the authors provide a feature-level analysis of generated valid programs? For Rust, it would be useful to report how often programs involve ownership/borrowing, lifetimes, trait bounds, generics, macros, const generics, unsafe code, and other nontrivial language features.
Limitations
The paper includes a limitations section, which is appreciated. However, I think several limitations should be discussed more explicitly:
- The current evaluation mainly establishes the benefit of syntax guidance over an unconstrained from-scratch RL baseline, not necessarily over practical compiler fuzzing methods.
- The lack of comparison with modern LLM-based generation limits the conclusions about practical advantage.
- The generated programs are bounded in length and vocabulary, which may limit semantic and structural complexity.
- The paper does not sufficiently analyze whether generated programs exercise difficult semantic features such as Rust ownership, borrowing, lifetimes, traits, or generics.
Final justification
Thank you for the detailed response and additional experiments. I find the combination of grammar-guided generation, reinforcement learning, and compiler feedback well motivated, and the new results support that this combination provides benefits beyond syntax enforcement alone.
One remaining question is whether the increased use of features such as lifetimes, generics, and ownership translates into better exploration of compiler behaviors that are more likely to expose bugs. A more detailed analysis of the bug-triggering test cases, including the feature combinations or unusual program structures they require, would help clarify this point. The fact that DeepSeek achieves higher coverage but finds fewer reported bugs also suggests that coverage alone may not capture this distinction.
I also consider the cost-matched comparison with LLMs reasonably fair, since API pricing already amortizes the cost of pretraining.
Overall, the response has improved my view of the paper. I increased my score from 3 to 4.
Formatting concerns
No
3 comments
Thank you for the detailed assessment and constructive feedback, which our revision will incorporate.
Q1/W1: Technical novelty. We do not claim that grammar-constrained generation itself is novel. Synsema's technical novelty lies in a syntax-guaranteed RL formulation of program generation for compiler testing, which includes a parser-derived action space representation and a compiler feedback-based reward. Following this, Synsema, for the first time, systematically evaluates three different representations that reduce the sampling space by enforcing syntactic correctness. The proposed reward function shapes the space by steering the agent towards generating semantically correct programs.
Liang et al. [1] study AST-derived representations (such as pre-order traversals of AST nodes [IfNode,BlockStmt,...]) for pretrained language models. Although this is similar in spirit to our Top-Down setting, Synsema instead represents actions through parsing operations (such as [E->E Op E, E->NUM] and [reduce:E->NUM,shift PLUS,...] as shown in Table 1) and thoroughly explores the action-representation design space by comparing three representations drawn from the parsing literature. Furthermore, Synsema does not target general-purpose program generation for, e.g., code completion and refinement, but program generation for compiler testing. Under a resource-bounded setting, Synsema discovered 14 unique bugs, including 5 previously unknown, demonstrating its practical utility.
Our revision will clarify Synsema's overall technical novelty in Section 1, and cite and discuss Liang et al. in Section 5.
Q2/W2/L1/L2: SOTA LLM-based baselines. Please refer to the “Comparing with LLM-based baselines” section in our response to AC.
Q3/W2/W4/L4: Semantic features. We disagree that the current evidence mainly shows that the model learns to increase compiler acceptance. We agree that by only analyzing compilability, the agents could simply generate many simple programs. We therefore extended our evaluation and would refer the reviewer to the “Learning semantics” section in our response to AC.
W5: Coverage interpretation. Our instrumented rustc has 1,762,659 edges. Determining that for javac is difficult because it is written in Java itself and loads classes dynamically. Therefore, we follow AFL to hash the dynamic edge IDs into a bitmap with 65,536 bits. Hashing collisions make our Java coverage an underapproximation of the true number of exercised edges. After five days, Synsema exercises 148,685 (8.43%) edges in rustc, where 71,689 (4.07%) edges are exercised by compilable programs. The data for javac is 23,260 (35.49%) and 16,512 (25.20%). Note that achieving good edge coverage in production compilers is challenging: the official test suites for rustc reach only 283,040 edges (16.1%) in general and 184,113 edges (10.4%) for compilable programs. For javac, it is 29,969 (45.73%) in general and 27,056 (41.28%) for compilable programs. Synsema, after only five days of training, therefore achieves 38.9% of the performance of the official test suite for Rust and 61.0% for Java when considering semantically valid programs.
The coverage per wall-clock time is already reported in Figure 4, which shows its evolution throughout the five-day experiment. The coverage per GPU-hour can be derived from Figure 4 directly: each run uses two GPUs throughout, so t hours of wall-clock time correspond to 2t GPU hours.
L3: Bounded programs. Our paper acknowledges that generated programs have a bounded length and that our implementation uses a predefined subword vocabulary. While this theoretically bounds the semantic and structural complexity, they do not appear to be a limiting factor in practice. Empirically, we know that most compiler bugs are short programs with only a few identifiers, as reported by the Small-Scope Hypothesis [4] and state-of-the-art fuzzers/reducers [2-6]. Further, our experiments show that our approach was effective and found 14 unique bugs (5 previously unknown) in javac and rustc, two mature production compilers.
[1] Liang et al. Grammar-Based Code Representation: Is It a Worthy Pursuit for LLMs? ACL25.
[2] Yang et al. Finding and Understanding Bugs in C Compilers. PLDI11.
[3] Wang et al. Rustlantis: Randomized Differential Testing of the Rust Compiler. OOPSLA24.
[4] Oetsch et al. On the Small-Scope Hypothesis for Testing Answer-Set Programs. KR12.
[5] Sun et al. Toward Understanding Compiler Bugs in GCC and LLVM. ISSTA16.
[6] Regehr et al. Test-Case Reduction for C Compiler Bugs. PLDI12.
Thank you for the detailed response and additional experiments. I find the combination of grammar-guided generation, reinforcement learning, and compiler feedback well motivated, and the new results support that this combination provides benefits beyond syntax enforcement alone.
One remaining question is whether the increased use of features such as lifetimes, generics, and ownership translates into better exploration of compiler behaviors that are more likely to expose bugs. A more detailed analysis of the bug-triggering test cases, including the feature combinations or unusual program structures they require, would help clarify this point. The fact that DeepSeek achieves higher coverage but finds fewer reported bugs also suggests that coverage alone may not capture this distinction.
I also consider the cost-matched comparison with LLMs reasonably fair, since API pricing already amortizes the cost of pretraining.
Overall, the response has improved my view of the paper. I increased my score from 3 to 4.
Thank you for the positive feedback! We agree that a detailed analysis of our bug-triggering test cases is valuable, and we will include this analysis in our revision.
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Thank you for the initial assessment of our work!
Synsema’s central result is not simply that grammar constraints increase validity. Rather, when syntax is guaranteed by construction, even a small, randomly initialized model can rapidly learn interesting semantic constraints that enable effective compiler testing. Such constraints are traditionally hand-encoded as language-specific generation logic, or learned jointly with syntax from vast data and compute. Synsema instead uses a standard RL algorithm and a 124M scratch model trained for five days on consumer-grade RTX 4090 GPUs, yet generates semantically interesting programs and finds 14 unique bugs in two production-grade compilers, five previously unknown.
Learning semantics. In programming languages and compilers, "semantically valid" means conforming to the language specification, not understanding a program’s higher-level meaning. Like others, we use compilers as executable proxies of these semantics. Following Reviewer ECUS and 4xXL, we conduct two analyses to assess whether our agents learn semantic constraints.
First, we examine all compilable Rust programs for nontrivial language features. Second, for each action representation, we replace the learned policy with a random one, isolating policy learning from syntax enforcement alone. Each cell below is
X% | Y%: the fraction of semantically correct programs containing the feature under the learned (X) and the random (Y) policy, summed over three runs.The baseline agent's programs contained none of the semantic concepts we examined: trained with the same resources and reward function, it generated no non-trivial programs. All three Synsema agents exercise every feature, though with varying frequencies. Macros are most prevalent, as fewer semantic constraints apply to them. Lifetimes, generics, and unsafe occur in 0.98% to 9.67% of programs, while ownership, trait bounds, const generics, and higher-ranked lifetimes/trait bounds are rarer, from 0.001% to 2.74%.
The random-policy comparison shows that this diversity comes from the learned policy, not from syntax enforcement alone: it generates significantly more programs for every feature, sometimes by orders of magnitude, and achieves twice the edge coverage. Macros are the sole exception, but their dominance is inherent to the constrained space, and the learned policy in fact generates them less often in two of three representations. Synsema thus generates programs with diverse semantic features, not merely higher compiler acceptance.
Comparing with LLM-based baselines. Synsema is not intended to outperform SOTA techniques built on LLMs pretrained with far more data and compute. Still, as requested, we compare it against Fuzz4All [1], a popular LLM-based fuzzer that found 98 compiler bugs. We instantiate it with two pretrained models on the Rust compiler: DeepSeek V4 Pro (LLM) and Gemma 3 4B (SLM). We estimate one Synsema run at ~$100 and use this as the budget per Fuzz4All run, disregarding these models' immense pretraining costs (unfair to Synsema). DeepSeek has exhausted its budget; Gemma is still running and we will update these results.
Two observations:
DeepSeek exceeds Synsema’s coverage by 21%/75% (overall/semantically valid), while Gemma exercises 12% fewer edges overall and 22% more on semantically valid programs. Both are also better at generating compilable programs, unsurprisingly, given their pretraining on common program patterns. Still, they reach only up to 68.3% of the coverage of the Rust compiler’s test suites, despite $100 per model and the likely inclusion of those tests in their pretraining data.
Code coverage is a useful indicator of diversity, but not sufficient on its own to measure bug-finding capability: only DeepSeek finds one bug, whereas Synsema found 14, including 5 previously unknown.
These results further highlight Synsema’s effectiveness and cost efficiency: learning semantic constraints under syntax-by-construction enables effective compiler testing with limited compute.
[1] Xia et al. Fuzz4All: Universal Fuzzing with Large Language Models. ICSE24.