CN109271168A - A kind of code conversion method, device and equipment, storage medium - Google Patents

A kind of code conversion method, device and equipment, storage medium Download PDF

Info

Publication number
CN109271168A
CN109271168A CN201810904064.2A CN201810904064A CN109271168A CN 109271168 A CN109271168 A CN 109271168A CN 201810904064 A CN201810904064 A CN 201810904064A CN 109271168 A CN109271168 A CN 109271168A
Authority
CN
China
Prior art keywords
keyword
language
code
language format
format
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
CN201810904064.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.)
Shanghai Whale Robot Technology Co Ltd
Original Assignee
Shanghai Whale Robot Technology 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 Shanghai Whale Robot Technology Co Ltd filed Critical Shanghai Whale Robot Technology Co Ltd
Priority to CN201810904064.2A priority Critical patent/CN109271168A/en
Publication of CN109271168A publication Critical patent/CN109271168A/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/51Source to source

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The present invention provides a kind of code conversion method, device and equipment, storage medium, code conversion method includes: whether the character string detected in object code is the keyword for meeting specified requirements, if so, the language format of the keyword is converted to second language format from first language format;From the related information identified in the object code with the keyword association under second language format in the object code;The related information that will identify that is recombinated with the keyword under corresponding second language format, with the object code after being converted.Solve the problems, such as that programming mode is limited under specified running environment.

Description

A kind of code conversion method, device and equipment, storage medium
Technical field
The present invention relates to code process technical fields more particularly to a kind of code conversion method, device and equipment, storage to be situated between Matter.
Background technique
Programming language has diversity, including assembler language, machine language, high-level language etc., and high-level language can divide For procedure enorited language and object-oriented language, procedure enorited language such as Fortran language, C language, Chinese program are set Count language etc.;Object-oriented language such as C++, C#, Smalltalk, python, JAVA etc..
Code can be run on the controller of needs, to realize control of the controller to executing agency, although programming language Speech has diversity, but the usually supported language of controller is limited, such as can only support C language.At present in the case, Programmer can only be programmed by C language, and the C language of completion is written in controller and is run, thus there is specified operation The limited problem of programming mode under environment.
Summary of the invention
In view of this, the present invention provides a kind of code conversion method, device and equipment, storage medium, solve in specified fortune The limited problem of programming mode under row environment.
First aspect present invention provides a kind of code conversion method, comprising:
Whether the character string detected in object code is the keyword for meeting specified requirements, if so, by the keyword Language format be converted to second language format from first language format;
From the pass identified in the object code with the keyword association under second language format in the object code Join information;
The related information that will identify that is recombinated with the keyword under corresponding second language format, after obtaining conversion Object code.
According to one embodiment of present invention, whether the character string in the detection object code is to meet specified requirements Keyword, comprising:
The character string in the object code is traversed, searches the character string traversed in the nominal key table of acquisition;
When finding the character string, judge in the nominal key table with the presence or absence of the character string corresponding the Keyword under two language formats, and if it exists, then determine that the character string is the keyword for meeting specified requirements.
According to one embodiment of present invention, the language format by keyword is converted to second from first language format Language format, comprising:
The keyword for meeting specified requirements under first language format is replaced with from the nominal key table Keyword under the correspondence second language format of acquisition.
According to one embodiment of present invention, this method may further comprise:
Keyword under the corresponding second language format of the character string if it does not exist, then by the language where the character string Sentence replaces with the specified sentence under corresponding second language format.
According to one embodiment of present invention, the keyword for meeting specified requirements includes at least one below:
Logical identifier;
Annotation identifier;
Function declaration identifier;
Condition judges identifier.
According to one embodiment of present invention, from being identified in the object code and second language in the object code The related information of keyword association under format, comprising:
For every line code string of the object code, search whether to deposit in related information table according to the code string In matched regular expression, and if it exists, then from being identified in the code string and keyword in the regular expression closes The related information of connection;
Wherein, the regular expression includes the key under at least one ambiguous characters and at least one second language format Word.
According to one embodiment of present invention, the related information that will identify that and corresponding second language format Under keyword recombination, comprising:
The related information that will identify that according to corresponding recombination format under corresponding second language format described in Keyword recombination, wherein the recombination format is according to the keyword under the second language format in keyword and recombination format Corresponding relationship in determine.
Second aspect of the present invention provides a kind of code conversion device, comprising:
Keyword conversion module, for detecting whether the character string in object code is the keyword for meeting specified requirements, If so, the language format of the keyword is converted to second language format from first language format;
Related information identification module, for from being identified in the object code and second language lattice in the object code The related information of keyword association under formula;
Recombination module, the related information for will identify that and the keyword weight under corresponding second language format Group, with the object code after being converted.
Third aspect present invention provides a kind of electronic equipment, including processor and memory;The memory is stored with can The program called by processor;Wherein, when the processor executes described program, the institute provided such as first aspect present invention is realized The code conversion method stated.
Fourth aspect present invention provides a kind of machine readable storage medium, which is characterized in that is stored thereon with program, the journey When sequence is executed by processor, the code conversion method provided such as first aspect present invention is realized.
Compared with the prior art, the embodiment of the present invention has the advantages that
In the embodiment of the present invention, the language format for meeting the keyword of specified requirements is converted to from first language format Two language formats can make to need the keyword of conversion to be converted to the keyword of required language format in object code, then by target generation Identify that keyword and corresponding related information are entire object codes with the related information of wherein keyword association in code Key message, thus sentence reconstruction is carried out according to keyword and corresponding related information, the object code after being converted, The language format conversion of object code is realized, so that the can also be used under the specified running environment for supporting second language One language carries out the programming of code, solves the problems, such as that programming mode is limited under specified running environment.
Detailed description of the invention
Fig. 1 is the flow diagram of the code conversion method of one embodiment of the invention;
Fig. 2 is the structural block diagram of the code conversion device of one embodiment of the invention;
Fig. 3 is the structural block diagram of the electronic equipment of one embodiment of the invention.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent all embodiments consistented with the present invention.On the contrary, they be only with it is such as appended The example of device and method being described in detail in claims, some aspects of the invention are consistent.
It is only to be not intended to limit the invention merely for for the purpose of describing particular embodiments in terminology used in the present invention. It is also intended in the present invention and the "an" of singular used in the attached claims, " described " and "the" including majority Form, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein refers to and wraps It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the present invention A little information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not departing from In the case where the scope of the invention, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as One information.Depending on context, word as used in this " if " can be construed to " ... when " or " when ... When " or " in response to determination ".
Code conversion method in the embodiment of the present invention can be applied to electronic equipment, and executing subject can be electronic equipment Processor.Electronic equipment for example can be computer equipment etc., specific unlimited.Can have code conversion on electronic equipment Required software and hardware, hardware for example may include for running the processor of program, for storing program, object code, table Deng memory and with execute the interface etc. that connect of equipment, be not limited thereto.
Code can be used in controller to realize control of the controller to executing agency, the problem of due to cost control, Under some scenes, the hardware resource of controller is less, for example, controller can use in the case where some robots control occasion Cortex-M3 processor cores, and since the resource of Cortex-M3 is smaller, in the control based on Cortex-M3 processor cores C language code can only be run on device, be unable to run the code that other language are write.
Currently, being directed to the feelings that above controller can only run C language code and be unable to run the code that other language are write There is no corresponding solution in condition, can only write corresponding language format for the language environment that controller can be run Code.
But programming language is so various now, and more and more people start to be programmed using Python, with For controller using Cortex-M3 processor cores, if the control to robot can only be realized by writing C language code System, programming mode is very limited, such as unskilled for C language Program Appliance or can be only programmed using Python For programmer, it can not just write to obtain required code.
Based on above-mentioned discovery, and the embodiment of the invention provides a kind of code conversion method, may be implemented the lattice of code Formula is converted into another language format from a kind of language format, in this way, being directed to above situation, can be write with Python Python code, then carry out the code conversion method of Python code to be through the embodiment of the present invention converted to C Language codes, it is not necessary to carry out writing for code with C language, write language certainly and be also not necessarily limited to Python.
The program debugging method of the embodiment of the present invention is more particularly described below, but should not be as limit.
In one embodiment, referring to Fig. 1, code conversion method be may comprise steps of:
S100: whether the character string in detection object code is the keyword for meeting specified requirements, if so, by the pass The language format of key word is converted to second language format from first language format;
S200: from being identified in the object code and the keyword association under second language format in the object code Related information;
S300: the related information that will identify that is recombinated with the keyword under corresponding second language format, to obtain Object code after conversion.
In embodiments of the present invention, object code for example can be the code write with Python, it is of course also possible to It is the code that other language are write, such as can also be the object-oriented languages such as C#.Object code by code conversion it Afterwards, what is obtained can be C language code, naturally it is also possible to be other language codes.That is first language format can be Python Language format, second language format can be C language format.
It can also include step S110 before step S100 in the code conversion method of the embodiment of the present invention: check mesh Whether the sentence marked in code is correct.
Specifically, the python tool that can run python language codes can be configured on an electronic device, e.g. PyCharm etc..It can use python tool and run the object code converted, if it exists mistake, then python work Tool can prompt corresponding mistake, so as to correct the statement error in object code, avoid the mistake that changes when code conversion Accidentally.The mistake that sentence in object code may occur for example, syntax error, character are misspelled, variable is undefined, first trip contracting Forward space formula is incorrect etc. unlimited.
Certainly python tool can be arranged in other equipment, after object code has been examined, object code is protected There are in local, corresponding object code is called from local when executing step S100.
The sentence in object code is being checked out, after guaranteeing that sentence is correct, can start to execute step S100.
In the step s 100, whether the character string detected in object code is the keyword for meeting specified requirements, if so, The language format of the keyword is converted into second language format from first language format.
In transcode process, for electronic equipment, can by entire object code as character string set into Row processing, thus, the character string in the embodiment of the present invention is not the data for being expression character string type in object code.Specifically , the object code of the embodiment of the present invention can define character string with space, line feed etc., i.e., by intercharacter in object code There is no these characters in space to be determined as a character string.The mode for specifically defining the character string in object code is unlimited.
Below with a specific code segment A come illustrate how determine object code in character string, certain code segment A's Function does not limit, and is only exemplary explanation, thus just it will not be described for the physical significance of the data such as variable therein.
Code segment A:
In code segment A, for for " for idx in range (0,6): ", " for ", " idx ", " in ", " range (0,6): " between there is space, thus be four character strings;Again by taking " if i > arr [idx]: " as an example for, " if " with " i > Arr [idx]: " between there are spaces, thus " if " is a character string, and " i > arr [idx]: " is a character string;Other classes Seemingly no longer it is described in detail.
Character string in object code can all be checked, to determine all in object code to meet specified requirements Keyword.The language format for meeting the keyword of specified requirements in object code is converted into the second language from first language format Say format.
Whether detection character string meets specified requirements in the step s 100, can exclude the following character string in object code One or more: the character string of non-keyword, the keyword of compatibility grammatically support first language but do not support the second language The unique identifier of speech grammatically supports first language but does not support the particular statement of second language.
Specifically, first language format is, for example, python language format, second language format is, for example, C language format, Because there is compatible keyword (such as " for ") in bilingual, because rather than each keyword require to convert.In step It detects whether character string meets specified requirements in S100, " for " in object code can be excluded, i.e., lattice are not carried out to " for " Formula conversion.
Keyword in the embodiment of the present invention may include in the identifier or programming language advanced in programming language The identifier and customized keyword advanced for.
Then execute step S200, from identified in the object code under second language format in the object code Keyword association related information.
Due to had already passed through in step S100 keyword language format convert, thus step S200 be directed to can be turn The object code obtained after changing.It is appreciated that the keyword in the object code under second language format, may include through step Keyword and unconverted and inherently under second language format pass under the second language format being converted in S100 Key word (keyword of i.e. compatible first language format and second language format).
After executing step S100, it is all second language that all keywords in object code, which are suitable for second language, Keyword under format.Thus in step S200, it can identify that each keyword corresponds to associated association from object code Information.The corresponding relationship between related information and keyword identified can be one-to-one, one-to-many, many-one, multi-to-multi. Multi-to-multi can refer to that multiple keywords can correspond to multiple related informations, but one of keyword is can not to determine wherein Related information.
Related information for example may include variable, variate-value, carry out sentence of assignment etc. to variable.According to keyword and Corresponding related information can determine corresponding code statement, and certainly, determining mode can be wanted according to the grammer of second language It asks and adaptively adjusts.
Then step S300, the related information that will identify that and the keyword under corresponding second language format are executed Recombination, with the object code after being converted.
The related information that will identify that recombinates to obtain second language sentence with the keyword under corresponding second language format, After related information in entire object code is recombinated with the keyword under corresponding second language format, after conversion being obtained Object code, i.e. second language object code.
It is appreciated that the related information that can be will identify that extracts, by the related information extracted and corresponding pass Key word is reassembled as sentence, in the sentence of recombination modification object code correspondence prototype statement, with the object code after being converted, Or object code can also be rebuild, with the sentence of recombination with the object code after being converted.
In the embodiment of the present invention, the language format for meeting the keyword of specified requirements is converted to from first language format Two language formats can make to need the keyword of conversion to be converted to the keyword of required language format in object code, then by target generation Identify that keyword and corresponding related information are entire object codes with the related information of wherein keyword association in code Key message, thus sentence reconstruction is carried out according to keyword and corresponding related information, the object code after being converted, The language format conversion of object code is realized, so that the can also be used under the specified running environment for supporting second language One language carries out the programming of code, solves the problems, such as that programming mode is limited under specified running environment.
In one embodiment, above method process can be executed by code conversion device 10, as shown in Fig. 2, code conversion Device 100 mainly includes 3 modules: keyword conversion module 100, related information identification module 200 and recombination module 300.It closes Key word conversion module 100 is used to execute above-mentioned steps S200 for executing above-mentioned steps S100, related information identification module 200, Recombination module 300 is for executing above-mentioned steps S300.
Preferably, the keyword for meeting specified requirements includes at least one below:
Logical identifier;
Annotation identifier;
Function declaration identifier;
Condition judges identifier.
It is appreciated that above-mentioned keyword is merely exemplary, it certainly can also include other contents.
In one embodiment, in step S100, whether the character string in the detection object code is to meet specified item The keyword of part, may comprise steps of:
S101: traversing the character string in the object code, searches the word traversed in the nominal key table of acquisition Symbol string;
S102: when finding the character string, judge in the nominal key table with the presence or absence of the character string pair Keyword under the second language format answered, and if it exists, then determine that the character string is the keyword for meeting specified requirements.
Object code is the set of character string, thus needs to judge all character strings, it is determined whether is to meet The keyword of specified requirements, and traversing is conveniently mode, it is certainly specific without being limited thereto.
In step s101, the character string in object code is traversed, the character string is searched in nominal key table.It can be with Understand, the character string in object code requires to traverse, and will be in designated key for the character string each traversed The character string is searched in word table, of course, it is possible to which often finding a character string in table then executes subsequent step S102 (certainly also May include other desired step, such as step S103), when subsequent step S102 execute complete when return again to step S101 after It is continuous to be traversed.
It can recorde all keywords different from second language of first language in nominal key table.First language Corresponding with first language format, second language is corresponding with second language format.Nominal key table can be stored in and be locally stored In device, called when needed by processor.
By taking object code is from python language conversion to C language as an example, python can recorde in nominal key table All keywords different from C language of language, and the keyword of python language format and C language format compatible (such as " for ", " else " etc.) be then the character string for not needing to be converted, maintain can be (under the subsequent format directly as C language Keyword), thus do not have to be recorded in nominal key table.
Specifically, " elif " can be found in nominal key table for example when traversing character string " elif " Character string illustrates that " elif " is keyword, but also needs to further determine whether to meet the keyword of specified requirements.
In step s 102, when finding character string, judge corresponding with the presence or absence of character string in nominal key table Keyword under second language format then determines that character string is the keyword for meeting specified requirements if it exists.
The mode of judgement, such as can be, from nominal key table, the content in the character string corresponding table item is read, Judge that the content in list item is key word type, if then determining that there are the passes under the corresponding second language format of character string Key word determines that character string is the keyword for meeting specified requirements.Judgment mode, it is also possible that each of nominal key table List item, which all records, has the mark content for recording content in mark list item to read corresponding mark content when finding character string It can determine with the presence or absence of the keyword under second language format in corresponding table item, so that it is determined that whether character string is to meet to specify The keyword of condition.
Such as when finding " elif " character string, corresponding mark content can determine whether, when mark content identification is list item When keyword under the middle format there are C language, it is determined that the character string is the keyword for meeting specified requirements, and correspondence can be read Keyword " else if ".
In one embodiment, in step S100, the language format by keyword is converted to from first language format Second language format, comprising:
The keyword for meeting specified requirements under first language format is replaced with from the nominal key table Keyword under the correspondence second language format of acquisition.
The character string is replaced with from the keyword under the correspondence second language format obtained in nominal key, but not right Other characters of sentence or character string are modified where character string.It will not be by first language format and second in object code The identical keyword of language format is modified.
In one embodiment, this method also can further include:
S103: the keyword under the corresponding second language format of the character string if it does not exist, then by the character string institute Sentence replace with the specified sentence under corresponding second language format.
That is, the corresponding contents in table of the character string is not second after finding character string in nominal key table Keyword under language format in this case, not doing the replacement of keyword, but the sentence where character string is replaced with together Specified sentence.
When the character string found is to support first language but do not support the keyword of second language, sentence example is specified The prompt of the keyword is not supported about output prompt in this way.When the character string found is the calling object class in first language When, specified sentence can be and custom function corresponding to the calling object class.Specifically and without limitation.
For specified sentence, specified sentence can be directly recorded at the corresponding position of character string of nominal key table, Also it can recorde the address that specified sentence is stored, corresponding memory space can be accessed by address and reads specified language accordingly Sentence, it is specific unlimited.
In one embodiment, the character string under the first language format recorded in nominal key table may include following At least one:
Logical identifier;
Annotation identifier;
Function declaration identifier;
Condition judges identifier;
It grammatically supports first language but does not support the unique identifier of second language;
It grammatically supports first language but does not support the particular statement of second language.
Logical identifier is (corresponding for example including " and " (corresponding contents in table is C language keyword " && "), " or " Contents in table is C language keyword " | | ") etc..For example including " # ", (corresponding contents in table is C language key to annotation identifier Word " // ").Function declaration identifier is for example including " def " (corresponding contents in table can be C language keyword " void ").Condition Judge identifier for example including " elif " (corresponding contents in table can be C language keyword " else if ").Grammatically support First language but do not support the unique identifier of second language for example including occupy row identifier (corresponding contents in table can be C The space character of language), single quotation marks (double quotation marks that corresponding contents in table can be C language).Grammatically support first language but The particular statement of second language is not supported (to can be replaced the customized letter prestored for example including the calling object class in first language Number).It is appreciated that above content is merely exemplary, it is not restricted to this.
In one embodiment, in step S200, from identified in the object code with second in the object code The related information of keyword association under language format, comprising:
For every line code string of the object code, search whether to deposit in related information table according to the code string In matched regular expression, and if it exists, then from being identified in the code string and keyword in the regular expression closes The related information of connection;
Wherein, the regular expression includes the key under at least one ambiguous characters and at least one second language format Word.
It is can recorde in related information table according to multiple canonical tables determined by the keyword under each second language format Up to formula (can determine a regular expression with a keyword, can also more than two keywords determine a regular expression, It is specific unlimited), fuzzy matching can be carried out, the keyword needed for only needing accurately matches, and the other contents such as variable do not have to accurate Matching.It can also record what instruction related information and keyword corresponding to regular expression recombinated in certain related information table Recombinate format.
Object code can be parsed (row that object code can be traversed) line by line, be believed according to every line code string in association It searches whether that there are matched regular expressions in breath table, i.e., fuzzy matching, in regular expression, the second language is carried out to code string Keyword under speech format is accurately matched as precise character, and ambiguous characters can then carry out fuzzy matching, obscure word Depending on the name of symbol can be according to needs.
Regular expression can be started with fixed format, be ended up with fixed format, and centre is specific matching symbol (accurate word Symbol, ambiguous characters).
Fuzzy matching is carried out to each line code string in object code by regular expression, so that a related information table The different sentences that are applicable in object code are equally applicable to different codes, also reduce the scale of construction of related information table, so that The treating capacity of matching process is smaller.
The related information identified is, for example, the character in the code string in addition to the keyword under second language format, when Certain adjustment can also be so carried out, it is specific unlimited.Due to including all the second of the code string in matched regular expression Keyword under language format, thus can related information directly be determined using the keyword in the regular expression.
Continue by taking above-mentioned code segment A as an example, for example traverses this line code string " for idx in range (0,6): " When, find matched regular expression be " ^ (|) { 0, } for (_ a-zA-Z0-9) { 1, } in (range)? ((0-9) { 1, }, () { 0, } (0-9) { 1, }) ", the matching symbol of the regular expression is once explained below:
^ (|) { 0 } is fixed beginning, indicates the space character or tab that can have 0 or more;
For is the keyword under second language format, is accurately matched;
(_ a-zA-Z0-9) indicate can only be the letter of underscore or a-z or the letter of A-Z or 0-9 number Word is unmatched if it is other characters (such as: &*);
(range)? expression can have this word of range, can also not have this word of range
For, in, range these three character strings related information for identification, the related information finally identified be idx, (0,6);
(0-9) { 1, } indicates can be with the number of at least one 0-9;() { 0, } indicates 0 or more space character;
$ indicates end mark.
It is appreciated that above-mentioned regular expression is only example, it can also be other forms certainly.
In one embodiment, in step S300, the related information that will identify that and corresponding second language Keyword recombination under format, comprising:
The related information that will identify that according to corresponding recombination format under corresponding second language format described in Keyword recombination, wherein the recombination format is according to the keyword under the second language format in keyword and recombination format Corresponding relationship in determine.
The corresponding relationship of the keyword and recombination format can be realized together by related information table, i.e., in related information table List item can recorde corresponding regular expression and recombination format.
Continue embodiment above-mentioned, the corresponding recombination format of regular expression can be determined in related information table, such as Recombinate format are as follows: for (%1=%2;%1 < %3;++ %1);Then by idx (0,6) and for keyword according to the recombination format It is recombinated, %1 is idx, and %2 is that 0, %3 is 6, and the sentence after recombination is for (idx=0;idx<6;++idx).
The list item of related information table for example can be such as following table (1):
Table (1)
Object code can be rebuild with the sentence after recombination, or with the sentence after recombination for the original in object code Code string, it is specific unlimited.
The present invention also provides a kind of code conversion devices, and in one embodiment, referring to Fig. 2, which includes:
Keyword conversion module 100, for detecting whether the character string in object code is the key for meeting specified requirements Word, if so, the language format of the keyword is converted to second language format from first language format;
Related information identification module 200, for from being identified in the object code and the second language in the object code Say the related information of the keyword association under format;
Recombination module 300, the related information for will identify that and the keyword under corresponding second language format Recombination, with the object code after being converted.
In one embodiment, the keyword conversion module 100 may include:
Traversal searching unit is looked into the nominal key table of acquisition for traversing the character string in the object code Look for the character string traversed;
Keyword judging unit, for when finding the character string, judging whether deposit in the nominal key table Keyword under the corresponding second language format of the character string, and if it exists, determine the character string then to meet specified item The keyword of part.
In one embodiment, the keyword conversion module 100, may also include that
Keyword replacement unit, for by the keyword for meeting specified requirements under first language format replace with from Keyword under the correspondence second language format obtained in the nominal key table.
In one embodiment, it in the keyword conversion module 100, may further comprise:
Specified sentence replacement unit, for the keyword under the corresponding second language format of the character string if it does not exist, Sentence where the character string is then replaced with to the specified sentence under corresponding second language format.
In one embodiment, the keyword for meeting specified requirements includes at least one below:
Logical identifier;
Annotation identifier;
Function declaration identifier;
Condition judges identifier.
In one embodiment, related information identification module 200, specifically can be used for:
For every line code string of the object code, search whether there is matching in lists according to the code string Regular expression, and if it exists, then from the pass identified in the code string with the keyword association in the regular expression Join information;
Wherein, the regular expression includes the key under at least one ambiguous characters and at least one second language format Word.
In one embodiment, the recombination module 300, is specifically used for:
The related information that will identify that according to corresponding recombination format under corresponding second language format described in Keyword recombination, wherein the recombination format is according to the keyword under the second language format in keyword and recombination format Corresponding relationship in determine.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus Realization process, details are not described herein.
For device embodiment, since it corresponds essentially to embodiment of the method, so related place is referring to method reality Apply the part explanation of example.The apparatus embodiments described above are merely exemplary, wherein described be used as separation unit The unit of explanation may or may not be physically separated, and component shown as a unit can be or can also be with It is not physical unit.
The embodiment of the present invention also provides a kind of electronic equipment, including processor and memory;The memory is stored with can The program called by processor;Wherein, when the processor executes described program, code as in the preceding embodiment is realized Conversion method.Memory can also be stored with object code, nominal key table, related information table etc..
The embodiment of present procedure debugging apparatus can be using on an electronic device.Taking software implementation as an example, as one Device on a logical meaning is by the processor of electronic equipment where it by computer corresponding in nonvolatile memory Program instruction is read into memory what operation was formed.For hardware view, Fig. 3 is that the present invention shows according to an exemplary embodiment A kind of hardware structure diagram of 10 place electronic equipment of code conversion device out, in addition to processor 510 shown in Fig. 3, memory 530, except interface 520 and nonvolatile memory 540, the electronic equipment in embodiment where device 10 is generally according to this The actual functional capability of electronic equipment can also include other hardware, repeat no more to this.
The embodiment of the present invention also provides a kind of machine readable storage medium, is stored thereon with program, and the program is by processor When execution, the code conversion method as described in any one of previous embodiment is realized.
It wherein includes storage medium (the including but not limited to disk of program code that the present invention, which can be used in one or more, Memory, CD-ROM, optical memory etc.) on the form of computer program product implemented.Machine readable storage medium includes Permanent and non-permanent, removable and non-removable media can be accomplished by any method or technique information storage.Information It can be computer readable instructions, data structure, the module of program or other data.The example of machine readable storage medium includes But be not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), its The random access memory (RAM) of his type, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), Flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM), digital versatile disc (DVD) or other Optical storage, magnetic cassette, tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium, can use It can be accessed by a computing device information in storage.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.

Claims (10)

1. a kind of code conversion method characterized by comprising
Whether the character string detected in object code is the keyword for meeting specified requirements, if so, by the language of the keyword Say that format is converted to second language format from first language format;
Letter is associated with the keyword association under second language format in the object code from identifying in the object code Breath;
The related information that will identify that is recombinated with the keyword under corresponding second language format, with the mesh after being converted Mark code.
2. code conversion method as described in claim 1, which is characterized in that whether the character string in the detection object code For the keyword for meeting specified requirements, comprising:
The character string in the object code is traversed, searches the character string traversed in the nominal key table of acquisition;
When finding the character string, judge in the nominal key table with the presence or absence of corresponding second language of the character string Say the keyword under format, and if it exists, then determine that the character string is the keyword for meeting specified requirements.
3. code conversion method as claimed in claim 2, which is characterized in that the language format by keyword is from the first language Speech format is converted to second language format, comprising:
The keyword for meeting specified requirements under first language format is replaced with and is obtained from the nominal key table Correspondence second language format under keyword.
4. code conversion method as claimed in claim 2, which is characterized in that this method may further comprise:
Keyword under the corresponding second language format of the character string if it does not exist, then replace the sentence where the character string The specified sentence being changed under corresponding second language format.
5. code conversion method as described in claim 1, which is characterized in that the keyword for meeting specified requirements include with Under at least one:
Logical identifier;
Annotation identifier;
Function declaration identifier;
Condition judges identifier.
6. code conversion method as described in claim 1, which is characterized in that identified from the object code and the mesh Mark the related information of the keyword association in code under second language format, comprising:
For every line code string of the object code, searched whether in related information table according to the code string exist The regular expression matched, and if it exists, then from being identified in the code string and the keyword association in the regular expression Related information;
Wherein, the regular expression includes the keyword under at least one ambiguous characters and at least one second language format.
7. code conversion method as described in claim 1, which is characterized in that the related information that will identify that with it is right Keyword recombination under the second language format answered, comprising:
The related information that will identify that is according to corresponding recombination format and the key under corresponding second language format Word recombination, wherein the recombination format is according to the keyword under the second language format in keyword and pair for recombinating format It should be related to middle determination.
8. a kind of code conversion device characterized by comprising
Keyword conversion module, for detecting whether the character string in object code is the keyword for meeting specified requirements, if so, The language format of the keyword is then converted into second language format from first language format;
Related information identification module, for from identified in the object code under second language format in the object code Keyword association related information;
Recombination module, the related information for will identify that are recombinated with the keyword under corresponding second language format, with Object code after being converted.
9. a kind of electronic equipment, which is characterized in that including processor and memory;The memory is stored with can be by processor tune Program;Wherein, when the processor executes described program, the code as described in any one of claim 1-7 is realized Conversion method.
10. a kind of machine readable storage medium, which is characterized in that it is stored thereon with program, it is real when which is executed by processor The now code conversion method as described in any one of claim 1-7.
CN201810904064.2A 2018-08-09 2018-08-09 A kind of code conversion method, device and equipment, storage medium Pending CN109271168A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810904064.2A CN109271168A (en) 2018-08-09 2018-08-09 A kind of code conversion method, device and equipment, storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810904064.2A CN109271168A (en) 2018-08-09 2018-08-09 A kind of code conversion method, device and equipment, storage medium

Publications (1)

Publication Number Publication Date
CN109271168A true CN109271168A (en) 2019-01-25

Family

ID=65153254

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810904064.2A Pending CN109271168A (en) 2018-08-09 2018-08-09 A kind of code conversion method, device and equipment, storage medium

Country Status (1)

Country Link
CN (1) CN109271168A (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110231955A (en) * 2019-05-13 2019-09-13 平安科技(深圳)有限公司 Code process method, apparatus, computer equipment and storage medium
CN110377291A (en) * 2019-06-19 2019-10-25 深圳壹账通智能科技有限公司 Structural data conversion method, device, computer equipment and storage medium
CN110597554A (en) * 2019-08-01 2019-12-20 浙江大学 Automatic generation optimization method for instruction function of instruction set simulator
CN110717032A (en) * 2019-08-26 2020-01-21 四川新网银行股份有限公司 Method for generating and displaying multi-system method call link diagram
CN111240681A (en) * 2019-12-30 2020-06-05 瑞庭网络技术(上海)有限公司 Method and device for converting different programming languages
CN112035710A (en) * 2020-07-28 2020-12-04 长沙市到家悠享网络科技有限公司 Code detection method, device, equipment and storage medium
CN113296827A (en) * 2021-03-31 2021-08-24 厦门科灿信息技术有限公司 Method and device for converting different languages and terminal equipment
CN113312057A (en) * 2021-06-17 2021-08-27 上海小熊星教育科技有限公司 Code processing method, programming assisting method, medium and electronic equipment
CN113391806A (en) * 2021-06-25 2021-09-14 北京光启元数字科技有限公司 Method, device, equipment and readable medium for converting color codes
CN113495731A (en) * 2020-03-19 2021-10-12 阿里巴巴集团控股有限公司 Code execution method and device, electronic equipment and storage medium
CN113608748A (en) * 2021-07-19 2021-11-05 上海浦东发展银行股份有限公司 Data processing method, device and equipment for converting C language into Java language
CN113760246A (en) * 2021-09-06 2021-12-07 网易(杭州)网络有限公司 Application program text language processing method and device, electronic equipment and storage medium
CN114047927A (en) * 2022-01-11 2022-02-15 山东捷瑞数字科技股份有限公司 Database code conversion method and system
CN114816412A (en) * 2022-05-25 2022-07-29 国汽智控(北京)科技有限公司 Algorithm compatibility method and device of automatic driving system
WO2024022432A1 (en) * 2022-07-28 2024-02-01 北京字跳网络技术有限公司 Information processing methods and apparatus, and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102929596A (en) * 2012-09-21 2013-02-13 华为技术有限公司 Code checking method and device
CN105867883A (en) * 2011-03-11 2016-08-17 英特尔公司 Dynamic core selection for heterogeneous multi-core systems
CN106293677A (en) * 2015-06-08 2017-01-04 阿里巴巴集团控股有限公司 A kind of code conversion method and device
CN107678749A (en) * 2017-09-29 2018-02-09 深圳市山龙智控有限公司 Code-transferring method and device based on structured language programming

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105867883A (en) * 2011-03-11 2016-08-17 英特尔公司 Dynamic core selection for heterogeneous multi-core systems
CN102929596A (en) * 2012-09-21 2013-02-13 华为技术有限公司 Code checking method and device
CN106293677A (en) * 2015-06-08 2017-01-04 阿里巴巴集团控股有限公司 A kind of code conversion method and device
CN107678749A (en) * 2017-09-29 2018-02-09 深圳市山龙智控有限公司 Code-transferring method and device based on structured language programming

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110231955B (en) * 2019-05-13 2024-05-07 平安科技(深圳)有限公司 Code processing method, device, computer equipment and storage medium
CN110231955A (en) * 2019-05-13 2019-09-13 平安科技(深圳)有限公司 Code process method, apparatus, computer equipment and storage medium
CN110377291A (en) * 2019-06-19 2019-10-25 深圳壹账通智能科技有限公司 Structural data conversion method, device, computer equipment and storage medium
CN110597554A (en) * 2019-08-01 2019-12-20 浙江大学 Automatic generation optimization method for instruction function of instruction set simulator
CN110717032A (en) * 2019-08-26 2020-01-21 四川新网银行股份有限公司 Method for generating and displaying multi-system method call link diagram
CN111240681B (en) * 2019-12-30 2023-08-15 瑞庭网络技术(上海)有限公司 Conversion method and device for different programming languages
CN111240681A (en) * 2019-12-30 2020-06-05 瑞庭网络技术(上海)有限公司 Method and device for converting different programming languages
CN113495731A (en) * 2020-03-19 2021-10-12 阿里巴巴集团控股有限公司 Code execution method and device, electronic equipment and storage medium
CN112035710A (en) * 2020-07-28 2020-12-04 长沙市到家悠享网络科技有限公司 Code detection method, device, equipment and storage medium
CN113296827A (en) * 2021-03-31 2021-08-24 厦门科灿信息技术有限公司 Method and device for converting different languages and terminal equipment
CN113312057A (en) * 2021-06-17 2021-08-27 上海小熊星教育科技有限公司 Code processing method, programming assisting method, medium and electronic equipment
CN113312057B (en) * 2021-06-17 2023-10-03 上海小熊星教育科技有限公司 Code processing method, programming auxiliary method, medium and electronic equipment
CN113391806A (en) * 2021-06-25 2021-09-14 北京光启元数字科技有限公司 Method, device, equipment and readable medium for converting color codes
CN113608748A (en) * 2021-07-19 2021-11-05 上海浦东发展银行股份有限公司 Data processing method, device and equipment for converting C language into Java language
CN113608748B (en) * 2021-07-19 2024-04-30 上海浦东发展银行股份有限公司 Data processing method, device and equipment for converting C language into Java language
CN113760246B (en) * 2021-09-06 2023-08-11 网易(杭州)网络有限公司 Application text language processing method and device, electronic equipment and storage medium
CN113760246A (en) * 2021-09-06 2021-12-07 网易(杭州)网络有限公司 Application program text language processing method and device, electronic equipment and storage medium
CN114047927B (en) * 2022-01-11 2022-04-29 山东捷瑞数字科技股份有限公司 Database code conversion method and system
CN114047927A (en) * 2022-01-11 2022-02-15 山东捷瑞数字科技股份有限公司 Database code conversion method and system
CN114816412A (en) * 2022-05-25 2022-07-29 国汽智控(北京)科技有限公司 Algorithm compatibility method and device of automatic driving system
WO2024022432A1 (en) * 2022-07-28 2024-02-01 北京字跳网络技术有限公司 Information processing methods and apparatus, and electronic device

Similar Documents

Publication Publication Date Title
CN109271168A (en) A kind of code conversion method, device and equipment, storage medium
US9251143B2 (en) Converting data into natural language form
US8412653B2 (en) Knowledge extraction and transformation
US7165216B2 (en) Systems and methods for converting legacy and proprietary documents into extended mark-up language format
KR101129083B1 (en) Expression grouping and evaluation
CN102713834B (en) Management accounts format information
CN106886509A (en) A kind of academic dissertation form automatic testing method
KR101110988B1 (en) Device for structured data transformation
US20130332905A1 (en) Test code generation based on test documentation
JP4365162B2 (en) Apparatus and method for retrieving structured document data
US7933763B2 (en) Method and software for extracting chemical data
US20170286103A1 (en) Identifying and correlating semantic bias for code evaluation
JP2006178944A (en) File format representing document, its method and computer program product
CN116627429B (en) Assembly code generation method and device, electronic equipment and storage medium
CN106970903B (en) Method and device for processing address information in logistics system
CN117289905B (en) Application software development method and device, storage medium and electronic equipment
CN111813416B (en) File packing method, device and equipment and storage medium
KR100501936B1 (en) System and method for source code checking
CN112463896A (en) Archive cataloging data processing method and device, computing equipment and storage medium
JPH06131232A (en) Multiple definition correction assisting device for data dictionary
JP2007501464A (en) Method and system for probability-based verification of XML documents
Rush Decentralized, Off-Chain, per-Block Accounting, Monitoring, and Reconciliation for Blockchains
CN118113301B (en) Program code checking method and system for numerical weather forecast mode program
CN117077148B (en) Program security analysis method, system, computer device and storage medium
León et al. Inconsistency detection on data communication standards using information extraction techniques: The ABP case

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190125