A configurable multi-system multi-axis numerical control program parsing method and system

By constructing an extensible parsing rule configuration system, the challenges of multi-system compatibility and rapid configuration in CNC program parsing technology have been solved, achieving seamless adaptation and accurate parsing across multiple systems and enhancing the application capabilities of CNC machining simulation software.

CN122240119APending Publication Date: 2026-06-19HUAZHONG UNIV OF SCI & TECH +2

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAZHONG UNIV OF SCI & TECH
Filing Date
2026-03-16
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing CNC program parsing technologies are insufficient to meet the requirements of multi-system compatibility, rapid configuration, and accurate parsing, which limits the promotion and application of CNC machining simulation software in complex manufacturing scenarios.

Method used

By constructing an extensible parsing rule configuration system and using structured configuration files to record keyword classification information and entry tree structure, compatible parsing for different brands of CNC systems is achieved, including lexical, syntactic and semantic parsing, to generate function instructions.

Benefits of technology

It achieves seamless adaptation to multiple systems, reduces development costs, improves the accuracy of analysis and the flexibility of configuration, and enhances the simulation and verification capabilities of CNC machining simulation software in complex manufacturing scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122240119A_ABST
    Figure CN122240119A_ABST
Patent Text Reader

Abstract

This invention belongs to the technical field of CNC systems and discloses a configurable multi-system, multi-axis CNC program parsing method and system. The method includes: receiving a pre-established structured configuration file defining parsing rules for the target CNC system; wherein the structured configuration file records keyword classification information and an entry tree structure, the keyword classification information including program word classification types and address value matching types, and the entry tree structure used to establish a mapping relationship between program word codes and function instructions to describe the semantic function mapping of program words; based on the structured configuration file, performing lexical and syntactic parsing and semantic parsing on the program to be parsed sequentially, converting the program to be parsed into function instructions. This invention achieves seamless adaptation to heterogeneous systems through configurable rules. New systems can be adapted simply by modifying the structured configuration file without coding intervention, achieving multi-system compatibility and rapid configuration. Based on accurate parsing, it can significantly reduce development costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of CNC systems, and more specifically, relates to a configurable multi-system multi-axis CNC program parsing method and system. Background Technology

[0002] Against the backdrop of the manufacturing industry's transformation towards digitalization and intelligence, CNC machining simulation technology has become a key support for improving production efficiency and reducing trial-and-error costs. Its core function lies in extracting machine tool motion information by analyzing CNC programs and simulating the machining process to avoid collision risks and process errors in advance. As a core component of simulation software, the compatibility and flexibility of the CNC program parsing module directly determine whether the software can adapt to the actual needs of different production scenarios.

[0003] While current mainstream CNC programs adhere to basic industry standards, various manufacturers have expanded upon these standards with specialized instructions and syntax rules to meet complex machining needs. The instruction sets of different CNC systems vary significantly, especially in the implementation of advanced functions such as macro programs and fixed cycles, creating a natural barrier to cross-system parsing and posing challenges to the reuse and simulation adaptation of CNC programs.

[0004] There are two common approaches to parsing existing CNC programs: one is to directly build the parsing logic based on regular expressions. While this is convenient for handling simple, fixed CNC programs, it has limited expressive power and cannot accurately represent certain specific expressions. The other approach relies on dedicated lexical and syntax generation tools. Even after completing basic adaptation development, if new instructions need to be added or the parsing logic needs to be adjusted, the underlying code still needs to be modified and recompiled. This not only results in a long development cycle but also significantly increases the complexity of user operations.

[0005] The combination of these problems makes it difficult for existing CNC program parsing technology to meet the core requirements of multi-system compatibility, rapid configuration, and accurate parsing, which in turn severely restricts the promotion and application of CNC machining simulation software in complex manufacturing scenarios. Summary of the Invention

[0006] To address the aforementioned deficiencies or improvement needs of existing technologies, this invention provides a configurable multi-system, multi-axis CNC program parsing method and system. This addresses the problem that existing CNC program parsing technologies struggle to meet the core requirements of multi-system compatibility, rapid configuration, and accurate parsing, thus severely hindering the promotion and application of CNC machining simulation software. By constructing an extensible parsing rule configuration system, it achieves compatible parsing for different brands of CNC systems while ensuring parsing accuracy and configuration flexibility, providing CNC machining simulation software with core parsing capabilities adaptable to multiple scenarios.

[0007] To achieve the above objectives, according to one aspect of the present invention, a configurable multi-system multi-axis CNC program parsing method is provided, comprising: Receive a pre-established structured configuration file that defines the parsing rules of the target CNC system; wherein, the structured configuration file records keyword classification information and an entry tree structure, the keyword classification information includes the program word classification type and address value matching type of the target CNC system, and the entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of program words; Based on the structured configuration file, the program to be parsed is sequentially subjected to lexical and syntactic parsing as well as semantic parsing, transforming the program into functional instructions.

[0008] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, the program word classification type in the keyword classification information includes functional keywords and auxiliary keywords; wherein, the address value matching type of functional keywords includes multiple types such as numeric type, text type, alphanumeric type, list type, compound type and single program word type; Auxiliary keywords include logical operators, mathematical operators, function names, and special keywords. Special keywords include at least one of the following: variable name code, variable definition code, variable label code, branch code, comment code, and subroutine code.

[0009] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, the entry tree structure specifically establishes the mapping relationship between the function word code formed by the function keyword and the function instruction under the context semantics, and sorts each function instruction according to priority order; The entry tree structure adopts a hierarchical organization: the first layer is the root node, marking the starting point of the entry tree structure; the second layer divides the function word codes into multiple categories according to their functional characteristics and sorts them to determine the priority order of instruction execution; the third layer contains function word codes composed of function keywords and address values; the fourth layer sets contextual semantic conditions, including system modal information and other function word codes in the current program block; the fifth layer outputs the matching function instructions; through a top-down matching judgment process, the first matching branch is selected as the final matching result.

[0010] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, lexical and syntactic parsing and semantic parsing are performed sequentially on the program to be parsed based on the structured configuration file, specifically including: Lexical analysis: The program to be analyzed is divided into an indivisible sequence of lexical units, and the program type is identified based on the keyword classification information to generate a sequence of lexical units with type identifiers; Syntax analysis: Using formal grammar rules, the sequence of lexical units is combined and grouped to gradually construct an abstract syntax tree with a clear semantic structure; Semantic parsing: Based on the entry tree structure, the abstract syntax tree is deeply traversed to match functional instructions, and semantic functional information is extracted based on the address value matching type, so as to transform the program to be parsed into functional instructions.

[0011] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, semantic parsing further includes: For special keywords, based on the preset grammar processing mechanism, the function instructions are judged and parsed by recognizing special keywords that conform to the preset grammar structure.

[0012] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, the parsed functional instructions include machining instructions and control instructions, and the method further includes: The program to be parsed is controlled to be parsed line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. Based on the preset target simulation system interface configuration, the parsed machining instruction sequence is converted for machining simulation.

[0013] The configurable multi-system multi-axis CNC program parsing method provided by the present invention further includes: The position of the program to be parsed is encoded in advance. If a subroutine call is involved, the subroutine is encoded and a corresponding relationship is established to facilitate the calling of the subroutine. During the parsing process, the current program position, the subroutine call position, and the program jump position are recorded, as well as the parsed variable information.

[0014] According to the configurable multi-system multi-axis CNC program parsing method provided by the present invention, the structured configuration file is an XML file, and the method further includes: Collect and record any abnormal information generated during the parsing process; these abnormal information include multiple errors such as configuration file format errors, lexical parsing errors, syntax parsing errors, and semantic parsing errors.

[0015] According to another aspect of the present invention, a configurable multi-system multi-axis CNC program parsing system is provided, comprising: The input and configuration module is used to receive a pre-established structured configuration file that defines the parsing rules of the target CNC system. The structured configuration file records keyword classification information and an entry tree structure. The keyword classification information includes the program word classification type and address value matching type of the target CNC system. The entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of the program word. An interpreter is used to perform lexical and syntactic analysis and semantic analysis on the program to be parsed based on the structured configuration file, and to convert the program to be parsed into functional instructions.

[0016] The configurable multi-system multi-axis CNC program parsing system provided by the present invention parses functional instructions including machining instructions and control instructions. The system also includes: The execution and feedback module is used to control the parsing of the program line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. The simulation instruction execution module is used to convert the parsed machining instruction sequence according to the preset target simulation system interface configuration in order to perform machining simulation.

[0017] In summary, compared with the prior art, the configurable multi-system multi-axis CNC program parsing method and system provided by this invention offer the following advantages: 1. In the process of working, this invention first sets the parsing rules of the target system through a structured configuration file. Then, based on the structured configuration file, the CNC program to be parsed is subjected to lexical and syntactic analysis and semantic interpretation to generate accurate functional instructions. Seamless adaptation to heterogeneous systems is achieved through configurable rules. That is, new systems can be adapted by modifying and replacing the structured configuration file without coding intervention. It can achieve multi-system compatibility and rapid configuration. On the basis of accurate parsing, it can significantly reduce development costs. 2. The proposed keyword classification information setting and entry tree structure, based on standardized syntax description and contextual condition mechanism, can accurately handle modal instructions and complex expressions, which is conducive to the smooth and accurate parsing of complex program code; 3. The overall system adopts a modular architecture, which supports hot-swappable expansion through modular design, making it easy for users to customize function expansion and facilitate secondary development; 4. This invention provides a highly versatile and configurable analytical solution for CNC machining simulation software, significantly improving the simulation verification capabilities in complex manufacturing scenarios. Attached Figure Description

[0018] Figure 1 This is the overall execution flowchart of the configurable multi-system multi-axis CNC program interpretation architecture provided by the present invention.

[0019] Figure 2 is an example of the keyword configuration format in the XML configuration file provided by the present invention.

[0020] Figure 3 is an example of the entry tree organization form provided by the present invention.

[0021] Figure 4 is an example of the configuration format of the entry tree in the XML configuration file provided by the present invention.

[0022] Figure 5 is an example of the lexical parsing workflow provided by the present invention.

[0023] Figure 6 is an example of the syntax parsing workflow provided by the present invention; where (a) is an example of the syntax analysis and reduction workflow based on the lexical parsing structure; and (b) is the EBNF expression of syntax reduction.

[0024] Figure 7 is the EBNF expression of the syntax reduction of the auxiliary keywords provided by the present invention.

[0025] Figure 8 is a flowchart of the semantic analysis program provided by the present invention.

[0026] Figure 9 is a flowchart of the processing methods for different types of expressions provided by the present invention.

[0027] Figure 10 is a flowchart of the process for determining the execution order of simulation instructions provided by the present invention.

[0028] Figure 11 is an overall execution flowchart of the execution and feedback module provided by the present invention.

[0029] Figure 12 is a comparison and verification diagram of the multi-system CNC program parsing results provided by the present invention; where (a) is a CNC program that follows the Fanuc syntax standard; (b) is an equivalent CNC program that follows the Siemens syntax standard; and (c) is a three-dimensional part model when processed to the same process stage. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.

[0031] Please see Figure 1 and Figure 2 This embodiment provides a configurable multi-system multi-axis CNC program parsing method, which includes: Receive a pre-established structured configuration file that defines the parsing rules of the target CNC system; wherein, the structured configuration file records keyword classification information and an entry tree structure, the keyword classification information includes the program word classification type and address value matching type of the target CNC system, and the entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of program words; Based on the structured configuration file, the program to be parsed is sequentially subjected to lexical and syntactic parsing as well as semantic parsing, transforming the program into functional instructions.

[0032] In some embodiments, the program word classification type in the keyword classification information includes functional keywords and auxiliary keywords; wherein, the address value matching type of functional keywords includes multiple types such as numeric type, text type, alphanumeric type, list type, compound type and single program word type; Auxiliary keywords include logical operators, mathematical operators, function names, and special keywords. Special keywords include at least one of the following: variable name code, variable definition code, variable label code, branch code, comment code, and subroutine code.

[0033] In this embodiment, the control system configuration file is defined in XML format to configure the parsing rules for different CNC systems. It is the only part of the entire architecture that requires user customization. Its configuration process mainly includes two core steps: keyword classification and entry tree construction. Users can classify program words according to matching types and set function priorities based on the CNC system programming manual. The entry tree describes the semantic mapping of function words in a specific context, with each condition node bound to a corresponding simulation instruction.

[0034] Keywords can be categorized into functional keywords and auxiliary keywords. Address value matching for functional keywords is further subdivided into various types based on their syntactic features, each corresponding to specific matching rules. As shown in Table 1, functional keywords will produce different types of address value matching results under different configurations.

[0035] Table 1. Impact of Keyword Type on Matching Results

[0036] Auxiliary keywords are defined into four basic types, as shown in Table 2. These are used in lexical analysis to determine the semantics of special symbols and non-functional keywords, enabling auxiliary functions such as mathematical operations and program jumps. Furthermore, the system supports the recognition of special statement structures, currently including the following types: "Variable Name," used to identify the start of a variable assignment statement; "Variable Definition," used to create user-defined variables; "Variable Label," indicating that subsequent numbers are variable register numbers; "Branch," used in Siemens systems for branching based on variable values; "Comment," indicating that subsequent content is a comment; and "Subroutine," used to identify subroutine names, which can be used in CNC subroutine call statements, etc. The keyword type settings are organized in the XML file as follows: Figure 2 As shown.

[0037] Table 2 Types and Functions of Auxiliary Keywords

[0038] In some embodiments, the entry tree structure specifically establishes the mapping relationship between the functional word codes formed by functional keywords and functional instructions under the context semantics, and sorts each functional instruction according to priority order; like Figure 3 As shown, the entry tree structure adopts a hierarchical organization: the first level is the root node, marking the starting point of the entry tree structure; the second level divides the function word codes into multiple categories according to their functional characteristics and sorts them to determine the priority order of instruction execution; the third level contains function word codes composed of function keywords and address values, where "*" represents a wildcard that supports matching any address value; the fourth level sets contextual semantic conditions, including system modal information and other function word codes in the current program block, with "* *" indicating the default branch condition; the fifth level outputs the matching function instructions, i.e., macro instructions; through a top-down matching judgment process, the first matching branch is selected as the final matching result.

[0039] In other words, if two function keywords appear simultaneously in the same line of code, it's necessary to determine whether they affect the functionality of a single function keyword. If a combination of two function keywords in the same line of code corresponds to a new function instruction, it should be listed in the entry tree, which can be reflected in the fourth-level context semantic conditions. For example, if X* and G4 appear simultaneously in the same line of code, it corresponds to the `dwellTime` instruction in the register value function. Additionally, some instructions are related to prior modal setting information. During program parsing, prior modal setting information should be considered, and the final instruction should be matched based on this information. For example, when the Y* function word code appears in the program, if the prior modal setting "machining plane XY, polar coordinates enabled" is present, the `polarAngle` instruction is matched; if no prior modal setting is present, the `yAxisMotion` instruction is matched.

[0040] Furthermore, each conditional branch can contain one or more macro instructions. These macro instructions, as the smallest functional units in the parsing architecture, can be combined to achieve complex functions. For example, in this embodiment, the program pause function represented by "G4 X" can be implemented by combining the macro instructions corresponding to "G4" and "X" respectively. The entry tree structure is set up in the XML file in the following way: Figure 4 As shown, the keyword classification information and entry tree structure can be organized in an XML file using a code enumeration format, which is easy to recognize.

[0041] In some embodiments, lexical and syntax analysis is built upon a modern parsing framework, transforming CNC program segments into abstract syntax trees. The lexical analysis phase identifies program word types using program words as core units, and syntax modeling employs standardized description methods to express hierarchical structures, supporting rules such as program segments and function word groups. Semantic analysis, combined with runtime context, matches conditional branches from the entry tree to generate simulation instruction sequences. This module extracts core nodes based on the abstract syntax tree, determines execution paths through logical conditions, and ultimately outputs parameterized simulation instructions according to functional priority. The lexical and syntax analysis module and the semantic analysis module together form the interpreter.

[0042] Based on the structured configuration file, the parsing program is sequentially subjected to lexical and syntactic parsing, as well as semantic parsing, specifically including: Lexical analysis: The program to be analyzed is divided into an indivisible sequence of lexical units, and the program type is identified based on the keyword classification information to generate a sequence of lexical units with type identifiers; Syntax analysis: Using formal grammar rules, the sequence of lexical units is combined and grouped to gradually construct an abstract syntax tree with a clear semantic structure; Semantic parsing: Based on the entry tree structure, the abstract syntax tree is deeply traversed to match functional instructions, and semantic functional information is extracted based on the address value matching type, so as to transform the program to be parsed into functional instructions.

[0043] Semantic parsing also includes: For special keywords, based on a preset grammatical processing mechanism, the function command is determined and parsed by identifying special keywords that conform to a preset grammatical structure. The grammatical parsing also includes: for special keywords, based on preset matching rules, grouping and processing the lexical unit sequences corresponding to the special keywords by identifying combinations of special keywords that conform to a preset grammatical structure.

[0044] Specifically, lexical and syntactic parsing organically combines lexical analysis and syntactic analysis to achieve a complete transformation from raw text to an abstract syntax tree. As shown in Figure 5, in the lexical analysis stage, the interpreter, based on a pre-configured rule base, segments the input continuous text stream into an indivisible sequence of lexical units. This process uses a keyword list for pattern matching to identify basic elements such as functional keywords, numerical constants, operators, and special keywords, and generates a sequence of lexical units with type identifiers, laying the foundation for subsequent syntactic analysis.

[0045] As shown in Figure 6, the syntax analysis stage adopts a formal syntax specification based on EBNF. Through a recursive descent parsing algorithm, the lexical unit sequence is hierarchically combined according to predetermined rules, that is, functional keywords and their corresponding expressions, as well as special keywords and their corresponding expressions, are grouped and divided to gradually construct an abstract syntax tree with a clear semantic structure. For different types of functional keywords, the system determines the matching rules for their subsequent address parameter values ​​based on the type set in the XML configuration: numeric keywords require matching numeric expressions, which can be direct numeric constants or complex mathematical expressions containing functions or variables and returning a numeric value; textual keywords correspond to strings or identifiers; compound keywords support multi-parameter combination matching.

[0046] like Figure 7 As shown, the system employs an independent syntax processing mechanism for handling special keywords. This involves establishing separate matching rules for each special keyword to group and process instructions by recognizing combinations of special keywords that conform to specific syntactic structures. Specifically, "variable name" is a subtype of special keywords. When the system recognizes the syntax pattern of "variable name" followed by "=" (a subtype of mathematical auxiliary keywords) and "mathematical expression" (composed of mathematical auxiliary keywords), it will be grouped as a variable assignment statement. Similarly, "variable definition" is also a subtype of special auxiliary keywords. When the system recognizes the structure of "variable definition" followed by "domain," "type identifier," and variable name, it will be recognized as a variable definition statement. The "domain" and "type identifier" are dedicated to this type of statement and therefore do not need to be defined separately in the system's XML configuration file. These special auxiliary statements are all standardized using dedicated syntactic production rules to ensure the accuracy and completeness of their syntactic structure.

[0047] like Figure 8 As shown, the semantic analysis phase mainly involves a depth-first traversal of the abstract syntax tree (AST) and the extraction and transformation of semantic information. In practice, the system uses a unified container, Variant, to store expression information, and the final AST's actual data structure is a List. <variant>The system then traverses the syntax tree, calling the corresponding handler based on the actual type of the node, as follows: Figure 9 As shown.

[0048] In this processing phase, the system primarily performs semantic analysis and transformation on four expression types: variable assignment expressions, variable definition expressions, function word group expressions, and special syntax statements. This classification aligns with the definitions of the aforementioned syntax rules. After the entire syntax tree sequence is processed, the system integrates the semantic information of all records and performs semantic mapping and organization of the identified simulation instructions based on the previously established entry tree structure. The specific execution flow of this process is as follows: Figure 10 As shown. The core objective of this processing stage is to determine the final execution order of simulation instructions. The system will set the priority of the instructions based on their functional characteristics to ensure that instructions with special functions or high priority are given priority for execution, thereby guaranteeing the correct implementation of the CNC program semantics and execution efficiency. Specifically, if two or more instructions appear simultaneously in the same line of code, the execution order of the instructions will be determined from top to bottom according to the priority order defined by the entry tree structure.

[0049] It is important to note that variable assignment, variable definition, and special syntax expressions typically have a direct impact on the interpretation architecture environment. This type of environment information is maintained uniformly by the execution and feedback module. The environment data structure design of the interpretation architecture is shown in Table 3, which includes a set of subroutines implemented using a hash table, recording the mapping relationship between subroutines and program buffers, thus enabling program location in constant time. Simultaneously, through the program call stack mechanism, the system can accurately record the breakpoint state of control flow transfer during each program call, ensuring that the main program can correctly resume execution from the breakpoint after the subroutine call ends. The parsing method also includes: pre-encoding the position of the program to be parsed; if subroutine calls are involved, encoding the involved subroutines and establishing corresponding relationships to facilitate subroutine calls; recording the current program position, the called subroutine position, and the program jump position during parsing, as well as recording the parsed variable information. It can also record the encoding of the currently processed CNC code file.

[0050] Table 3 Explains the data structure design of the architecture environment.

[0051] like Figure 11 As shown, after the interpreter completes initialization, the actual parsing and execution of the CNC program are uniformly scheduled by the execution and feedback module. This module uses program segments as the basic processing unit and drives the system to complete code parsing and simulation instruction generation according to a predetermined process. This module actively detects the existence of NC code files to be parsed and selects unexecuted files in sequence to send to the interpreter for processing. After the file is loaded, the interpreter reads the code line by line according to the program segment order and performs lexical analysis, syntax analysis, and semantic analysis sequentially within each program segment. Through this series of processes, the original NC code is gradually transformed into an executable internal syntax structure. It is worth noting that if the simulation instructions contain control instructions, the controller will dynamically adjust the order of subsequent files and program segments to be processed.

[0052] The parsed functional instructions include processing instructions and control instructions. The method also includes: The program to be parsed is controlled to be parsed line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. Based on the preset target simulation system interface configuration, the parsed machining instruction sequence is converted for machining simulation.

[0053] Furthermore, the structured configuration file is an XML file, and the method further includes: Anomalies generated during the parsing process are collected and recorded. These anomalies include multiple errors such as configuration file format errors, lexical parsing errors, syntax parsing errors, and semantic parsing errors. Configuration file format errors occur when the file format is inconsistent with the preset format type, preventing the recognition and reception of structured configuration files. Lexical parsing errors may include unrecognized program word types, syntax parsing errors may include unrecognized matching syntax structures preventing syntax parsing, and semantic parsing errors may include unrecognized instructions preventing semantic parsing.

[0054] In some embodiments, a configurable multi-system multi-axis CNC program parsing system is also provided for implementing the method described in the above embodiments. The system includes: The input and configuration module is used to receive a pre-established structured configuration file that defines the parsing rules of the target CNC system. The structured configuration file records keyword classification information and an entry tree structure. The keyword classification information includes the program word classification type and address value matching type of the target CNC system. The entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of the program word. An interpreter is used to sequentially perform lexical and syntactic analysis and semantic analysis on the program to be parsed based on the structured configuration file, transforming the program into functional instructions. The interpreter specifically includes a lexical and syntactic analysis module and a semantic analysis module.

[0055] In some embodiments, the parsed functional instructions include processing instructions and control instructions, and the system further includes: The execution and feedback module is used to control the parsing of the program line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. The simulation instruction execution module is used to convert the parsed machining instruction sequence according to the preset target simulation system interface configuration for machining simulation. As a bridge between the parsing architecture and the external simulation system, the module is primarily responsible for converting the internally generated instruction sequence into interface calls recognizable by the target simulation system. This module uses a predefined interface adapter to convert motion instructions into tool position coordinates and motion trajectory data required by the simulation system, mapping control instructions to state update operations of the simulation system.

[0056] As shown in Figure 1, the multi-axis CNC program parsing architecture provided in this embodiment consists of six core functional modules: an input and configuration module, a lexical and syntax parsing module, a semantic interpretation module, an execution and feedback module, a simulation instruction execution module, and an error handling module. During the initialization phase, this architecture receives three types of input data: a control system configuration file, the CNC code file to be parsed, and a machine tool simulation environment configuration. The machine tool simulation environment configuration is used to determine various modal parameters and system interface information during the machining process. This configuration includes machine tool operating mode settings and simulation system interface information, providing the necessary information for converting the parsed functional instructions into simulation instructions for the simulation system. After system startup, initialization is completed by loading the control system configuration file and reading the simulation environment configuration. Subsequently, the CNC program file is read sequentially, and syntax unit conversion, semantic interpretation, and simulation instruction generation are performed in sequence, ultimately driving high-fidelity machine tool motion simulation.

[0057] The input and configuration module is responsible for parsing the XML-formatted control system configuration file, converting its defined keyword system and entry tree rules into internal parsing rules executable by the interpreter. This module also loads the CNC code file into system memory and establishes a program buffer to support efficient retrieval of program jump targets and flow control. Furthermore, the input and configuration module pre-encodes the positions of the program to be parsed; if subroutine calls are involved, it encodes the relevant subroutines and establishes corresponding relationships for initial configuration.

[0058] The Execution and Feedback module manages the execution status and flow control of the parsing process. This module maintains the execution context, coordinates data flow between modules, and ensures the stability and reliability of the parsing process. It also provides a robust flow control mechanism, supporting different debugging modes such as single-step execution and continuous execution.

[0059] The simulation instruction execution module parses simulation instructions and calls the simulation system interface to process motion and control instructions. Motion instructions output tool position and trajectory information, driving the simulation platform to reproduce the machining process; control instructions update variable assignments, modal states, or parsing flows, affecting the internal behavior of the interpreter.

[0060] The error handling module detects anomalies in real time and records error logs, supporting parsing interruptions and recovery. It can identify various anomalies such as syntax errors and logical conflicts. This lightweight module focuses on collecting and processing anomaly information generated during process execution. It monitors the status output of each execution stage and collects and categorizes error information generated during parsing. Error types mainly include: configuration file parsing errors, syntax unit recognition errors, function word classification errors, and instruction group conflict errors.

[0061] In this invention, the user first sets the target system rules through a configuration file. After initialization, the parser reads the CNC program line by line, generating simulation instructions through lexical analysis, syntax analysis, and semantic interpretation. During instruction execution, dynamic adjustments are made based on simulation environment feedback, and an error handling mechanism ensures robustness. The entire architecture supports hot-swappable expansion through modular design; users can adapt to new systems by modifying XML configurations without requiring coding intervention.

[0062] As shown in Figure 12, to verify the correctness and universality of the parsing architecture described in this embodiment, comparative tests were conducted using CNC programs from the Fanuc system and the Siemens system, respectively. The upper part of the figure displays two sets of source code with different syntax specifications side-by-side: the left side shows the CNC program conforming to the Fanuc syntax standard, including modal instructions such as G17 and G40, and auxiliary function instructions such as T and M; the right side shows the equivalent program conforming to the Siemens specification, exhibiting significant differences in instruction format and parameter passing.

[0063] After processing the two heterogeneous programs using this analytical architecture, both ultimately generated the 3D part models shown in the lower part of the figure. These models clearly demonstrate the geometry at the same machining stage through yellow feature areas on a blue-green background, and their feature dimensions match the design drawings. This experimental result proves that although the input programs have systematic differences in syntax and instruction expression, after processing by the configurable analytical rules of this architecture, they can accurately generate the same toolpath and machining results.

[0064] This comparative experiment visually verifies the core advantage of this embodiment: through a configurable rule system, it can effectively eliminate syntax barriers between different CNC systems, constructing a universal CNC code parsing system across systems. This cross-system compatibility provides manufacturing enterprises with a unified simulation verification platform, significantly reducing simulation adaptation costs when multiple brands of equipment are produced on mixed production lines.

[0065] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / variant>

Claims

1. A configurable multi-system, multi-axis CNC program parsing method, characterized in that, include: Receive a pre-established structured configuration file that defines the parsing rules of the target CNC system; wherein, the structured configuration file records keyword classification information and an entry tree structure, the keyword classification information includes the program word classification type and address value matching type of the target CNC system, and the entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of program words; Based on the structured configuration file, the program to be parsed is sequentially subjected to lexical and syntactic parsing as well as semantic parsing, transforming the program into functional instructions.

2. The configurable multi-system multi-axis CNC program parsing method as described in claim 1, characterized in that, The keyword classification information includes functional keywords and auxiliary keywords; among them, the address value matching type of functional keywords includes multiple types such as numeric type, text type, alphanumeric type, list type, compound type and single program word type. Auxiliary keywords include logical operators, mathematical operators, function names, and special keywords. Special keywords include at least one of the following: variable name code, variable definition code, variable label code, branch code, comment code, and subroutine code.

3. The configurable multi-system multi-axis CNC program parsing method as described in claim 2, characterized in that, The entry tree structure specifically establishes the mapping relationship between the functional word codes formed by functional keywords and functional instructions under the context semantics, and sorts each functional instruction according to priority order; The entry tree structure adopts a hierarchical organization: the first level is the root node, which marks the starting point of the entry tree structure; the second level divides the function word codes into multiple categories according to their functional characteristics and sorts them to determine the priority order of instruction execution; the third level contains function word codes composed of function keywords and address values; the fourth level sets the context semantic conditions, including system modal information and other function word codes in the current program block. The fifth layer outputs matching function instructions; through a top-down matching judgment process, the first matching branch is selected as the final matching result.

4. The configurable multi-system multi-axis CNC program parsing method as described in claim 2, characterized in that, Based on the structured configuration file, the parsing program is sequentially subjected to lexical and syntactic parsing, as well as semantic parsing, specifically including: Lexical analysis: The program to be analyzed is divided into an indivisible sequence of lexical units, and the program type is identified based on the keyword classification information to generate a sequence of lexical units with type identifiers; Syntax analysis: Using formal grammar rules, the sequence of lexical units is combined and grouped to gradually construct an abstract syntax tree with a clear semantic structure; Semantic parsing: Based on the entry tree structure, the abstract syntax tree is deeply traversed to match functional instructions, and semantic functional information is extracted based on the address value matching type, so as to transform the program to be parsed into functional instructions.

5. The configurable multi-system multi-axis CNC program parsing method as described in claim 4, characterized in that, Semantic parsing also includes: For special keywords, based on the preset grammar processing mechanism, the function instructions are judged and parsed by recognizing special keywords that conform to the preset grammar structure.

6. The configurable multi-system multi-axis CNC program parsing method as described in claim 5, characterized in that, The parsed function instructions include processing instructions and control instructions. The methods also include: The program to be parsed is controlled to be parsed line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. Based on the preset target simulation system interface configuration, the parsed machining instruction sequence is converted for machining simulation.

7. The configurable multi-system multi-axis CNC program parsing method as described in claim 6, characterized in that, Also includes: The position of the program to be parsed is encoded in advance. If a subroutine call is involved, the subroutine is encoded and a corresponding relationship is established to facilitate the calling of the subroutine. During the parsing process, the current program position, the subroutine call position, and the program jump position are recorded, as well as the parsed variable information.

8. The configurable multi-system multi-axis CNC program parsing method as described in claim 1, characterized in that, The structured configuration file is an XML file, and the method further includes: Collect and record any abnormal information generated during the parsing process; these abnormal information include multiple errors such as configuration file format errors, lexical parsing errors, syntax parsing errors, and semantic parsing errors.

9. A configurable multi-system, multi-axis CNC program parsing system, characterized in that, include: The input and configuration module is used to receive a pre-established structured configuration file that defines the parsing rules of the target CNC system. The structured configuration file records keyword classification information and an entry tree structure. The keyword classification information includes the program word classification type and address value matching type of the target CNC system. The entry tree structure is used to establish the mapping relationship between program word code and function instructions to describe the semantic function mapping of the program word. An interpreter is used to perform lexical and syntactic analysis and semantic analysis on the program to be parsed based on the structured configuration file, and to convert the program to be parsed into functional instructions.

10. The configurable multi-system multi-axis CNC program parsing system as described in claim 9, characterized in that, The parsed function instructions include processing instructions and control instructions. The system also includes: The execution and feedback module is used to control the parsing of the program line by line or segment by segment. When a subroutine or jump control instruction is semantically parsed, the corresponding subroutine is called or the corresponding program segment is jumped to be parsed. The simulation instruction execution module is used to convert the parsed machining instruction sequence according to the preset target simulation system interface configuration in order to perform machining simulation.