arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2503.00944cs.SE
收藏

B-OCL:一个Python中的对象约束语言解释器

B-OCL: An Object Constraint Language Interpreter in Python

Fitash Ul Haq, Jordi Cabot

AI总结:

本文提出了一个基于Python的OCL解释器,通过ANTLR解析器生成符合OCL元模型的语法树,并结合对象图评估约束,填补了Python建模中OCL工具的空白。

摘要:

对象约束语言(OCL)在建模社区被广泛用于补充软件模型,以精确定义受建模系统的约束和业务规则。支持OCL约束定义和解释的工具数量有限,基于Python的建模方法更是如此。本文介绍了一个Python的OCL解释器。该解释器包含两个组件:解析器和评估器。我们将OCL元模型实现为一组Python类,并使用最先进的ANTLR解析器生成器为解析器设计语法。解析器在解析OCL约束的每个部分后,生成符合OCL元模型的语法树。然后,评估器使用该语法树和对象图解释约束。最后,解释器报告所有约束的结果。

英文摘要:

The Object Constraint Language (OCL) has been widely used in the modeling community to complement software models for precisely defining constraints and business rules for the modeled systems. There is a limited number of tools supporting the definition and interpretation of OCL constraints, even less for a Python-based modelling approaches. In this paper, we introduce an OCL interpreter for Python. The interpreter has two components: parser and evaluator. We implement the OCL metamodel as a set of Python classes and design the grammar for the parser using the state-of-the-art ANTLR parser generator. The parser generates the syntax tree, that conforms with the OCL metamodel, after parsing each part of the OCL constraint. The evaluator then interprets the constraints using this syntax tree and the object diagram. In the end, the interpreter reports the result for all the constraints.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑