PEG-based AADL code-to-graph multi-level conversion method
Through the PEG-based AADL code to graphics multi-level conversion method, the problem of complex system architecture analysis and presentation is solved, efficient analysis and intuitive multi-level graphical display are achieved, and the efficiency and accuracy of system design are improved.
Patent Information
- Application Number
- CN202510187569.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2045-02-20
AI Technical Summary
The prior art is difficult to effectively parse and display complex embedded system architectures, especially in supporting multi-level graphical displays.
The multi-level conversion method of AADL code to graphics based on PEG is adopted, and by defining PEG syntax rules, building an AADL code parser, generating a multi-level abstract syntax tree (AST) and converting it into a graphical expression.
It significantly improves the efficiency of AADL code parsing, can clearly present the hierarchical relationship between system design elements, improves the efficiency and accuracy of architectural design, and has good scalability and compatibility.
Smart Images

Figure CN120029667A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of embedded system architecture modeling and analysis, and in particular relates to a PEG-based AADL code to graphic multi-level conversion method. Background Art
[0002] With the continuous development of system design and requirements analysis, the model-based system engineering (MBSE) method has been widely used in the development of embedded systems. MBSE promotes the full life cycle management from requirements analysis, architecture design to verification by building models instead of relying on traditional documents. Especially in the fields of aerospace, automobiles, and national defense, MBSE has become an important means to improve system design efficiency and ensure system consistency and traceability. By adopting a model-driven development approach, MBSE can effectively cope with the increasingly complex system architecture and solve the problems of information islands and collaboration difficulties in traditional development methods.
[0003] Under the framework of MBSE, modeling and analysis of embedded system architecture is an important part. Through modeling languages such as AADL (Architecture Analysis and Design Language), users can model, analyze and verify system architecture. This model-based design method can help engineers better understand system architecture and optimize system design. However, as the complexity of system architecture continues to increase, how to effectively parse and display these complex architectures, especially supporting multi-level graphical displays, has become an important challenge in system architecture analysis.
[0004] The present invention is committed to filling the gap in model-based system architecture design tools in the domestic aerospace field. The method proposed in the present invention can help engineers intuitively and clearly view the system's hierarchical structure and the relationship between various components, quickly identify potential problems and optimize them, thereby significantly improving the efficiency and accuracy of architecture design. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] The technical problem to be solved by the present invention is how to provide a PEG-based AADL code to graphic multi-level conversion method to solve the problem of effectively parsing and displaying these complex architectures, especially supporting multi-level graphical display.
[0007] (II) Technical solution
[0008] In order to solve the above technical problems, the present invention proposes a PEG-based AADL code to graphics multi-level conversion method, the method comprising the following steps:
[0009] Step 1: Define PEG grammar rules
[0010] Define PEG grammar rules for AADL code parsing. The grammar rules are used to accurately describe the hierarchical structure and nested relationship of the AADL language by recursively defining various grammar contents.
[0011] Step 2: Build an AADL code parser
[0012] Based on the defined PEG grammar rules, an AADL code parser is built. The parser is used to parse the AADL code layer by layer, identify each design element, and capture and feedback grammatical and semantic problems during the parsing process.
[0013] Step 3: Generate a multi-level abstract syntax tree AST
[0014] The parser generates a multi-level abstract syntax tree AST according to the structure of the AADL code. The multi-level abstract syntax tree AST is used to express the node structure, hierarchical nesting, attribute mapping and element relationship of AADL;
[0015] Step 4: Convert the multi-level abstract syntax tree AST into a graphical expression
[0016] The multi-level abstract syntax tree AST is converted into a graphical display. Through the graphical method, each level of the system architecture is intuitively presented.
[0017] (III) Beneficial effects
[0018] The present invention proposes a PEG-based AADL code to graphics multi-level conversion method, which has the following characteristics:
[0019] (1) The PEG-based parsing method significantly improves the efficiency of AADL code parsing and adapts to system design requirements of different scales and complexities.
[0020] (2) By converting the parsed multi-level abstract syntax tree (AST) into a graphical display, the hierarchical relationship between different design elements, such as systems, subsystems, components, and interfaces, can be clearly presented. This makes complex structures more intuitive and easier for designers and developers to analyze, understand, and modify.
[0021] (3) The AST system built on PEG has good scalability and can adapt to different versions of AADL by simply adjusting the grammar rules and parser modules, ensuring the long-term applicability and compatibility of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the method of the present invention;
[0023] Figure 2This is an implementation example based on Peggy.js;
[0024] Figure 3 Schematic diagram of the AST structure generated by the parser;
[0025] Figure 4 AST is converted into a graphical expression diagram. DETAILED DESCRIPTION
[0026] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0027] The present invention relates to embedded system architecture modeling and analysis technology in the field of MBSE (Model-Based Systems Engineering). Specifically, the present invention provides a multi-level conversion method from AADL (Architecture Analysis and Design Language) code to graphics based on PEG (Parsing Expression Grammar), which can convert the architecture model described by AADL into a visual graphical representation by parsing and converting it. It is the core technical module of the MBSE tool chain developed by our unit.
[0028] The present invention proposes a PEG-based AADL code to graphics multi-level conversion method, which solves the problems of low parsing efficiency, inflexible graphic display, poor scalability and the like in the prior art. The core steps of the method are as follows: the first step is to define the PEG grammar rules. The grammar rules can accurately describe the basic elements, recursive structure and grammatical priority of the AADL language. The second step is to build an AADL code parser. The parser is built based on the defined PEG grammar rules. The parser can parse the AADL code layer by layer, identify each design element (such as package, component, interface, etc.), and capture and feedback grammatical semantic problems during the parsing process. The third step is to generate a multi-level abstract syntax tree (AST). AST can clearly express the node structure, hierarchical nesting, attribute mapping and element relationship of AADL. The fourth step is to convert the multi-level abstract syntax tree AST into a graphical expression. Through a graphical method, each level of the system architecture is intuitively presented.
[0029] The present invention proposes a PEG-based AADL code to graphics multi-level conversion method. The specific implementation steps are as follows (eg Figure 1 shown):
[0030] Step 1: Define PEG grammar rules
[0031] The present invention first defines a set of PEG grammar rules suitable for AADL code parsing. The grammar rules recursively define each grammar content to ensure that the hierarchical structure and nested relationship of the AADL language can be accurately described. The specific grammar rules include:
[0032] (1) Basic elements: define the smallest components such as identifiers and keywords.
[0033] (2) Recursive structure: Complex nested structures and hierarchical relationships can be handled by recursively defining combination rules.
[0034] (3) Syntax priority: Set a reasonable priority to ensure the correctness of grammatical parsing.
[0035] Step 2: Build an AADL code parser
[0036] Based on the PEG grammar rules defined above, an AADL code parser is constructed. The functions of the parser include:
[0037] (1) Code decomposition: Parse the AADL code layer by layer according to the PEG rules, divide the code into multiple hierarchical structures, and identify each element.
[0038] (2) Recursive parsing: Each sub-element in a multi-level structure is parsed step by step through recursive descent.
[0039] (3) Error capture and feedback: During the parsing process, if a syntax error or a structure that does not conform to the specification is encountered, the parser can immediately return error information and provide the error location and type.
[0040] Step 3: Build a multi-level abstract syntax tree (AST)
[0041] The multi-level abstract syntax tree AST is an accurate representation of the hierarchical structure in the AADL code. The parser generates a multi-level abstract syntax tree AST based on the structure of the AADL code. The structure of the AST has the following characteristics:
[0042] (1) Node construction: Each node of AST represents an element in AADL code. The node contains its ID, type, attributes, and relationship with other nodes.
[0043] (2) Hierarchical nesting: AST is a recursive structure. The relationship between nodes and subnodes represents the hierarchical relationship between different design elements. For example, the system node is the top-level node, its subnodes are subsystems, and the subnodes of the subsystems are specific components, and so on.
[0044] (3) Attribute mapping: Each node is accompanied by corresponding attribute information, such as component ports, interface parameters, etc. These attributes help further analyze the system structure.
[0045] (4) Element relationships: The connections between nodes represent the relationships between different design elements (such as communication between components, calling relationships of interfaces, etc.).
[0046] Step 4: Convert AST into a graphical expression
[0047] By converting the multi-level abstract syntax tree AST into a graphical representation, each level of the system can be presented intuitively. This conversion process includes:
[0048] (1) Generate a tree structure diagram: Convert the AST into a tree structure diagram to express the hierarchical structure between elements.
[0049] (2) Component relationship diagram: Graphically expresses the relationship between components, subsystems, and their ports and interfaces to facilitate subsequent analysis and modification.
[0050] Embodiment 1:
[0051] The specific steps to implement the PEG-based AADL code to graphics multi-level conversion tool are as follows:
[0052] Step 1: Define PEG grammar rules
[0053] First, define the PEG grammar rules for AADL code parsing. The implementation example based on Peggy.js is as follows: Figure 2 As shown, the file name is aadl.peggy.
[0054] (1) Basic elements
[0055] Basic elements are the smallest components of PEG syntax. Identifier definitions such as CommonIdentifier are used to match component names and attribute names in AADL; keywords such as Category are used to match reserved keywords in AADL.
[0056] (2) Recursive structure
[0057] The hierarchical structure and nested relationship in the AADL code are described recursively. For example, Package is a recursive structure, which contains multiple PackageContents. These contents can be CommonImplementation or CommonDefinition, which are also recursive structures, consisting of 0 to multiple ImplementationSubContents and TypeSubContents respectively.
[0058] (3) Syntax priority
[0059] In PEG, the priority of rules is determined by the order of rules. For example, if a Category contains multiple keywords, the data will be parsed first due to the order of rules, followed by other keywords.
[0060] Step 2: Build an AADL code parser
[0061] According to the PEG rule file aadl.peggy written in the first step, Peggy.js is used to implement the decomposition and recursive parsing of AADL code. During the parsing process, it can identify abnormal output (such as the exception thrown by nameMatchCheck), and print errors to identify the specific error location and type.
[0062] Step 3: Build a multi-level abstract syntax tree (AST)
[0063] The AST structure generated by the parser is as follows Figure 3 As shown. The multi-level abstract syntax tree AST consists of AADLNode nodes, which represent an element in the AADL code. Each AADLNode node contains the following information:
[0064] (1) ID represents the unique identifier of each node.
[0065] (2) Type indicates the type of the node, which can be device, processor, memory, thread, connection, etc.
[0066] (3)Attributes contains the attribute mapping information of the node, such as name, attributes, characteristics, etc.
[0067] (4) Relation represents the relationship between different elements, such as inclusion relationship, dependency relationship, interaction relationship, inheritance relationship, etc.
[0068] (5) Children represents the child nodes of the node. Each child node is also a complete AADLNode, expressing the hierarchical relationship between the node and the child nodes.
[0069] Step 4: Convert AST into a graphical expression
[0070] Convert the AST in the third step into a tree structure diagram and a component relationship diagram to intuitively display the hierarchical structure and the relationship between elements constructed by the AADL system. For example, Figure 4 shown.
[0071] Embodiment 2:
[0072] The present invention proposes a PEG-based AADL code to graphics multi-level conversion method, which solves the problems of low parsing efficiency, inflexible graphics display, and poor scalability in the prior art. The core steps of the method are as follows:
[0073] The first step is to define the PEG grammar rules, which can accurately describe the basic elements, recursive structure and grammar priority of the AADL language.
[0074] The second step is to build an AADL code parser. Based on the defined PEG grammar rules, the parser is built, which can parse the AADL code layer by layer, identify various design elements (such as packages, components, interfaces, etc.), and capture and feedback grammatical and semantic problems during the parsing process.
[0075] The third step is to generate a multi-level abstract syntax tree (AST). AST can clearly express the node structure, hierarchical nesting, attribute mapping and element relationship of AADL.
[0076] The fourth step is to convert the multi-level abstract syntax tree AST into a graphical expression. Through the graphical method, each level of the system architecture is intuitively presented.
[0077] Beneficial Effects
[0078] The present invention proposes a multi-level conversion method of AADL code to graphics based on PEG, which has the following characteristics:
[0079] (1) The PEG-based parsing method significantly improves the efficiency of AADL code parsing and adapts to system design requirements of different scales and complexities.
[0080] (2) By converting the parsed multi-level abstract syntax tree (AST) into a graphical display, the hierarchical relationship between different design elements, such as systems, subsystems, components, and interfaces, can be clearly presented. This makes complex structures more intuitive and easier for designers and developers to analyze, understand, and modify.
[0081] (3) The AST system built on PEG has good scalability and can adapt to different versions of AADL by simply adjusting the grammar rules and parser modules, ensuring the long-term applicability and compatibility of the system.
[0082] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A PEG-based AADL code to graphics multi-level conversion method, characterized in that: The method comprises the following steps: Step 1: Define PEG grammar rules Define PEG grammar rules for AADL code parsing. The grammar rules are used to accurately describe the hierarchical structure and nested relationship of the AADL language by recursively defining each grammar content. Step 2: Build an AADL code parser Based on the defined PEG grammar rules, an AADL code parser is built. The parser is used to parse the AADL code layer by layer, identify each design element, and capture and feedback grammatical and semantic problems during the parsing process. Step 3: Generate a multi-level abstract syntax tree AST The parser generates a multi-level abstract syntax tree AST according to the structure of the AADL code. The multi-level abstract syntax tree AST is used to express the node structure, hierarchical nesting, attribute mapping and element relationship of AADL; Step 4: Convert the multi-level abstract syntax tree AST into a graphical expression The multi-level abstract syntax tree AST is converted into a graphical display. Through the graphical method, each level of the system architecture is intuitively presented.
2. The PEG-based AADL code to graphics multi-level conversion method according to claim 1, characterized in that: In the first step, the grammar rules include: basic elements, recursive structure and grammar priority; Basic elements: define the smallest component unit of identifiers and keywords; Recursive structure: handle complex nested structures and hierarchical relationships by recursively defining combination rules; Syntax priority: Set a reasonable priority. The priority of rules in PEG is determined by the order of the rules to ensure the correctness of grammatical parsing.
3. The PEG-based AADL code to graphics multi-level conversion method as claimed in claim 2, characterized in that: Identifiers are used to match component names and attribute names in AADL; keywords are used to match reserved keywords in AADL.
4. The PEG-based AADL code to graphics multi-level conversion method according to claim 1, characterized in that: In the second step, the parser is used for code decomposition, recursive parsing, and error capture and feedback; Code decomposition: Parse the AADL code layer by layer according to the PEG rules, divide the code into multiple hierarchical structures, and identify each element; Recursive parsing: By recursive descent, each sub-element in the multi-level structure is gradually parsed; Error capture and feedback: During the parsing process, if a syntax error or a structure that does not conform to the specification is encountered, the parser can immediately return error information and provide the error location and type.
5. The PEG-based AADL code to graphics multi-level conversion method as claimed in claim 4, characterized in that: According to the PEG rule file aadl.peggy written in the first step, Peggy.js is used to implement the decomposition and recursive parsing of AADL code. During the parsing process, it can identify abnormal output, print errors, and identify the specific error location and type.
6. The PEG-based AADL code to graphics multi-level conversion method as claimed in claim 4, characterized in that: In the third step, Node construction: Each node in the AST represents an element in the AADL code. The node contains its ID, type, attributes, and relationship with other nodes; Hierarchical nesting: AST is a recursive structure, and the relationship between nodes and sub-nodes represents the hierarchical relationship between different design elements; Attribute mapping: Each node comes with corresponding attribute information; Element relationships: The connections between nodes represent the relationships between different design elements.
7. The PEG-based AADL code to graphics multi-level conversion method according to claim 6, characterized in that: The third step includes: the multi-level abstract syntax tree AST is composed of AADLNode nodes, the AADLNode node represents an element in the AADL code, and each AADLNode node contains the following information: ID represents the unique identification of each node; Type indicates the type of node, including: device, processor, memory, thread, and connection; Attributes contains the attribute mapping information of the node, including: name, attributes and characteristics; Relation represents the relationship between different elements, including: inclusion relationship, dependency relationship, interaction relationship and inheritance relationship; Children represents the child nodes of the node. Each child node is also a complete AADLNode, expressing the hierarchical relationship between the node and the child nodes.
8. The PEG-based AADL code to graphics multi-level conversion method according to claim 6, characterized in that: In the hierarchical nesting, the system node is the top-level node, its child nodes are subsystems, and the child nodes of the subsystems are specific components.
9. The PEG-based AADL code to graphics multi-level conversion method as claimed in claim 6, characterized in that: In element relationships, the relationships between elements include: communication between components and calling relationships of interfaces.
10. The PEG-based AADL code to graphics multi-level conversion method according to claim 6, characterized in that: The fourth step comprises: Generate a tree structure diagram: Convert AST into a tree structure diagram to express the hierarchical structure between elements; Component relationship diagram: graphically expresses the relationship between components, subsystems and their ports and interfaces to facilitate subsequent analysis and modification.
Citation Information
Patent Citations
AADL-based method for establishing, analyzing and simulating hybrid system model
CN103942086A
A control flow graph construction method for object-oriented programming
CN109408034A
ANTLR-based flattening conversion method for AltaRica 3.0
CN109857458A
Code analysis method and system and readable storage medium
CN117193852A
Calling link generation method based on Java static code analysis
CN118312250A