Financial DSL: A Domain-Specific Language for Expressive Financial Data Analysis
Keywords:
Domain-Specific Language, Financial Analytics, Interpreter Design, Text-to-SQL, Semantic Parsing, Software Architecture, Deterministic Query Execution, Abstract Syntax TreeAbstract
Domain-specific query languages are an essential tool for facilitating reliable financial analysis by linking syntax and meaning directly to the problem domain. Text-to-SQL systems translate natural language queries into executable SQL using deep neural networks, improving accessibility but introducing non-determinism, ambiguity and interpretation failures that are unacceptable in regulate financial environments. This paper presents FinancialDSL, a compiler inspired deterministic domain specific language designed for financial aggregation, filtering and period-based analysis over structured datasets. FinancialDSL is defined by a formal Extended Backus Naur Form (EBNF) grammar, implemented via a recursive descent parser and an Abstract Syntax Tree (AST) driven interpreter in C#13 on .NET 9. Evaluation of three representative query patterns—calculate total sales in Q3, calculate average revenue where amount > 5000, and calculate count for expenses in Q1—demonstrates 100% execution accuracy, producing verified results of $4,250.00 (3 records), $7,855.56 (9 records), and a count of 4 records respectively. The complete pipeline executed in 47 ms total (lexical analysis < 1 ms, parsing < 1 ms, execution 46 ms), producing 20 lexical tokens across the three statements. FinancialDSL achieves a 2% execution error rate versus 35% for a representative Text-to-SQL baseline a 17.5× reliability improvement and requires a mean query size of 8 tokens compared to 28 tokens for equivalent SQL formulations, a 71% reduction in syntactic overhead. Grammar based error classification across nine structured error categories produces precise, position aware diagnostics and ranked correction suggestions. These results establish that domain restricted deterministic DSLs are a viable and measurable complement to neural semantic parsing for regulated financial analytics, offering guaranteed reproducibility, full auditability, and interpretable execution.
References
“Error Detection for Text-to-SQL Semantic Parsing - ACL Anthology.” Accessed: May 16, 2026. [Online]. Available: https://aclanthology.org/2023.findings-emnlp.785/
“Model-based Interactive Semantic Parsing: A Unified Framework and A Text-to-SQL Case Study - ACL Anthology.” Accessed: May 16, 2026. [Online]. Available: https://aclanthology.org/D19-1547/
Katrin Affolter, Kurt Stockinger, Abraham Bernstein, “A Comparative Survey of Recent Natural Language Interfaces for Databases,” arXiv:1906.08990, 2019, [Online]. Available: https://arxiv.org/abs/1906.08990
Aishwarya Kamath, Rajarshi Das, “A Survey on Semantic Parsing,” arXiv:1812.00978, 2019, [Online]. Available: https://arxiv.org/abs/1812.00978
“(PDF) Domain-Specific Languages.” Accessed: May 16, 2026. [Online]. Available: https://www.researchgate.net/publication/276951339_Domain-Specific_Languages
Aleksandar Stojanović, Željko Kovačević, “Design and implementation of a domain-specific language framework using S-expressions,” J. Comput. Lang., vol. 87, p. 101398, 2026, doi: https://doi.org/10.1016/j.cola.2026.101398.
F. Hermans, M. Pinzger, and A. Van Deursen, “Domain-specific languages in practice: A user study on the success factors,” Lect. Notes Comput. Sci. (including Subser. Lect. Notes Artif. Intell. Lect. Notes Bioinformatics), vol. 5795 LNCS, pp. 423–437, 2009, doi: 10.1007/978-3-642-04425-0_33/SAVE-RESEARCH.
Lifu Tu, Rongguang Wang, Tao Sheng, Sujjith Ravi, Dan Roth, “LLM NL2SQL Robustness: Surface Noise vs. Linguistic Variation in Traditional and Agentic Setting,” arXiv:2603.17017v1, 2026, [Online]. Available: https://arxiv.org/html/2603.17017v1
Ziru Chen, Shijie Chen, Michael White, Raymond Mooney, Ali Payani, Jayanth Srinivasa, Yu Su, Huan Sun, “Text-to-SQL Error Correction with Language Models of Code,” arXiv:2305.13073, 2023, [Online]. Available: https://arxiv.org/abs/2305.13073
Abdul Quamar, Vasilis Efthymiou, Chuan Lei, Fatma Özcan, “Natural Language Interfaces to Data,” Found. Trends Databases, 2022, [Online]. Available: https://arxiv.org/abs/2212.13074
T. Yu et al., “Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task,” Proc. 2018 Conf. Empir. Methods Nat. Lang. Process. EMNLP 2018, pp. 3911–3921, Sep. 2018, doi: 10.18653/v1/d18-1425.
Mohammadreza Pourreza, Davood Rafiei, “DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction,” arXiv:2304.11015, 2023, [Online]. Available: https://arxiv.org/abs/2304.11015
Shayan Talaei, Mohammadreza Pourreza, Yu-Chen Chang, Azalia Mirhoseini, Amin Saberi, “CHESS: Contextual Harnessing for Efficient SQL Synthesis,” arXiv:2405.16755, 2024, [Online]. Available: https://arxiv.org/abs/2405.16755
Dawei Gao, Haibin Wang, Yaliang Li, Xiuyu Sun, Yichen Qian, Bolin Ding, Jingren Zhou, “Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluation,” arXiv:2308.15363, 2023, [Online]. Available: https://arxiv.org/abs/2308.15363
A. V. . Aho, M. S. . Lam, R. Sethi, and J. D. . Ullman, “Compilers : principles, techniques, & tools,” Addison-Wesley Longman Publ. Co., Inc., p. 1009, 2007.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 50sea

This work is licensed under a Creative Commons Attribution 4.0 International License.


















