CN110471670A - A kind of compiler, Compilation Method and method for tracing and DCS controller - Google Patents

A kind of compiler, Compilation Method and method for tracing and DCS controller Download PDF

Info

Publication number
CN110471670A
CN110471670A CN201910768902.2A CN201910768902A CN110471670A CN 110471670 A CN110471670 A CN 110471670A CN 201910768902 A CN201910768902 A CN 201910768902A CN 110471670 A CN110471670 A CN 110471670A
Authority
CN
China
Prior art keywords
intermediate code
code
node
grammer
optimization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910768902.2A
Other languages
Chinese (zh)
Inventor
王欣
黄玲
李蒙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Hollysys Co Ltd
Hangzhou Hollysys Automation Co Ltd
Original Assignee
Beijing Hollysys Co Ltd
Hangzhou Hollysys Automation Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Hollysys Co Ltd, Hangzhou Hollysys Automation Co Ltd filed Critical Beijing Hollysys Co Ltd
Priority to CN201910768902.2A priority Critical patent/CN110471670A/en
Publication of CN110471670A publication Critical patent/CN110471670A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/425Lexical analysis

Abstract

The application provides a kind of compiler, comprising: intermediate code is obtained module and obtains the intermediate code converted as unit of program organization unit for source code successively to be carried out morphological analysis, syntactic analysis, semantic analysis;Error tracking logic is inserted into module, for parsing intermediate code, and inserting error trace logic, obtains updating intermediate code;Optimization module executes code optimization for that will update intermediate code, obtains optimization and update intermediate code;Object Code Generator module generates object code for updating intermediate code using optimization.It can be seen that, the application passes through inserting error trace logic during compilation of source code, the object code with error tracking logic is ultimately generated, the object code can obtain configuration logic implementation procedure when by DCS controller load and execution error tracking logic, generation error tracked information, positioning failure reason.The application additionally provides Compilation Method, method for tracing, DCS controller simultaneously, all has above-mentioned beneficial effect.

Description

A kind of compiler, Compilation Method and method for tracing and DCS controller
Technical field
This application involves field of communication technology, in particular to a kind of Compilation Method, compiler and method for tracing and DCS control Device.
Background technique
DCS is the english abbreviation (Distributed Control System) of dcs, at present at It is ripe to be applied to the industries such as refining, metallurgy, chemical industry, building materials, electric power.Controller is the core equipment of DCS, is responsible for collection site number According to, operation control logic and algorithm, control field device output.Configurable controller logic error will will lead to live serious event Barrier, such as cannot in time, accurately track reason and thoroughly solve, will lead to more serious consequence, such fault characteristic is as follows: tight Acute, complexity, hysteresis quality, inoperable property.Even if controller developer is on the scene in time, can only also carry out theoretical quiet State analysis, can not carry out operation experiments and be verified, orientation problem means are limited.
How the basic reason of efficiently and accurately positioning field controller configuration logic mistake, be always that each DCS producer needs The problem to be faced, controller error method for tracing typically now are as follows:
Currently used main method is programmed logic analysis, records one by one.Configuration logic engineer is writing configuration During program, being directed to, which wrong may carry out single-point, chases after an analysis, increases the letter such as program assertion, overload alarm log recording Breath, such method can star certain effect for positioning site problems, but effect is limited, but such method major defect is such as Under: it is easy to appear dead zone of design, omission is generated, is fixed against each fault point of manual analysis, and increase in configuration program and assert, The breakdown judges logic such as overload alarm by this method often can not be to site environment comprehensive diagnostic complicated and changeable;Work It measures larger, the fault point of the configuration program logic in engineering is comprehensively analyzed, adds breakdown judge logical code process It is bigger workload, this not only increases human cost, more consumes PROJECT TIME.Every hyte state engineer's is horizontal and right The degree of understanding of program is different, and the quality that this work is completed is also different.
Therefore, how to provide a kind of scheme of solution above-mentioned technical problem is that those skilled in the art need to solve at present Problem.
Summary of the invention
The purpose of the application is to provide a kind of Compilation Method, compiler and method for tracing and DCS controller, easy to operate, Failure cause is more efficiently obtained comprehensively, improves user experience.Its concrete scheme is as follows:
The application provides a kind of compiler, comprising:
Intermediate code obtains module and obtains for source code successively to be carried out morphological analysis, syntactic analysis, semantic analysis The intermediate code converted as unit of program organization unit;
Error tracking logic insertion module is updated for parsing the intermediate code, and inserting error trace logic Intermediate code;
Optimization module obtains optimization and updates intermediate code for the update intermediate code to be executed code optimization;
Object Code Generator module generates object code for updating intermediate code using the optimization.
Optionally, the intermediate code is grammer forest, and the grammer forest includes each described program organizational unit pair The layer grammer forest answered, and each layer of grammer forest includes multiple syntax trees.
Optionally, the error tracking logic is inserted into module, comprising:
Marking unit marks the position of all syntax trees of the grammer forest for traversing the grammer forest It sets;
Determination unit, for determining the grammer tree type for marking the syntax tree having;
Intermediate code acquiring unit is updated, for calling syntax tree according to grammer tree type insertion preset function, is obtained To the update intermediate code.
Optionally, the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for when the grammer tree type is sequential organization syntax tree, in the sequential organization grammer The root node of insertion sequence function call syntax tree between the start node of tree and the original right brotgher of node of the start node, Wherein, the root node is the left brother of the right brotgher of node of the start node, the original right brotgher of node of the start node Younger brother's node;
Wherein, it includes the root node that the sequential function, which calls syntax tree, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing data.
Optionally, the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for being selection structural grammar tree when the grammer tree type, in the selection structural grammar tree All child nodes the left brotgher of node at insertion selection function call syntax tree root node, wherein the root node is Select the child node of structural grammar root vertex;
Wherein, the selection function call syntax tree includes the root node, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing information.
Optionally, the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for being loop structure syntax tree when the grammer tree type, in the loop structure syntax tree Loop body child node the left brotgher of node at insertion cyclical function call the root node of syntax tree, wherein the root node is The child node of loop structure grammer root vertex;
Wherein, it includes the root node that the cyclical function, which calls syntax tree, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing information.
Optionally, the optimization module, comprising:
Optimize unit and, to execute code optimization, obtains institute for distributing the update intermediate code to multiple threads It states optimization and updates intermediate code.
This application discloses a kind of Compilation Methods, comprising:
Source code is successively subjected to morphological analysis, syntactic analysis, semantic analysis, obtains turning as unit of program organization unit The intermediate code of change;
The intermediate code, and inserting error trace logic are parsed, obtains updating intermediate code;
The update intermediate code is executed into code optimization, optimization is obtained and updates intermediate code;
Intermediate code, which is updated, using the optimization generates object code.
Optionally, the intermediate code is grammer forest, and the grammer forest includes each described program organizational unit pair The layer grammer forest answered, and each layer of grammer forest includes multiple syntax trees.
Optionally, the parsing intermediate code, and inserting error trace logic, obtain updating intermediate code, comprising:
The grammer forest is traversed, the position of all syntax trees of the grammer forest is marked;
Determine the grammer tree type for the syntax tree that label has;
Syntax tree is called according to grammer tree type insertion preset function, obtains the update intermediate code.
It is optionally, described to call syntax tree according to grammer tree type insertion preset function, comprising:
Start node and institute when the grammer tree type is sequential organization syntax tree, in the sequential organization syntax tree State the root node of insertion sequence function call syntax tree between the original right brotgher of node of start node, wherein the root node It is the right brotgher of node, the left brotgher of node of the original right brotgher of node of the start node of the start node;
Wherein, it includes the root node that the sequential function, which calls syntax tree, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing data.
It is optionally, described to call syntax tree according to grammer tree type insertion preset function, comprising:
When the grammer tree type is selection structural grammar tree, in all child nodes for selecting structural grammar tree The root node of insertion selection function call syntax tree at the left brotgher of node, wherein the root node is selection structural grammar tree root The child node of node;
Wherein, the selection function call syntax tree includes the root node, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing information.
It is optionally, described to call syntax tree according to grammer tree type insertion preset function, comprising:
When the grammer tree type is loop structure syntax tree, in the loop body child node of the loop structure syntax tree The root node that cyclical function calls syntax tree is inserted at the left brotgher of node, wherein the root node is loop structure grammer tree root The child node of node;
Wherein, it includes the root node that the cyclical function, which calls syntax tree, and the left child node of the root node is for connecing Input parameter is received, the right child node of the root node is for saving logical tracing information.
Optionally, described that the update intermediate code is executed into code optimization, it obtains optimization and updates intermediate code, comprising:
The update intermediate code is distributed to multiple threads, to execute code optimization, is obtained in the optimization update Between code.
The application provides a kind of method for tracing, comprising:
The object code that load such as above-mentioned Compilation Method obtains;
Obtain the logical tracing data of configuration logic, generation error tracked information;
According to the error tracking information, positioning failure reason.
The application provides a kind of DCS controller, comprising:
Code loading module, for loading the object code obtained such as above-mentioned Compilation Method;
Error tracking information generating module, for obtaining the logical tracing data of configuration logic, generation error tracked information;
Failure cause locating module, for according to the error tracking information, positioning failure reason.
The application provides a kind of compiler, comprising: intermediate code obtains module, for source code successively to be carried out to morphology point Analysis, syntactic analysis, semantic analysis obtain the intermediate code converted as unit of program organization unit;The insertion of error tracking logic Module obtains updating intermediate code for parsing intermediate code, and inserting error trace logic;Optimization module, for that will update Intermediate code executes code optimization, obtains optimization and updates intermediate code;Object Code Generator module, used in being updated using optimization Between code building object code.As it can be seen that the application is ultimately generated by inserting error trace logic during compilation of source code Object code with error tracking logic, object code meeting when by DCS controller load and execution error tracking logic Configuration logic implementation procedure is obtained, generation error tracked information, positioning failure reason is easy to operate, more efficiently obtains comprehensively Failure cause improves user experience.The application additionally provides a kind of Compilation Method, method for tracing, DCS controller simultaneously, has There is above-mentioned beneficial effect, details are not described herein.
Detailed description of the invention
In order to illustrate the technical solutions in the embodiments of the present application or in the prior art more clearly, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of application for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is a kind of flow chart of Compilation Method provided by the embodiment of the present application;
Fig. 2 is a kind of structural schematic diagram of system architecture provided by the embodiment of the present application;
Fig. 3 is grammer forest structure schematic diagram provided by the embodiment of the present application;
Fig. 4 is the schematic diagram that sequential logic structure source code provided by the embodiments of the present application is converted into intermediate code;
Fig. 5 is that a kind of sequential logic structure provided by the embodiments of the present application inserts schematic diagram;
Fig. 6 is the schematic diagram that selection logical construction source code provided by the embodiments of the present application is converted into intermediate code;
Fig. 7 is that a kind of selection logical construction provided by the embodiments of the present application inserts schematic diagram;
Fig. 8 is the schematic diagram that circle logic structure source code provided by the embodiments of the present application is converted into intermediate code;
Fig. 9 is that a kind of circle logic structure provided by the embodiments of the present application inserts schematic diagram;
Figure 10 is the flow chart of another kind Compilation Method provided by the embodiment of the present application;
Figure 11 is a kind of structural schematic diagram of compiler provided by the embodiment of the present application;
Figure 12 is a kind of flow chart of method for tracing provided by the embodiments of the present application.
Specific embodiment
To keep the purposes, technical schemes and advantages of the embodiment of the present application clearer, below in conjunction with the embodiment of the present application In attached drawing, the technical scheme in the embodiment of the application is clearly and completely described, it is clear that described embodiment is Some embodiments of the present application, instead of all the embodiments.Based on the embodiment in the application, those of ordinary skill in the art Every other embodiment obtained without making creative work, shall fall in the protection scope of this application.
The present embodiment provides a kind of Compilation Methods, and inserting error trace logic, ultimately generates during compilation of source code Object code with error tracking logic can be more comprehensively efficient to realize during object code executes To failure cause, improve user experience, it is specific referring to FIG. 1, Fig. 1 is a kind of Compilation Method provided by the embodiment of the present application Flow chart specifically includes:
S101, source code is successively subjected to morphological analysis, syntactic analysis, semantic analysis, obtain be with program organization unit The intermediate code of unit conversion.
Source code, which is user, uses the industry controls language editorial logic source codes such as LD, ST, CFC, FBD, group by configuration software Compiler in state software equipment compiles source code into object code, and configuration software equipment passes through network or serial communication will Object code is downloaded to DCS controller, and then DCS controller loads the object code, and dispatches execution, it is known that compiler is whole The important component of a process realizes the source code of user configuration program to the conversion of DCS controller executable code, tool Body, the system architecture formed is controlled by configuration software equipment and DCS, as shown in Fig. 2, Fig. 2 is provided by the embodiment of the present application A kind of system architecture structural schematic diagram.
Wherein, for compiler, in the embodiment of the present application, compiler may include compiling front end, compiler back-end, before compiling End is mainly used for realizing that step S101, compiler back-end are mainly used for realizing step S102-S104.
Optionally, intermediate code is grammer forest, and grammer forest includes that the corresponding layer grammer of each program organization unit is gloomy Woods, and each layer of grammer forest includes multiple syntax trees.
Intermediate code is that unit is converted to one with POU (Program Organization Units, program organization unit) Kind intermediate structure, and then intermediate structure is converted to object code, the intermediate structure, that is, intermediate code.There are many real for intermediate code Existing form, the application is using grammer forest as a kind of implementation of intermediate code.Grammer forest is made of multiple syntax trees, tool Body, grammer forest includes the corresponding layer grammer forest of each POU, and the layer grammer that each POU corresponds to multiple syntax tree compositions is gloomy Woods, grammer forest structure shows as shown in figure 3, grammer forest is usually multiple layers of grammer forest structure, each layer of grammer forest It is an one-dimensional doubly linked list, each layer of grammer forest is made of more syntax trees, and every syntax tree is a ternary tree, and The node of every syntax tree is referred to as tree node, the subtree of tree node namely its father node (father tree).The grammer forest structure Essence is another expression-form of programmed logic.
S102, parsing intermediate code, and inserting error trace logic, obtain updating intermediate code.
Intermediate code is parsed, determines that the intermediate code i.e. different type of intermediate structure, the type include: sequential organization grammer Tree (such as: ADD, SUB, CALL etc.), selection structural grammar tree (such as: IF, Swith/case etc.), loop structure syntax tree (such as: For, While etc.).The inserting error trace logic in intermediate code obtains updating the i.e. newly-generated language of intermediate code Method tree.It is using program inserting technology in each syntax tree, inserting error trace logic is wrong for wrong more new logic Tracking error logic is recorded to configuration logic implementation procedure, generation error tracked information, when configuration logic when the error occurs, It can be according to error tracking Information locating failure cause.
Optionally, intermediate code, and inserting error trace logic are parsed, obtains updating intermediate code, comprising: traversal grammer Forest marks the position of all syntax trees of grammer forest;Determine the grammer tree type for the syntax tree that label has;According to Grammer tree type is inserted into preset function and calls syntax tree, obtains updating intermediate code.
During traversing grammer forest, to the position of all selecting sequence structural grammar trees, structural grammar tree, loop grammar tree Carry out classification marker is set, is prepared for next step inserting process, when the grammer tree type for the syntax tree that determining label has.Root According to different grammer tree types, the position of error tracking logic insertion is different, is inserted into default letter further according to grammer tree type Number calls syntax tree, obtains updating intermediate code.Wherein, error tracking logic includes that the preset function of multiple and different types is called Syntax tree, corresponding type include sequential organization syntax tree, selection structural grammar tree, loop structure syntax tree.
Optionally, syntax tree is called according to grammer tree type insertion preset function, comprising: when grammer tree type is that sequence is tied When structure syntax tree, the insertion sequence letter between the start node of sequential organization syntax tree and the original right brotgher of node of start node Number calls the root node of syntax tree, wherein root node is the original right brother section of the right brotgher of node of start node, start node The left brotgher of node of point;Wherein, it includes root node that sequential function, which calls syntax tree, and the left child node of root node is for receiving input Parameter, the right child node of root node is for saving logical tracing data.
ST is certainly not limited to by taking ST language as an example for sequential organization logical grammar tree, is also possible to LD language, CFC language Speech, FBD language, referring to FIG. 4, Fig. 4 is that sequential logic structure source code provided by the embodiments of the present application is converted into intermediate code Schematic diagram, at the right brotgher of node of first start node (START node) of this syntax tree be inserted into sequence Function call syntax tree, that is, pitching pile code, as shown in figure 5, Fig. 5 is that a kind of sequential logic structure provided by the embodiments of the present application is inserted Fill schematic diagram.The syntax tree being newly inserted into is that sequential function calls syntax tree, which calls syntax tree left subtree node generation Table inputs parameter, including POU number, sequential logic structure I D, system time, the sequential function call the right child node of syntax tree Represent the function call to SeqStructureRecord ().It is the library that compiling is completed in advance that the sequential function, which calls syntax tree, File is completed incoming POU number, sequential logic structure I D and present system time being saved in logical tracing data field Function.Logical tracing data field is the region of memory delimited in advance, and for saving logical tracing information, these information can be determined Phase saves into non-power-failure volatile storage medium, and is sent to historical data base.
Optionally, syntax tree is called according to grammer tree type insertion preset function, comprising: when grammer tree type is selection knot Structure syntax tree, the insertion selection function call syntax tree at the left brotgher of node of all child nodes of selection structural grammar tree Root node, wherein root node is the child node for selecting structural grammar root vertex;Wherein, selection function call syntax tree includes Root node, the left child node of root node is for receiving input parameter, and the right child node of root node is for saving logical tracing information.
ST is certainly not limited to by taking ST language as an example for selection architecture logic syntax tree, is also possible to LD language, CFC language Speech, FBD language.Referring to FIG. 6, Fig. 6 is that selection logical construction source code provided by the embodiments of the present application is converted into intermediate code Schematic diagram, one selection function call syntax of the branch node of structure (selection) insertion at the child nodes of this syntax tree Tree is pitching pile code, as shown in fig. 7, Fig. 7 is that a kind of selection logical construction provided by the embodiments of the present application inserts schematic diagram.The choosing The left child node for selecting function call syntax tree represents incoming parameter, these parameter informations include in logical tracing information linear list POU number, selection architecture logic number, time;The right child node representative pair of the selection function call syntax tree The function call of BranchStructureRecord ().The function and above-mentioned SeqStructureRecord () function are similar Seemingly, the preservation function of selection logical construction tracked information is completed.
Optionally, syntax tree is called according to grammer tree type insertion preset function, comprising: when grammer tree type is circulation knot Structure syntax tree is inserted into cyclical function at the left brotgher of node of the loop body child node of loop structure syntax tree and calls syntax tree Root node, wherein root node is the child node of loop structure grammer root vertex;Wherein, cyclical function calling syntax tree includes Root node, the left child node of root node is for receiving input parameter, and the right child node of root node is for saving logical tracing information.
ST is certainly not limited to by taking ST language as an example for loop structure logical grammar tree, is also possible to LD language, CFC language Speech, FBD language, Fig. 8 are the schematic diagram that circle logic structure source code provided by the embodiments of the present application is converted into intermediate code.With Above-mentioned selection structural grammar tree inserting process is similar, and (loop body children tree nodes) are inserted at this syntax tree child nodes One cyclical function calls syntax tree, that is, pitching pile code, as shown in figure 9, Fig. 9 is that a kind of circulation provided by the embodiments of the present application is patrolled It collects structure and inserts schematic diagram.The cyclical function calls the left child node of syntax tree to represent incoming parameter, and parameter information includes that POU is compiled Number, loop body number, the time;It is CyclicStructureRecord () letter that the cyclical function, which calls the right child node of syntax tree, Number calls.The function is similar with above-mentioned SeqStructureRecord (), BranchStructureRecord () function, Complete the preservation function of loop structure logical tracing information.
S103, intermediate code execution code optimization will be updated, and will obtain optimization and updates intermediate code.
S104, intermediate code generation object code is updated using optimization.
After successfully being inserted to grammer forest, updates intermediate code and handled by compiler back-end.Compiler back-end by intermediate code into One-step optimization obtains optimization and updates intermediate code, is further formed the assembly code of counterlogic, then be converted by assembly code Machine code (binary code).After the engineering logic that configuration engineer writes is compiled into binary code by configuration software, Machine code is downloaded into controller by way of network or serial communication, and by controller load operating.In this way, controller In just run the configuration logic that configuration engineer is write, and in the configuration logic during above-mentioned compiling inserting, Inserted tracking logic.Tracking logic can recorde the operational process of program, and the non-power-failure recorded to this controller is easy In the property lost storage medium, and history server is uploaded to by network cycle.Pass through the tracked information, it may be convenient to know group Actual motion process of the state logic in controller.When run-time error occurs in live configuration logic, by checking configuration logic Tracked information, and then program point where positioning failure logic, improve the solution efficiency of site problems.
As it can be seen that while the advantages that the present embodiment is non-volatile in the power down for guaranteeing fault trace method, and historical data can be looked into, Relative in configuration program, increase is asserted, overload alarm is to single fault point error tracking mode, and the present invention is compiling link, It is directed to entire configuration logic generation error tracked information, the information of tracking is more comprehensive;Relative to current manually analysis, The trace mode of addition tracking fault point, the present embodiment automatically generate configuration logic in configuration logic compilation process manually Fault trace point, it is more convenient to use to user;The present embodiment defines a kind of intermediate code structure, in view of this intermediate code Structure is inserted, and industry control programming language (LD, ST, CFC, FBD etc.) difference is thus shielded, and versatility is more preferable.
Based on the above-mentioned technical proposal, the present embodiment is by inserting error trace logic during compilation of source code, finally The object code with error tracking logic is generated, the object code is by DCS controller load and execution error tracking logic When can obtain configuration logic implementation procedure, generation error tracked information, positioning failure reason is easy to operate, more comprehensively efficiently Failure cause is obtained, user experience is improved.
Based on the above embodiment, specific referring to FIG. 10, Figure 10 is the embodiment of the present application in order to improve compiling efficiency The flow chart of provided another kind Compilation Method, comprising:
S201, source code is successively subjected to morphological analysis, syntactic analysis, semantic analysis, obtain be with program organization unit The intermediate code of unit conversion.
S202, parsing intermediate code, and inserting error trace logic, obtain updating intermediate code.
S203, update intermediate code is distributed to multiple threads, to execute code optimization, obtains optimization and update intermediate generation Code.
Intermediate code is configured by compiler as unit of POU, it is to be appreciated that updating intermediate code is also with POU It is configured for unit, therefore the treatment effeciency in order to guarantee optimization, can will distribute multiple threads, to improve processing effect Rate.For example, the supported thread of central processing unit is 6, the unit of the present embodiment includes 8, can be according to priority principle, will Update intermediate code 8 units be divided into 2,3,4,5,6 threads handled, improve treatment effeciency.
S204, intermediate code generation object code is updated using optimization.
Based on the above-mentioned technical proposal, the present embodiment improves compiling effect by taking multiple thread process to update intermediate code Rate.
A kind of compiler provided by the embodiments of the present application is introduced below, compiler described below and above description Compilation Method can correspond to each other reference, with reference to Figure 11, Figure 11 be the embodiment of the present application provided by a kind of structure of compiler Schematic diagram, comprising:
Intermediate code obtains module 100 and obtains for source code successively to be carried out morphological analysis, syntactic analysis, semantic analysis To the intermediate code converted as unit of program organization unit;
Error tracking logic insertion module 200 is updated for parsing intermediate code, and inserting error trace logic Intermediate code;
Optimization module 300 executes code optimization for that will update intermediate code, obtains optimization and update intermediate code;
Object Code Generator module 400 generates object code for updating intermediate code using optimization.
Wherein, the compiler of traditional configuration software is as shown in Fig. 2, mainly include two parts: after compiling front end, compiling End.Compiling front end mainly includes morphological analysis, syntactic analysis, lexical analysis;Compiler back-end mainly includes code optimization, binary system Code generation module.After the compiled front-end processing of source code, intermediate code is generated.Compiler back-end further locates intermediate code Reason generates object code.
The present embodiment has been ultimately generated by inserting error trace logic during compilation of source code with error tracking The object code of logic, the object code can obtain configuration logic when by DCS controller load and execution error tracking logic and hold Row process, generation error tracked information, positioning failure reason is easy to operate, more efficiently obtains failure cause comprehensively, improves and uses Family experience.
In some specific embodiments, intermediate code is grammer forest, and grammer forest includes each program organization unit Corresponding layer grammer forest, and each layer of grammer forest includes multiple syntax trees.
In some specific embodiments, error tracking logic is inserted into module 200, comprising:
Marking unit marks the position of all syntax trees of grammer forest for traversing grammer forest;
Determination unit, for determining the grammer tree type for marking the syntax tree having;
Intermediate code acquiring unit is updated, for calling syntax tree according to grammer tree type insertion preset function, is obtained more New intermediate code.
In some specific embodiments, intermediate code acquiring unit is updated, comprising:
It is inserted into subelement, for when grammer tree type is sequential organization syntax tree, in the beginning of sequential organization syntax tree The root node of insertion sequence function call syntax tree between node and the original right brotgher of node of start node, wherein root node It is the right brotgher of node, the left brotgher of node of the original right brotgher of node of start node of start node;
Wherein, it includes root node that sequential function, which calls syntax tree, and the left child node of root node is for receiving input parameter, root The right child node of node is for saving logical tracing data.
In some specific embodiments, intermediate code acquiring unit is updated, comprising:
Be inserted into subelement, for when grammer tree type be selection structural grammar tree, select structural grammar tree it is all in The root node of insertion selection function call syntax tree at the left brotgher of node of child node, wherein root node is selection structural grammar The child node of root vertex;
Wherein, selection function call syntax tree includes root node, and the left child node of root node is for receiving input parameter, root The right child node of node is for saving logical tracing information.
In some specific embodiments, intermediate code acquiring unit is updated, comprising:
It is inserted into subelement, for being loop structure syntax tree when grammer tree type, in the loop body of loop structure syntax tree The root node that cyclical function calls syntax tree is inserted at the left brotgher of node of child node, wherein root node is loop structure grammer The child node of root vertex;
Wherein, it includes root node that cyclical function, which calls syntax tree, and the left child node of root node is for receiving input parameter, root The right child node of node is for saving logical tracing information.
In some specific embodiments, optimization module 300, comprising:
Optimize unit, distributes for intermediate code will to be updated to multiple threads, to execute code optimization, obtain optimizing more New intermediate code.
Since the embodiment of compiler part is corresponded to each other with the embodiment of Compilation Method part, compiler part Embodiment refers to the description of the embodiment of Compilation Method part, wouldn't repeat here.
A kind of electronic equipment provided by the embodiments of the present application is introduced below, electronic equipment described below and above The Compilation Method of description can correspond to each other reference.
The embodiment of the present application provides a kind of electronic equipment, comprising:
Memory, for storing computer program;
Processor is realized when for executing computer program such as the step of above-mentioned Compilation Method.
Since the embodiment of electronics portion is corresponded to each other with the embodiment of Compilation Method part, electronic equipment portion The embodiment divided refers to the description of the embodiment of Compilation Method part, wouldn't repeat here.
A kind of computer readable storage medium provided by the embodiments of the present application is introduced below, calculating described below Machine readable storage medium storing program for executing can correspond to each other reference with above-described Compilation Method.
The embodiment of the present application provides a kind of computer readable storage medium, and calculating is stored on computer readable storage medium Machine program is realized when computer program is executed by processor such as the step of above-mentioned Compilation Method.
Since the embodiment of computer readable storage medium part is corresponded to each other with the embodiment of Compilation Method part, The embodiment of computer readable storage medium part refers to the description of the embodiment of Compilation Method part, wouldn't repeat here.
Figure 12 is please referred to, Figure 12 is a kind of flow chart of method for tracing provided by the embodiments of the present application, comprising:
The object code that S301, load Compilation Method obtain;
S302, the logical tracing data for obtaining configuration logic, generation error tracked information;
S303, according to error tracking information, positioning failure reason.
Based on the above-mentioned technical proposal, the present embodiment provides a kind of method for tracing, comprising: the target that load Compilation Method obtains Code;Obtain the logical tracing data of configuration logic, generation error tracked information;According to error tracking information, positioning failure is former Cause;Compilation Method includes that source code is successively carried out morphological analysis, syntactic analysis, semantic analysis, is obtained with program organization unit For the intermediate code of unit conversion;Intermediate code, and inserting error trace logic are parsed, obtains updating intermediate code;It will update Intermediate code executes code optimization, obtains optimization and updates intermediate code;Intermediate code, which is updated, using optimization generates object code.This Application inserting error trace logic during compilation of source code, generates object code, which adds by DCS controller Configuration logic implementation procedure can be obtained when executing error tracking logic by carrying, and more comprehensively, efficiently obtain failure cause positioning failure Reason.
A kind of DCS controller provided by the embodiments of the present application is introduced below, DCS controller described below with it is upper The method for tracing of text description can correspond to each other reference.
A kind of DCS controller includes:
Loading module, for loading the object code obtained such as above-mentioned method for tracing;
Error tracking information generating module, for obtaining the logical tracing data of configuration logic, generation error tracked information;
Failure cause locating module, for according to error tracking information, positioning failure reason.
A kind of electronic equipment provided by the embodiments of the present application is introduced below, electronic equipment described below and above The method for tracing of description can correspond to each other reference.
The embodiment of the present application provides a kind of electronic equipment, comprising:
Memory, for storing computer program;
Processor is realized when for executing computer program such as the step of above-mentioned method for tracing.
Since the embodiment of electronics portion is corresponded to each other with the embodiment of method for tracing part, electronic equipment portion The embodiment divided refers to the description of the embodiment of method for tracing part, wouldn't repeat here.
A kind of computer readable storage medium provided by the embodiments of the present application is introduced below, calculating described below Machine readable storage medium storing program for executing can correspond to each other reference with above-described method for tracing.
The embodiment of the present application provides a kind of computer readable storage medium, and calculating is stored on computer readable storage medium Machine program is realized when computer program is executed by processor such as the step of above-mentioned method for tracing.
Since the embodiment of computer readable storage medium part is corresponded to each other with the embodiment of method for tracing part, The embodiment of computer readable storage medium part refers to the description of the embodiment of method for tracing part, wouldn't repeat here.
Each embodiment is described in a progressive manner in specification, the highlights of each of the examples are with other realities The difference of example is applied, the same or similar parts in each embodiment may refer to each other.For device disclosed in embodiment Speech, since it is corresponded to the methods disclosed in the examples, so being described relatively simple, related place is referring to method part illustration .
Professional further appreciates that, unit described in conjunction with the examples disclosed in the embodiments of the present disclosure And algorithm steps, can be realized with electronic hardware, computer software, or a combination of the two, in order to clearly demonstrate hardware and The interchangeability of software generally describes each exemplary composition and step according to function in the above description.These Function is implemented in hardware or software actually, the specific application and design constraint depending on technical solution.Profession Technical staff can use different methods to achieve the described function each specific application, but this realization is not answered Think beyond scope of the present application.
The step of method described in conjunction with the examples disclosed in this document or algorithm, can directly be held with hardware, processor The combination of capable software module or the two is implemented.Software module can be placed in random access memory (RAM), memory, read-only deposit Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology In any other form of storage medium well known in field.
A kind of Compilation Method provided herein, compiler, method for tracing, DCS controller have been carried out in detail above It introduces.Specific examples are used herein to illustrate the principle and implementation manner of the present application, the explanation of above embodiments It is merely used to help understand the present processes and its core concept.It should be pointed out that for the ordinary skill people of the art Member for, under the premise of not departing from the application principle, can also to the application, some improvement and modification can also be carried out, these improve and Modification is also fallen into the protection scope of the claim of this application.

Claims (10)

1. a kind of compiler characterized by comprising
Intermediate code obtains module and obtains for source code successively to be carried out morphological analysis, syntactic analysis, semantic analysis with journey Sequence organizational unit is the intermediate code of unit conversion;
Error tracking logic is inserted into module, for parsing the intermediate code, and inserting error trace logic, obtains updating intermediate Code;
Optimization module obtains optimization and updates intermediate code for the update intermediate code to be executed code optimization;
Object Code Generator module generates object code for updating intermediate code using the optimization.
2. compiler according to claim 1, which is characterized in that the intermediate code is grammer forest, and the grammer is gloomy Woods includes the corresponding layer grammer forest of each described program organizational unit, and each layer of grammer forest includes multiple syntax trees.
3. compiler according to claim 2, which is characterized in that the error tracking logic is inserted into module, comprising:
Marking unit marks the position of all syntax trees of the grammer forest for traversing the grammer forest;
Determination unit, for determining the grammer tree type for marking the syntax tree having;
Intermediate code acquiring unit is updated, for calling syntax tree according to grammer tree type insertion preset function, obtains institute State update intermediate code.
4. compiler according to claim 2, which is characterized in that the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for when the grammer tree type is sequential organization syntax tree, in the sequential organization syntax tree The root node of insertion sequence function call syntax tree between start node and the original right brotgher of node of the start node, In, the root node is the Zuo brother of the right brotgher of node of the start node, the original right brotgher of node of the start node Node;
Wherein, it includes the root node that the sequential function, which calls syntax tree, and the left child node of the root node is defeated for receiving Enter parameter, the right child node of the root node is for saving logical tracing data.
5. compiler according to claim 2, which is characterized in that the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for being selection structural grammar tree when the grammer tree type, in the institute of the selection structural grammar tree There is the root node of insertion selection function call syntax tree at the left brotgher of node of child nodes, wherein the root node is selection The child node of structural grammar root vertex;
Wherein, the selection function call syntax tree includes the root node, and the left child node of the root node is defeated for receiving Enter parameter, the right child node of the root node is for saving logical tracing information.
6. compiler according to claim 2, which is characterized in that the update intermediate code acquiring unit, comprising:
It is inserted into subelement, for being loop structure syntax tree when the grammer tree type, in following for the loop structure syntax tree The root node that cyclical function calls syntax tree is inserted at the left brotgher of node of ring body child node, wherein the root node is circulation The child node of structural grammar root vertex;
Wherein, it includes the root node that the cyclical function, which calls syntax tree, and the left child node of the root node is defeated for receiving Enter parameter, the right child node of the root node is for saving logical tracing information.
7. compiler according to any one of claims 1 to 6, which is characterized in that the optimization module, comprising:
Optimization unit, to execute code optimization, obtains described excellent for distributing the update intermediate code to multiple threads Change and updates intermediate code.
8. a kind of Compilation Method characterized by comprising
Source code is successively subjected to morphological analysis, syntactic analysis, semantic analysis, obtains converting as unit of program organization unit Intermediate code;
The intermediate code, and inserting error trace logic are parsed, obtains updating intermediate code;
The update intermediate code is executed into code optimization, optimization is obtained and updates intermediate code;
Intermediate code, which is updated, using the optimization generates object code.
9. a kind of method for tracing characterized by comprising
Load the object code that Compilation Method as claimed in claim 8 obtains;
Obtain the logical tracing data of configuration logic, generation error tracked information;
According to the error tracking information, positioning failure reason.
10. a kind of DCS controller characterized by comprising
Loading module, the object code obtained for loading Compilation Method as claimed in claim 8;
Error tracking information generating module, for obtaining the logical tracing data of configuration logic, generation error tracked information;
Failure cause locating module, for according to the error tracking information, positioning failure reason.
CN201910768902.2A 2019-08-20 2019-08-20 A kind of compiler, Compilation Method and method for tracing and DCS controller Pending CN110471670A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910768902.2A CN110471670A (en) 2019-08-20 2019-08-20 A kind of compiler, Compilation Method and method for tracing and DCS controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910768902.2A CN110471670A (en) 2019-08-20 2019-08-20 A kind of compiler, Compilation Method and method for tracing and DCS controller

Publications (1)

Publication Number Publication Date
CN110471670A true CN110471670A (en) 2019-11-19

Family

ID=68512019

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910768902.2A Pending CN110471670A (en) 2019-08-20 2019-08-20 A kind of compiler, Compilation Method and method for tracing and DCS controller

Country Status (1)

Country Link
CN (1) CN110471670A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124906A (en) * 2019-12-17 2020-05-08 支付宝(杭州)信息技术有限公司 Tracking method, compiling method and device based on dynamic embedded points and electronic equipment
CN111308974A (en) * 2020-02-27 2020-06-19 杭州和利时自动化有限公司 Method, system and equipment for controlling DCS simulation system
CN112346734A (en) * 2020-11-06 2021-02-09 杭州和利时自动化有限公司 Compiling verification method, device and equipment and computer readable storage medium
CN112558947A (en) * 2020-12-18 2021-03-26 京东数字科技控股股份有限公司 Program call tracing method, device and storage medium
CN113031954A (en) * 2019-12-24 2021-06-25 阿里巴巴集团控股有限公司 Code compiling method and device, electronic equipment, storage medium and heterogeneous system
CN113703779A (en) * 2021-09-06 2021-11-26 武汉市字节码科技有限公司 Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
CN114168142A (en) * 2021-10-12 2022-03-11 芯华章科技股份有限公司 Code coverage rate calculation method, electronic device and storage medium
CN114721667A (en) * 2022-04-21 2022-07-08 北京万昇智能科技有限公司 Method and device for compiling ST code into WebAssembly code
CN114860216A (en) * 2022-07-07 2022-08-05 麒麟软件有限公司 C program dynamic tracking method and system for integrated development environment
CN115185900A (en) * 2022-05-20 2022-10-14 中核武汉核电运行技术股份有限公司 Downloading method for time sequence data real-time calculation algorithm

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010011371A1 (en) * 1998-09-29 2001-08-02 Min-Mei Tang Compilation of embedded language statements in a source code program
US20020169999A1 (en) * 2001-05-14 2002-11-14 Microsoft Corporation Placing exception throwing instructions in compiled code
US20030188299A1 (en) * 2001-08-17 2003-10-02 Broughton Jeffrey M. Method and apparatus for simulation system compiler
US20050050537A1 (en) * 2003-08-21 2005-03-03 Thompson J. Patrick Systems and method for representing relationships between units of information manageable by a hardware/software interface system
CN102231109A (en) * 2011-07-15 2011-11-02 南京大学 Traceless manageable automatic source code instrumentation method
US20120054722A1 (en) * 2010-08-30 2012-03-01 Susumu Takeda Trace generating unit, system, and program of the same
WO2012081024A1 (en) * 2010-12-16 2012-06-21 Eyal Ben-Avraham System and method for optimizing parallel compilation of a source code
CN104142819A (en) * 2013-07-10 2014-11-12 腾讯科技(深圳)有限公司 File processing method and device
US20150020056A1 (en) * 2013-07-10 2015-01-15 Tencent Technology (Shenzhen) Company Limited Methods and systems for file processing
CN106648681A (en) * 2016-12-29 2017-05-10 南京科远自动化集团股份有限公司 System and method for compiling and loading programmable language
CN106940654A (en) * 2017-02-15 2017-07-11 南京航空航天大学 The automatic detection and localization method of EMS memory error in source code

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010011371A1 (en) * 1998-09-29 2001-08-02 Min-Mei Tang Compilation of embedded language statements in a source code program
US20020169999A1 (en) * 2001-05-14 2002-11-14 Microsoft Corporation Placing exception throwing instructions in compiled code
US20030188299A1 (en) * 2001-08-17 2003-10-02 Broughton Jeffrey M. Method and apparatus for simulation system compiler
US20050050537A1 (en) * 2003-08-21 2005-03-03 Thompson J. Patrick Systems and method for representing relationships between units of information manageable by a hardware/software interface system
US20120054722A1 (en) * 2010-08-30 2012-03-01 Susumu Takeda Trace generating unit, system, and program of the same
WO2012081024A1 (en) * 2010-12-16 2012-06-21 Eyal Ben-Avraham System and method for optimizing parallel compilation of a source code
CN102231109A (en) * 2011-07-15 2011-11-02 南京大学 Traceless manageable automatic source code instrumentation method
CN104142819A (en) * 2013-07-10 2014-11-12 腾讯科技(深圳)有限公司 File processing method and device
US20150020056A1 (en) * 2013-07-10 2015-01-15 Tencent Technology (Shenzhen) Company Limited Methods and systems for file processing
CN106648681A (en) * 2016-12-29 2017-05-10 南京科远自动化集团股份有限公司 System and method for compiling and loading programmable language
CN106940654A (en) * 2017-02-15 2017-07-11 南京航空航天大学 The automatic detection and localization method of EMS memory error in source code

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
曾彤: "面向对象技术的组态软件实时数据库的设计与实现", 《广西轻工业》 *
赵忠明等: "基于CodeTest工具的DCS系统嵌入式测试设计与实现", 《电子技术应用》 *
陈泰红: "《嵌入式多核DSP应用开发与实践》", 31 March 2017, 北京航空航天大学出版社 *
马圣: "一种新的IEC61131-3语言编译器中间结构的设计方案", 《电子元器件应用》 *

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124906A (en) * 2019-12-17 2020-05-08 支付宝(杭州)信息技术有限公司 Tracking method, compiling method and device based on dynamic embedded points and electronic equipment
CN111124906B (en) * 2019-12-17 2022-06-28 蚂蚁财富(上海)金融信息服务有限公司 Tracking method, compiling method and device based on dynamic embedded points and electronic equipment
CN113031954A (en) * 2019-12-24 2021-06-25 阿里巴巴集团控股有限公司 Code compiling method and device, electronic equipment, storage medium and heterogeneous system
CN111308974A (en) * 2020-02-27 2020-06-19 杭州和利时自动化有限公司 Method, system and equipment for controlling DCS simulation system
CN112346734A (en) * 2020-11-06 2021-02-09 杭州和利时自动化有限公司 Compiling verification method, device and equipment and computer readable storage medium
CN112558947B (en) * 2020-12-18 2024-04-05 京东科技控股股份有限公司 Program call tracking method, device and storage medium
CN112558947A (en) * 2020-12-18 2021-03-26 京东数字科技控股股份有限公司 Program call tracing method, device and storage medium
CN113703779A (en) * 2021-09-06 2021-11-26 武汉市字节码科技有限公司 Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
CN113703779B (en) * 2021-09-06 2024-04-16 王喆 Cross-platform multi-language compiling method and ultra-light Internet of things virtual machine
CN114168142A (en) * 2021-10-12 2022-03-11 芯华章科技股份有限公司 Code coverage rate calculation method, electronic device and storage medium
CN114721667A (en) * 2022-04-21 2022-07-08 北京万昇智能科技有限公司 Method and device for compiling ST code into WebAssembly code
CN115185900A (en) * 2022-05-20 2022-10-14 中核武汉核电运行技术股份有限公司 Downloading method for time sequence data real-time calculation algorithm
CN114860216B (en) * 2022-07-07 2022-11-08 麒麟软件有限公司 C program dynamic tracking method and system for integrated development environment
CN114860216A (en) * 2022-07-07 2022-08-05 麒麟软件有限公司 C program dynamic tracking method and system for integrated development environment

Similar Documents

Publication Publication Date Title
CN110471670A (en) A kind of compiler, Compilation Method and method for tracing and DCS controller
US8091071B2 (en) Method and system for template-based code generation
CN106293664A (en) Code generating method and device
CN106777101B (en) Data processing engine
US20090144703A1 (en) Method and system for versioning a software system
CN104932905A (en) Automatic code generation method from AADL to C language
CN102306122A (en) Automated testing method and equipment
CN101980546B (en) Intelligent network platform, service execution method and method for analyzing service abnormality
CN111208995A (en) Method, system, device and storage medium for automatically generating IBM host job
CN110795091A (en) Modular routing decoupling method, storage medium, electronic device and system
CN117075909B (en) Compiling method, electronic device and medium for realizing parallel programming
US20140310070A1 (en) Coordinated business rules management and mixed integer programming
CN101351801A (en) Method for reconstructing statement, and computer system having the function therefor
US20090064092A1 (en) Visual programming language optimization
CN105446788B (en) A kind of information processing method and electronic equipment
CN114995226A (en) Flow control system and method for aerospace embedded equipment
CN109902085B (en) Configuration storage structure optimization method and system
JP2014228990A (en) Control program creation apparatus and control program creation method
Hayhurst et al. Towards capability-based synthesis of executable robot behaviors
US7603661B2 (en) Parse table generation method and system
US5394550A (en) System for affecting recompilation of source code
Delsart et al. SpartyJet 4.0 User's Manual
CN115390913B (en) Log monitoring method and device for zero code intrusion, electronic equipment and storage medium
KR20110024996A (en) Language conversion apparatus and method for autonomous of satellite control in satellite ground control system
Strittmatter et al. Towards a Modular Palladio Component Model.

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20191119

RJ01 Rejection of invention patent application after publication