Kajal: Extracting Grammar of a Source Code Using Large Language Models

Fuente: arXiv
Saved in:
Bibliographic Details
Main Author: Torkamani, Mohammad Jalili
Format: Preprint
Published: 2024
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866913609292972032
author Torkamani, Mohammad Jalili
author_facet Torkamani, Mohammad Jalili
contents Understanding and extracting the grammar of a domain-specific language (DSL) is crucial for various software engineering tasks; however, manually creating these grammars is time-intensive and error-prone. This paper presents Kajal, a novel approach that automatically infers grammar from DSL code snippets by leveraging Large Language Models (LLMs) through prompt engineering and few-shot learning. Kajal dynamically constructs input prompts, using contextual information to guide the LLM in generating the corresponding grammars, which are iteratively refined through a feedback-driven approach. Our experiments show that Kajal achieves 60% accuracy with few-shot learning and 45% without it, demonstrating the significant impact of few-shot learning on the tool's effectiveness. This approach offers a promising solution for automating DSL grammar extraction, and future work will explore using smaller, open-source LLMs and testing on larger datasets to further validate Kajal's performance.
format Preprint
id arxiv_https___arxiv_org_abs_2412_08842
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Kajal: Extracting Grammar of a Source Code Using Large Language Models
Torkamani, Mohammad Jalili
Software Engineering
Artificial Intelligence
D.2; D.3; F.4.2; I.2.5
Understanding and extracting the grammar of a domain-specific language (DSL) is crucial for various software engineering tasks; however, manually creating these grammars is time-intensive and error-prone. This paper presents Kajal, a novel approach that automatically infers grammar from DSL code snippets by leveraging Large Language Models (LLMs) through prompt engineering and few-shot learning. Kajal dynamically constructs input prompts, using contextual information to guide the LLM in generating the corresponding grammars, which are iteratively refined through a feedback-driven approach. Our experiments show that Kajal achieves 60% accuracy with few-shot learning and 45% without it, demonstrating the significant impact of few-shot learning on the tool's effectiveness. This approach offers a promising solution for automating DSL grammar extraction, and future work will explore using smaller, open-source LLMs and testing on larger datasets to further validate Kajal's performance.
title Kajal: Extracting Grammar of a Source Code Using Large Language Models
topic Software Engineering
Artificial Intelligence
D.2; D.3; F.4.2; I.2.5
url https://arxiv.org/abs/2412.08842