Abstract
Syntax errors are a significant barrier for novice programmers and a common issue in AI-generated code. This paper introduces Iaso, an automated program repair (APR) tool specifically designed to rectify syntax errors in C programs. Iaso integrates three core components: a Syntax-based Code Generator (SCG), an Error Localization Model (ELM), and an Ensemble Code Repair Assistant (ECRA). By training on over 1.3 million synthetically generated, compilable programs derived from Abstract Syntax Trees (ASTs), Iaso achieves state-of-the-art performance. Evaluation on the DeepFix and Tracer benchmarks shows that Iaso achieves a 78.8% and 91.0% repair rate, respectively, outperforming Google’s PaLM and performing competitively with ChatGPT while requiring significantly fewer resources and producing more precise, minimal edits.
Introduction
For students learning to code, the "syntax barrier" often precedes the challenge of algorithmic logic. Compiler error messages are frequently unhelpful, leading to frustration. While Large Language Models (LLMs) have shown promise in code repair, they often "over-fix" by rewriting large sections of code, which can obscure the original error and hinder learning. Furthermore, existing deep-learning tools suffer from data scarcity and poor error localization. Iaso addresses these issues by leveraging structural grammar rules and an ensemble approach to provide precise, minimal syntax corrections.
Methodology
Iaso’s architecture is designed to overcome the limitations of traditional text-based repair models through a three-stage pipeline.
Syntax-based Code Generator (SCG)
To address data scarcity, Iaso employs a Syntax-based Code Generator. Unlike models that treat code as plain text, SCG operates on serialized Abstract Syntax Trees (ASTs). This structural approach ensures that generated programs adhere to C grammar rules. Iaso synthesized over 1.3 million compilable C programs to augment its training data, allowing the model to learn from a vast array of potential coding styles and errors.
Error Localization and Ensemble Repair
The repair process begins with the Error Localization Model (ELM), a lightweight 2-layer transformer that identifies the exact line needing correction by analyzing raw code, compiler messages, and model predictions. Once localized, the Ensemble Code Repair Assistant (ECRA) takes over. ECRA consists of multiple correctors trained on different data partitions. During inference, it aggregates suggestions and selects the fix that ensures compilation with the lowest Normalized Levenshtein Distance (NLD), prioritizing minimal changes.
Results
Iaso was benchmarked against standard datasets and state-of-the-art LLMs.
- Repair Rates: Iaso achieved a 78.8% full repair rate on the DeepFix dataset (a 4.2% improvement over previous baselines) and 91.0% on the Tracer dataset.
- Comparison with LLMs: Iaso outperformed Google’s PaLM by 6% in accuracy. While ChatGPT maintains a slight lead (90.3% vs. Iaso's 88.1% in unrestricted settings), Iaso achieves its results with a fraction of the computational power and significantly higher precision in its edits.
- Minimal Edits: By focusing on AST-based rules, Iaso maintains high accuracy even when restricted to very small changes, whereas LLM performance typically drops when they are prevented from rewriting large code blocks.
Conclusion
Iaso demonstrates that specialized, structurally-aware models can "punch above their weight," rivaling or exceeding the performance of much larger general-purpose models in domain-specific tasks like syntax repair. By focusing on minimal, precise edits, Iaso provides a more effective tool for educational environments. Future work will focus on expanding the model's capability to handle semantic errors and more diverse library contexts.
Summary updated