CN108182069A - Programming language transformation method, terminal device and computer-readable medium - Google Patents

Programming language transformation method, terminal device and computer-readable medium Download PDF

Info

Publication number
CN108182069A
CN108182069A CN201711466295.1A CN201711466295A CN108182069A CN 108182069 A CN108182069 A CN 108182069A CN 201711466295 A CN201711466295 A CN 201711466295A CN 108182069 A CN108182069 A CN 108182069A
Authority
CN
China
Prior art keywords
parameter
target
source
mentioned
text information
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.)
Granted
Application number
CN201711466295.1A
Other languages
Chinese (zh)
Other versions
CN108182069B (en
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.)
SHENZHEN IDREAMSKY TECHNOLOGY Co.,Ltd.
Original Assignee
Shenzhen Dream World Polytron Technologies Inc
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 Shenzhen Dream World Polytron Technologies Inc filed Critical Shenzhen Dream World Polytron Technologies Inc
Priority to CN201711466295.1A priority Critical patent/CN108182069B/en
Publication of CN108182069A publication Critical patent/CN108182069A/en
Application granted granted Critical
Publication of CN108182069B publication Critical patent/CN108182069B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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 embodiment of the invention discloses a kind of language transfer method, terminal device and computer memory device, this method includes:Parameter is configured in acquisition source, and the source file path parameter being configured according to above-mentioned source in parameter obtains source text information.According to source be configured parameter determine source text information being converted to target text information needed for target parameter is configured.Parameter is configured according to above-mentioned target source text information is parsed to obtain the corresponding target abstract syntax tree of source text information.Parameter and above-mentioned target abstract syntax tree is configured in above-mentioned target, class generation language form converting objects is generated by preset grammer.Class is generated according to above-mentioned grammer and above-mentioned target abstract syntax tree is converted into above-mentioned target text information by above-mentioned language form converting objects.The application development time can be saved using the embodiment of the present invention, improve the efficiency of application development.

Description

Programming language transformation method, terminal device and computer-readable medium
Technical field
The present invention relates to a kind of field of computer technology more particularly to programming language transformation method, terminal device and calculating Machine readable medium.
Background technology
With the continuous development of science and technology, in current end application development process, agile development into For common recognition in the industry, it is short that above-mentioned agile development refers to the development cycle.Therefore, this also leads to the requirement for program development language Increasingly tend to simple grammer, using flexible and developer is facilitated quickly to realize programmed logic.
In the prior art, such as during game application is developed, different program languages is often used simultaneously. For example, based on Unity3D engines exploitation game application when, need using C# language come carry out more bottom, change it is less Function code write, it is also desirable to be modified writing for frequent game logic using Lua language.But make simultaneously With different program languages, need repeatedly to be switched between different language, can thus improve application development cost, Reduce the efficiency of application development.
Invention content
An embodiment of the present invention provides a kind of programming language transformation method, terminal device and computer storage medias.It can be real Existing different type becomes the conversion between language, can save the application development time, improve the efficiency of application development.
First aspect provides a kind of programming language transformation method, including:
Parameter is configured in acquisition source, and the source file path parameter being configured in parameter according to above-mentioned source obtains source text information, The program language type of above-mentioned source text information is first language type;
According to above-mentioned source be configured parameter determine above-mentioned source text information being converted to target text information needed for target Parameter is configured, the program language type of above-mentioned file destination information is second language type;
Parameter is configured according to above-mentioned target above-mentioned source text information is parsed to obtain above-mentioned source text information correspondence Target abstract syntax tree;
Parameter and above-mentioned target abstract syntax tree is configured in above-mentioned target, class generation class of languages is generated by preset grammer Type converting objects;
Class is generated according to above-mentioned grammer and above-mentioned target abstract syntax tree is converted by above-mentioned language form converting objects State target text information.
It is above-mentioned to pass through above-mentioned target configuration parameter and above-mentioned target abstract syntax tree in some feasible embodiments Preset grammer generation class generation language form converting objects includes:
Parameter is configured according to above-mentioned target and above-mentioned target abstract syntax tree instantiates preset grammer generation class, to obtain Grammer generates object;
The corresponding semantic model of the above-mentioned target abstract syntax tree of object acquisition is generated, and according to upper predicate by above-mentioned grammer Adopted model and the conversion class generative grammar node converting objects of preset syntactic node;
The root node of the above-mentioned target abstract syntax tree of object acquisition is generated according to above-mentioned grammer, and above-mentioned target is abstracted language The root node of method tree is converted into the object of the first kind;
Tree is abstracted with above-mentioned target grammer according to the object of the above-mentioned first kind and above-mentioned syntactic node converting objects generation Associated language form converting objects.
In some feasible embodiments, above-mentioned target abstract syntax tree includes M syntactic node, above-mentioned according to above-mentioned Grammer generates class and above-mentioned target abstract syntax tree is converted into target text information and included by above-mentioned language form converting objects:
Class generation write-in object is generated by above-mentioned grammer according to above-mentioned source file address parameter, wherein, above-mentioned write-in pair As being used for being written into pre-set text by the transformed code of program language type according to default write-in rule;
According to above-mentioned language form converting objects and above-mentioned write-in object to any syntactic node in above-mentioned M syntactic node J carries out following operate:
Call preset in the above-mentioned language form converting objects and associated language form transformation rules of above-mentioned syntactic node j Above-mentioned syntactic node j is converted into target subcode, wherein, the program language type of above-mentioned target subcode is above-mentioned second language Say type;
Above-mentioned target subcode is written to by preset target text by above-mentioned write-in object according to default write-in rule In, to update above-mentioned target text;
Target text information is obtained according to newer target text is completed.
In some feasible embodiments, above-mentioned source configuration parameter includes N number of source parameter, above-mentioned to be configured according to above-mentioned source The target configuration parameter that parameter is determined to be converted to above-mentioned source text information needed for target text information includes:
Following handle is carried out to any source parameter i in above-mentioned N number of source parameter:
The value of above-mentioned source parameter i is obtained, and the value of above-mentioned source parameter i is passed into default parameter and handles class;
In above-mentioned default parameter processing class with the associated processing functions of above-mentioned source parameter i and above-mentioned source parameter i Value generation target parameter;
According to needed for the handling result of above-mentioned N number of source parameter obtains above-mentioned source text information being converted to target text information Target configuration parameter.
In some feasible embodiments, before parameter is configured in above-mentioned acquisition, the above method further includes:
Judge whether to receive source configuration parameter;
If being judged as NO, configuration parameter input prompting is shown in the user interface.
In some feasible embodiments, above-mentioned first language type be C#, above-mentioned second language type include Lua or JavaScript。
Second aspect provides a kind of programming language transformation terminal device, including:
Acquiring unit for obtaining source configuration parameter, and is obtained according to the source file path parameter that above-mentioned source is configured in parameter Source text information is taken, the program language type of above-mentioned source text information is first language type;
Parameter processing unit is configured, the above-mentioned source configuration parameter for being obtained according to above-mentioned acquiring unit is determined will be above-mentioned Source text information is converted to the target configuration parameter needed for target text information, the program language type of above-mentioned file destination information For second language type;
Syntax tree generation unit, for the target configuration parameter that is obtained according to above-mentioned configuration parameter processing unit to above-mentioned the The above-mentioned source text information that two acquiring units obtain is parsed to obtain the corresponding target abstract syntax of above-mentioned source text information Tree;
Converting objects generation unit, for the target configuration parameter for obtaining above-mentioned configuration parameter processing unit and upper predicate The target abstract syntax tree of method tree generation unit generation generates class by preset grammer and generates language form converting objects;
Converting unit, for generating the above-mentioned class of languages that class and above-mentioned converting objects generation unit generate according to above-mentioned grammer Above-mentioned target abstract syntax tree is converted into above-mentioned target text information by type converting objects.
In some feasible embodiments, above-mentioned converting objects processing unit is used for:
The above-mentioned target configuration parameter obtained according to above-mentioned configuration parameter processing unit and the life of above-mentioned syntax tree generation unit Into target abstract syntax tree instantiate preset grammer generation class, to obtain grammer generation object;
The corresponding semantic model of the above-mentioned target abstract syntax tree of object acquisition is generated, and according to upper predicate by above-mentioned grammer Adopted model and the conversion class generative grammar node converting objects of preset syntactic node;
The root node of the above-mentioned target abstract syntax tree of object acquisition is generated according to above-mentioned grammer, and above-mentioned target is abstracted language The root node of method tree is converted into the object of the first kind;
Tree is abstracted with above-mentioned target grammer according to the object of the above-mentioned first kind and above-mentioned syntactic node converting objects generation Associated language form converting objects.
In some feasible embodiments, above-mentioned source configuration parameter includes N number of source parameter, and above-mentioned configuration parameter processing is single Member is used for:
Following handle is carried out to any source parameter i in above-mentioned N number of source parameter:
The value of above-mentioned source parameter i is obtained, and the value of above-mentioned source parameter i is passed into default parameter and handles class;
In above-mentioned default parameter processing class with the associated processing functions of above-mentioned source parameter i and above-mentioned source parameter i Value generation target parameter;
According to needed for the handling result of above-mentioned N number of source parameter obtains above-mentioned source text information being converted to target text information Target configuration parameter.
In some feasible embodiments, the target abstract syntax tree that above-mentioned syntax tree generation unit obtains includes M The above-mentioned converting unit of syntactic node is used for:
Class generation write-in object is generated by above-mentioned grammer according to the source file address parameter that above-mentioned acquiring unit obtains, In, above-mentioned write-in object is used for according to the regular write-in into target text of default write-in by the transformed code of language form;
According to above-mentioned language form converting objects and above-mentioned write-in object to any syntactic node in above-mentioned M syntactic node J carries out following operate:
Call preset in the above-mentioned language form converting objects and associated language form transformation rules of above-mentioned syntactic node j Above-mentioned syntactic node j is converted into target subcode, wherein, the program language type of above-mentioned target subcode is above-mentioned second language Say type;
Above-mentioned target subcode is written to by preset target text by above-mentioned write-in object according to default write-in rule In, to update above-mentioned target text;
Target text information is obtained according to newer target text is completed.
In some feasible embodiments, above-mentioned acquiring unit is additionally operable to judge that ginseng is configured in the above-mentioned source that whether receives Amount.If being judged as NO, configuration parameter input prompting is shown in the user interface.
The third aspect, an embodiment of the present invention provides another terminal devices, are set including processor, input equipment, output Standby and memory, above-mentioned processor, input equipment, output equipment and memory are connected with each other, wherein, above-mentioned memory is used to deposit Storage supports terminal device to perform the computer program of the above method, and above computer program includes program instruction, above-mentioned processor It is configured for calling above procedure instruction, the method for performing above-mentioned first aspect.
Fourth aspect, an embodiment of the present invention provides a kind of computer readable storage medium, above computer storage mediums Computer program is stored with, above computer program includes program instruction, and above procedure instruction makes when being executed by a processor State the method that processor performs above-mentioned first aspect.
5th aspect, the embodiment of the present application provide a kind of computer program, and the computer program includes program instruction, Described program instruction makes the processor perform the described programming language transformation method of first aspect when being executed by a processor.
The embodiment of the present invention first obtains source configuration parameter, is obtained according to the source file path parameter that above-mentioned source is configured in parameter Take source text information.According to source be configured parameter determine above-mentioned source text information being converted to target text information needed for target Parameter is configured.Source text information is parsed to obtain the corresponding target of source text information further according to above-mentioned target configuration parameter Abstract syntax tree.Parameter and above-mentioned target abstract syntax tree is configured in above-mentioned target, class generation language is generated by preset grammer Type converting objects.Class and above-mentioned language form converting objects are finally generated by above-mentioned target abstract syntax tree according to above-mentioned grammer It is converted into above-mentioned target text information.The application development time can be saved using the embodiment of the present invention, application program is improved and open The efficiency of hair.
Description of the drawings
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment Attached drawing is briefly described, it should be apparent that, the accompanying drawings in the following description is only some embodiments of the present invention, for For those of ordinary skill in the art, without creative efforts, other are can also be obtained according to these attached drawings Attached drawing.
Fig. 1 is a kind of programming language transformation method first embodiment flow diagram provided in an embodiment of the present invention;
Fig. 2 is a kind of programming language transformation method second embodiment flow diagram provided in an embodiment of the present invention;
Fig. 3 is a kind of structure diagram of programming language transformation terminal device provided in an embodiment of the present invention;
Fig. 4 is a kind of another structure diagram of programming language transformation terminal device provided in an embodiment of the present invention
Fig. 5 is a kind of structure diagram for programming language transformation terminal device that another embodiment of the present invention provides.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete Site preparation describes, it is clear that described embodiment is part of the embodiment of the present invention, instead of all the embodiments.Based on this hair Embodiment in bright, the every other implementation that those of ordinary skill in the art are obtained without making creative work Example, shall fall within the protection scope of the present invention.
It should be appreciated that ought use in this specification and in the appended claims, term " comprising " and "comprising" instruction Described feature, entirety, step, operation, the presence of element and/or component, but one or more of the other feature, whole is not precluded Body, step, operation, element, component and/or its presence or addition gathered.
It is also understood that the term used in this description of the invention is merely for the sake of the mesh for describing specific embodiment And be not intended to limit the present invention.As description of the invention and it is used in the attached claims, unless on Other situations are hereafter clearly indicated, otherwise " one " of singulative, "one" and "the" are intended to include plural form.
It will be further appreciated that the term "and/or" used in description of the invention and the appended claims is Refer to any combinations and all possible combinations of one or more of the associated item listed, and including these combinations.
As used in this specification and in the appended claims, term " if " can be according to context quilt Be construed to " when ... " or " once " or " in response to determining " or " in response to detecting ".Similarly, phrase " if it is determined that " or " if detecting [described condition or event] " can be interpreted to mean according to context " once it is determined that " or " in response to true It is fixed " or " once detecting [described condition or event] " or " in response to detecting [described condition or event] ".
In the specific implementation, the terminal device described in the embodiment of the present invention is including but not limited to such as with the sensitive table of touch Mobile phone, laptop computer or the tablet computer in face (for example, touch-screen display and/or touch tablet) etc it is other Portable device.It is to be further understood that in certain embodiments, the equipment is not portable communication device, but is had The desktop computer of touch sensitive surface (for example, touch-screen display and/or touch tablet).
In discussion below, the terminal device including display and touch sensitive surface is described.However, it should manage Solution, one or more of the other physical User that terminal device can include such as physical keyboard, mouse and/or control-rod connect Jaws equipment.
Terminal device supports various application programs, such as one or more of following:Drawing application program, demonstration application Program, word-processing application, website create application program, disk imprinting application program, spreadsheet applications, play and answer With program, telephony application, videoconference application, email application, instant messaging applications, forging Refining supports application program, photo management application program, digital camera application program, digital camera application program, web-browsing should With program, digital music player application and/or video frequency player application program.
The various application programs that can be performed on the terminal device can use at least one of such as touch sensitive surface Public physical user-interface device.It can be adjusted among applications and/or in corresponding application programs and/or change touch is quick Feel the corresponding information shown in the one or more functions and terminal device on surface.In this way, the public physics frame of terminal device Structure (for example, touch sensitive surface) can be supported various using journey with user interface intuitive and transparent for a user Sequence.
Fig. 1 is referred to, is that a kind of first embodiment flow of programming language transformation method provided in an embodiment of the present invention is shown It is intended to.Hereafter it is described by executive agent of terminal device.Programming language transformation method may include step as described in Figure:
S101 obtains source configuration parameter, and the source file path parameter being configured in parameter according to above-mentioned source obtains source text Information.
In some feasible embodiments, terminal device can detect user operation instruction input by user, then parse Above-mentioned user operation instruction, to obtain above-mentioned source configuration parameter.Terminal device can also be directly acquired directly from its memory space Parameter is configured in preset source.Wherein, above-mentioned source configuration parameter may include:Source file path parameter, file destination path parameter, side Supplementary information shows parameter etc., does not limit herein.For example, terminal device obtain programming language transformation instruction after, can be direct Parameter acquisition approach is configured according to preset source and determines address of the source configuration parameter in memory headroom, and carry according to the address Take out above-mentioned source configuration parameter.
In some feasible embodiments, terminal device can match after above-mentioned source configuration parameter is got from above-mentioned source It puts and source file path parameter is extracted in parameter.Then source document is extracted from memory space according to above-mentioned source file path parameter Part.Finally, terminal device can extract out all text messages in above-mentioned source file, and be determined as above-mentioned source text information.Its In, above-mentioned source file is the document of code of having program recorded thereon.The above-mentioned source text information of all program codes in above-mentioned source text. The language form that becomes of above-mentioned source text information is above-mentioned first language type.For example, one is preserved 1000 byte C# The document of language codes is exactly a source file.And the C# codes of above-mentioned 1000 bytes are above-mentioned source text information.It is above-mentioned C# language type is first language type.
S102 is configured parameter according to above-mentioned source and determines the source text information of first language type being converted into second language Target configuration parameter needed for the target text information of type.
In some feasible embodiments, terminal device can be configured according to above-mentioned source and join after source text information is obtained Amount is determined for the source text information of first language type to be converted into the target needed for the target text information of second language type Parameter is configured.Wherein, above-mentioned source configuration parameter includes N number of source parameter.Specifically, terminal device is carried from above-mentioned N number of source parameter A source parameter i is taken out, is then determined at default parameter associated with source parameter i according to the parameter name of above-mentioned source parameter i Manage function.Then the parameter value for handling the above-mentioned source parameter i of function pair according to default parameter is handled, to obtain target parameter.
S103 parses above-mentioned source text information to obtain the corresponding target abstract syntax of above-mentioned source text information Tree.
In some feasible embodiments, terminal device is needed after above-mentioned source text information is obtained by above-mentioned source Text message is parsed, with obtain above-mentioned source text information (for convenience of understand, hereafter with source code replace source text information into Row description) corresponding to abstract syntax tree.Wherein, above-mentioned syntax tree (abstractsyntax code, AST) is above-mentioned source document The tree-shaped expression of the abstract syntax structure of all program codes in this.Specifically, terminal device is getting above-mentioned source code Afterwards, the code analysis specified structure can be called to parse above-mentioned source code, to obtain the target corresponding to above-mentioned source code Abstract syntax tree.For example, the code analysis that terminal device can call Roslyn to provide parses above-mentioned source code, to obtain target pumping As syntax tree.
Above-mentioned target is configured parameter and above-mentioned target abstract syntax tree and generates class generation language by preset grammer by S104 Say type converting objects.
In some feasible embodiments, terminal device is after above-mentioned target configuration parameter is got, by above-mentioned target Parameter and above-mentioned target abstract syntax tree is configured, class generation language form converting objects is generated by preset grammer.Specifically, Parameter first is configured according to above-mentioned target for terminal device and above-mentioned target abstract syntax tree instantiates preset grammer and generates class, with Object is generated to grammer.Then, terminal device is corresponding by the above-mentioned grammer generation above-mentioned target abstract syntax tree of object acquisition Semantic model, and class generative grammar node converting objects is converted according to above-mentioned semantic model and preset syntactic node.Then, eventually End equipment generates the root node of the above-mentioned target abstract syntax tree of object acquisition according to above-mentioned grammer, and by above-mentioned target abstract syntax The root node of tree is converted into the object of the first kind.Wherein, the object of the above-mentioned first kind can be in Microsoft's code analysis library The object of CompilationUnitSyntax types.Finally, the object and upper predicate that terminal device can be according to the above-mentioned first kind The converting objects of method node is generated is abstracted the associated language form converting objects of tree with above-mentioned target grammer.Wherein, above-mentioned class of languages The target text information for acting as being converted to the source text information of first language type second language type of type converting objects.
S105 generates class according to the grammer and the target abstract syntax tree is converted in the language form converting objects Into the target text information.
In some feasible embodiments, terminal device, can first root after above-mentioned language form converting objects is got Class generation write-in object is generated by the grammer according to the source file address parameter.Wherein, said write object is used for basis The transformed code of language form is passed through in default write-in rule write-in into target text.Then, terminal device can be according to default Sequence language form conversion is carried out to each syntactic node in above-mentioned target abstract syntax tree, to obtain and each syntactic node Corresponding target subcode.Wherein, the program language type of above-mentioned target subcode is above-mentioned second language type.Example Such as, second language type can be Lua language.Then, the object code that terminal device will be converted to by above-mentioned write-in object It is written in preset text.After above-mentioned conversion operation and write operation are fully completed, final acquired pre-set text is For target text.All text messages in above-mentioned target text are target text information.
The embodiment of the present invention first obtains source configuration parameter, source file path parameter is included at least in source configuration parameter.Root Source text information is obtained according to above-mentioned source file path parameter.Source text information is parsed again to obtain source text information correspondence Target abstract syntax tree.Parameter is configured according to source to determine the source text information of first language type being converted to second language Target configuration parameter needed for the target text information of type.Parameter is configured in above-mentioned target and above-mentioned target abstract syntax tree leads to Cross preset grammer generation class generation language form converting objects.Class is finally generated according to above-mentioned grammer and above-mentioned language form turns It changes object and above-mentioned target abstract syntax tree is converted into above-mentioned target text information.It can be saved using journey using the embodiment of the present invention The sequence development time improves the efficiency of application development.
Fig. 2 is referred to, is that a kind of second embodiment flow of programming language transformation method provided in an embodiment of the present invention is shown It is intended to.Hereafter it is described by executive agent of terminal device.Programming language transformation method may include step as described in Figure:
S201 is detected and is parsed user operation instruction input by user.
Whether S202 judges above-mentioned user operation instruction comprising source configuration parameter acquisition instruction.
In some feasible embodiments, terminal device, can before parameter is configured according to source and obtains source text information User operation instruction is obtained by detecting user to the click of arbitrary region in the user interface of terminal device, is set according to terminal Whether what standby preset instruction set judged to receive includes whether corresponding terminal function is source configuration parameter to user operation instruction The instruction of acquisition.If being judged as YES, step S204 is performed.If it is judged as NO.Then perform step S203.
S203 shows configuration parameter input prompting in the user interface, and judges whether to receive source configuration parameter again.
It, can be if terminal device does not detect that parameter acquisition instruction is configured in source in some feasible embodiments Configuration parameter input solicited message is shown in above-mentioned user interface, to ask in user's input such as operational order.Optionally, terminal Equipment can also show configuration parameter input help information in above-mentioned user interface, so that user can encounter according to its own Problem inputs in help information from above-mentioned configuration parameter and finds corresponding solution.
S204 obtains source configuration parameter, and the source file path parameter being configured in parameter according to above-mentioned source obtains source text Information.
It, can be according to above-mentioned after terminal device gets source configuration parameter acquisition instruction in some feasible embodiments Source configuration parameter acquisition instruction directly directly acquires preset source configuration parameter from its memory space.Wherein, above-mentioned source configuration Parameter may include:Source file path parameter, file destination path parameter, help information show parameter etc., do not limit herein.Example Such as, terminal device obtain it is above-mentioned parameter acquisition instruction is configured with source after, can parse above-mentioned source configuration parameter acquisition instruction with Source configuration parameter acquisition approach is obtained, parameter acquisition approach then, which is configured, according to above-mentioned source determines that source configuration parameter is set in terminal Address in standby memory space, and root extracts preset source configuration parameter out of change of address corresponding storage region.It is optional , ginseng is configured in the source that mobile terminal can be also directly acquired by parsing above-mentioned source configuration parameter acquisition instruction corresponding to the instruction Amount.
In some feasible embodiments, terminal device can match after above-mentioned source configuration parameter is got from above-mentioned source It puts and source file path parameter is extracted in parameter.Then source document is extracted from memory space according to above-mentioned source file path parameter Part.Finally, terminal device can extract out all text messages in above-mentioned source file, and be determined as above-mentioned source text information.Its In, above-mentioned source file is the document of code of having program recorded thereon.The above-mentioned source text information of all program codes in above-mentioned source text. The language form that becomes of above-mentioned source text information is above-mentioned first language type.Optionally, above-mentioned first language type is C#. For example, a document for preserving 1000 byte C# language codes is exactly a source file.And the C# of above-mentioned 1000 bytes Code is above-mentioned source text information.Above-mentioned C# language type is first language type.
S205 is configured according to above-mentioned source needed for parameter determines above-mentioned source text information being converted to target text information Parameter is configured in target.
In some feasible embodiments, terminal device can be configured according to above-mentioned source and join after source text information is obtained Amount is determined for the source text information of first language type to be converted into the target needed for the target text information of second language type Parameter is configured.Wherein, above-mentioned source configuration parameter includes N number of source parameter.Specifically, terminal device is carried from above-mentioned N number of source parameter A source parameter i is taken out, is then determined at default parameter associated with source parameter i according to the parameter name of above-mentioned source parameter i Manage function.Then the parameter value for handling the above-mentioned source parameter i of function pair according to default parameter is handled, to obtain target parameter. For example, above-mentioned source configuration parameter includes source file path parameter A.Terminal device extracts above-mentioned source file path parameter, so Default parameter associated with A is obtained according to the parameter name A for obtaining above-mentioned source path parameter afterwards and handles function.Wherein, in execution State default parameter processing function, container enumerated to obtain a syntax tree, and using the syntax tree enumerate container as with above-mentioned source The corresponding target parameters of file path parameter A.Aforesaid operations are repeated, until the source parameter handled is converted into After corresponding target parameter, all target parameters are subjected to integration processing, to obtain target configuration parameter.
S206 parses above-mentioned source text information to obtain the corresponding target abstract syntax of above-mentioned source text information Tree.
In some feasible embodiments, terminal device is needed after above-mentioned source text information is obtained by above-mentioned source Text message is parsed, with obtain above-mentioned source text information (for convenience of understand, hereafter with source code replace source text information into Row description) corresponding to abstract syntax tree.Wherein, above-mentioned syntax tree (abstractsyntax code, AST) is above-mentioned source document The tree-shaped expression of the abstract syntax structure of all program codes in this, one in each node representation program code on tree Kind structure.Why say and be abstracted, be because abstract syntax tree can't represent each details that true grammer occurs, example Such as, the nested parenthesis in program code can be implied in the structure of tree, can't be presented in the form of node.Specifically, eventually End equipment can extract out the syntax tree solution included in target configuration parameter after above-mentioned source code and target configuration parameter is got Analyse parameter.Then parameter is parsed according to syntax tree the code analysis specified structure to be called to parse above-mentioned source code, with Obtain the target abstract syntax tree corresponding to above-mentioned source code.For example, terminal device can call the code analysis function of Microsoft CSharpConmandLine.Default.Parse to above-mentioned syntax tree parsing parameter parse, with obtain one with it is above-mentioned Syntax tree parses the corresponding parsing class object of parameter.Using above-mentioned mechanical object as library function CSharpSyntaxTree.ParserText parameter input, by library function CSharpSyntaxTree.ParserText come Above-mentioned source text information is parsed, to obtain the target abstract syntax tree corresponding to above-mentioned source text information.
Above-mentioned target is configured parameter and above-mentioned target abstract syntax tree and generates class generation language by preset grammer by S207 Say type converting objects.
In some feasible embodiments, terminal device is after above-mentioned target abstract syntax tree is got, by above-mentioned mesh Standard configuration puts parameter and above-mentioned target abstract syntax tree and generates class generation language form converting objects by preset grammer.Specifically , parameter first is configured according to above-mentioned target for terminal device and above-mentioned target abstract syntax tree instantiates preset grammer and generates class, To obtain grammer generation object.Then, the adjustable generating function generated in object with predicate method of terminal device is associated with above-mentioned Target abstract syntax tree.Terminal device can call preset code analysis semantic model to obtain above-mentioned target abstract syntax tree and correspond to Semantic model.For example, terminal device can the corresponding preset Microsoft's code analysis semantic model of invocation target abstract syntax tree Microsoft.CodeAnalysis.SemanticModel obtains the semantic model of above-mentioned target abstract syntax tree.And according to Above-mentioned semantic model and the conversion class generative grammar node converting objects of preset syntactic node.Then, terminal device is adjustable uses The root node included in predicate method generation object obtains function to obtain the root node of above-mentioned target abstract syntax tree, and will be above-mentioned The root node of target abstract syntax tree is converted into the object of the first kind.Wherein, the object of the above-mentioned first kind can be Microsoft's generation The object of CompilationUnitSyntax types in code parsing library.Finally, terminal device can be according to the above-mentioned first kind Traversal function in object traverses each syntactic node in above-mentioned target abstract syntax tree, is included according in above-mentioned converting objects Syntax conversion rule, generation is abstracted the associated language form converting objects of tree with above-mentioned target grammer.Wherein, above-mentioned class of languages The target text information for acting as being converted to the source text information of first language type second language type of type converting objects. Wherein, above-mentioned second language type may include Lua and JavaScript, not limit herein.
S208 generates class according to the grammer and the target abstract syntax tree is converted in the language form converting objects Into the target text information.
In some feasible embodiments, terminal device can obtain after above-mentioned language form converting objects is got The flow object of one control iostream of target text coordinates measurement that above-mentioned language form converting objects includes.Then make Preset write-in object is initialized with above-mentioned flow object.Wherein, said write object is used for regular to target according to default write-in Write-in is by the transformed code of language form in text.Then, terminal device is converted by above-mentioned language form in reply It states each syntactic node in target abstract syntax tree and carries out language form conversion.Specifically, it is carried by language form converting objects Take out any one syntactic node k in above-mentioned target abstract syntax tree, by language form converting objects obtain with it is above-mentioned The associated language form transformation rule functions of syntactic node k.Then pass through predicate in above-mentioned language form transformation rule function pair Method node k carries out language form conversion, to obtain and the corresponding target subcodes of syntactic node k.Wherein, above-mentioned target filial generation The program language type of code is above-mentioned second language type.For example, second language type can be Lua.Then, terminal device can Call the write-in object after above-mentioned initialization that above-mentioned target subcode is written in preset text.When to above-mentioned target After all syntactic nodes in abstract syntax tree complete above-mentioned conversion operation and write operation, final acquired pre-set text is For target text.All text messages in above-mentioned target text are target text information.
The embodiment of the present invention first obtains source configuration parameter, source file path parameter is included at least in source configuration parameter.Root Source text information is obtained according to above-mentioned source file path parameter.Source text information is parsed again to obtain source text information correspondence Target abstract syntax tree.Parameter is configured according to source to determine the source text information of first language type being converted to second language Target configuration parameter needed for the target text information of type.Parameter is configured in above-mentioned target and above-mentioned target abstract syntax tree leads to Cross preset grammer generation class generation language form converting objects.Class is finally generated according to above-mentioned grammer and above-mentioned language form turns It changes object and above-mentioned target abstract syntax tree is converted into above-mentioned target text information.It can be saved using journey using the embodiment of the present invention The sequence development time improves the efficiency of application development.
Fig. 3 is referred to, is a kind of structure diagram of programming language transformation terminal device provided in an embodiment of the present invention.It should Terminal device includes:
For obtaining source configuration parameter, and the source file path parameter in parameter is configured according to above-mentioned source in acquiring unit 10 Source text information is obtained, the program language type of above-mentioned source text information is first language type;
Parameter processing unit 20 is configured, the above-mentioned source for being obtained according to above-mentioned acquiring unit 10 be configured parameter determine by Above-mentioned source text information is converted to the target configuration parameter needed for target text information, the program language of above-mentioned file destination information Type is second language type
Syntax tree generation unit 30, for obtained according to above-mentioned configuration parameter processing unit 20 target configuration parameter to The above-mentioned source text information for stating the acquisition of acquiring unit 10 is parsed and is abstracted language to obtain the corresponding target of above-mentioned source text information Method tree;
Converting objects generation unit 40, for above-mentioned configuration parameter processing unit 20 is obtained target configuration parameter and The target abstract syntax tree for stating the generation of syntax tree generation unit 30 generates class generation language form conversion pair by preset grammer As;
Converting unit 50, for generating the upper predicate that class and above-mentioned converting objects generation unit 40 generate according to above-mentioned grammer Above-mentioned target abstract syntax tree is converted into above-mentioned target text information by speech type converting objects.
In some feasible embodiments, above-mentioned converting objects generation unit 40 is used for:
The above-mentioned target configuration parameter obtained according to above-mentioned configuration parameter processing unit 20 and above-mentioned syntax tree generation unit The target abstract syntax tree of 30 generations instantiates preset grammer generation class, to obtain grammer generation object;
The corresponding semantic model of the above-mentioned target abstract syntax tree of object acquisition is generated, and according to upper predicate by above-mentioned grammer Adopted model and the conversion class generative grammar node converting objects of preset syntactic node;
The root node of the above-mentioned target abstract syntax tree of object acquisition is generated according to above-mentioned grammer, and above-mentioned target is abstracted language The root node of method tree is converted into specific type object, wherein, above-mentioned specific type object is parsed for appointment codes in library The object of CompilationUnitSyntax types;
Tree is abstracted according to above-mentioned specific type object and above-mentioned syntactic node converting objects generation with above-mentioned target grammer to close The language form converting objects of connection.
In some feasible embodiments, above-mentioned source configuration parameter includes N number of source parameter, and above-mentioned configuration parameter processing is single Member 20 is used for:
Following handle is carried out to any source parameter i in above-mentioned N number of source parameter:
The value of above-mentioned source parameter i is obtained, and the value of above-mentioned source parameter i is passed into default parameter and handles class;
In above-mentioned default parameter processing class with the associated processing functions of above-mentioned source parameter i and above-mentioned source parameter i Value generation target parameter;
It is obtained the above-mentioned source text information of first language type being converted to according to the handling result of above-mentioned N number of source parameter Target configuration parameter needed for the target text information of two language forms.
In some feasible embodiments, the target abstract syntax tree that above-mentioned syntax tree generation unit 30 obtains includes M A above-mentioned converting unit of syntactic node is used for:
Class generation write-in object is generated by above-mentioned grammer according to the source file address parameter that above-mentioned acquiring unit 10 obtains, Wherein, above-mentioned write-in object was used for according to the regular write-in into target text of default write-in by language form transformed generation Code;
According to above-mentioned language form converting objects and above-mentioned write-in object to any syntactic node in above-mentioned M syntactic node J carries out following operate:
Call preset in the above-mentioned language form converting objects and associated language form transformation rules of above-mentioned syntactic node j Above-mentioned syntactic node j is converted into target subcode, wherein, the program language type of above-mentioned target subcode is above-mentioned second language Say type;
Above-mentioned target subcode is written in target text by above-mentioned write-in object according to default write-in rule, with more New above-mentioned target text;
Target text information is obtained according to newer target text is completed, wherein, above-mentioned target text information is completes more All codes in new target text.
In some feasible embodiments, please also refer to Fig. 4, Fig. 4 is a kind of program provided in an embodiment of the present invention Another structure diagram of language conversion terminal device.Above-mentioned terminal device further includes detection unit 60, above-mentioned detection unit 60 For judging whether equipment receives source configuration parameter acquisition instruction.If being judged as NO, configuration ginseng is shown in the user interface Amount input prompting.
In some feasible embodiments, above-mentioned acquiring unit 10 according to source be configured parameter obtain source text information it Before, above-mentioned detection unit 60 can obtain user by detecting user to the click of arbitrary region in the user interface of terminal device Whether operational order includes corresponding terminal work(according to what the preset instruction set of terminal device judged to receive to user operation instruction The instruction that parameter obtains can be configured for source.If being judged as YES, start 10 acquisition source of acquiring unit configuration parameter.If it is judged as No, then detection unit 60 can show configuration parameter input solicited message in above-mentioned user interface, to ask in user's input such as Operational order.Optionally, detection unit 60 can also show configuration parameter input help information in above-mentioned user interface, so that The problem of user can encounter according to its own inputs in help information from above-mentioned configuration parameter and finds corresponding solution party Method.
After acquiring unit 10 is according to operational order input by user, optionally, acquiring unit 10 can be configured according to above-mentioned source Preset source configuration parameter is obtained in the memory space of the direct slave device of parameter acquisition instruction.Wherein, above-mentioned source configuration parameter can Including:Source file path parameter, file destination path parameter, help information show parameter etc., do not limit herein.For example, it obtains Take unit 10 that parameter acquisition approach is configured according to above-mentioned source and determines that source is matched after above-mentioned source configuration parameter acquisition instruction is obtained Address of the parameter in the memory space of equipment is put, and root extracts preset source configuration out of change of address corresponding storage region Parameter.Optionally, acquiring unit 10 also can be configured parameter acquisition instruction and directly acquire the instruction by parsing above-mentioned source and be included Source configuration parameter.
Acquiring unit 10 can be configured in parameter from above-mentioned source after above-mentioned source configuration parameter is got and extract source file road Diameter parameter.Then source file is extracted from memory space according to above-mentioned source file path parameter.Finally, acquiring unit 10 can carry All text messages in above-mentioned source file are taken out, and are determined as above-mentioned source text information.Wherein, above-mentioned source file has for record The document of program code.The above-mentioned source text information of all program codes in above-mentioned source text.Above-mentioned source text information becomes Language form is above-mentioned first language type.Optionally, above-mentioned first language type is C#.For example, one is preserved 1000 The document of a byte C# language code is exactly a source file.And the C# codes of above-mentioned 1000 bytes are above-mentioned source text letter Breath.Above-mentioned C# language type is first language type.
After source text information is obtained, above-mentioned configuration parameter processing unit 20 can be configured according to above-mentioned source joins acquiring unit 10 Amount is determined for the source text information of first language type to be converted into the target needed for the target text information of second language type Parameter is configured.Wherein, above-mentioned source configuration parameter includes N number of source parameter.Specifically, configuration parameter processing unit 20 is from above-mentioned N number of A source parameter i is extracted in the parameter of source, is then determined according to the parameter name of above-mentioned source parameter i associated with source parameter i Default parameter processing function.Then, configuration parameter processing unit 20 handles the ginseng of the above-mentioned source parameter i of function pair according to default parameter Magnitude is handled, to obtain target parameter.For example, above-mentioned source configuration parameter includes source file path parameter A.Terminal device Above-mentioned source file path parameter is extracted, is then obtained according to the parameter name A for obtaining above-mentioned source path parameter associated with A pre- If parameter handles function.Wherein, above-mentioned default parameter processing function is performed, container is enumerated, and should to obtain a syntax tree Syntax tree enumerate container as with the corresponding target parameters of above-mentioned source file path parameter A.20 weight of parameter processing unit is configured Multiple aforesaid operations, until after the source parameter handled is converted into corresponding target parameter, by all targets Parameter carries out integration processing, to obtain target configuration parameter.
Parameter processing unit 20 is configured after above-mentioned target configuration parameter is obtained, syntax tree generation unit 30 is needed according to upper State target configuration parameter above-mentioned source text information is parsed, with obtain above-mentioned source text information (for convenience of understand, hereafter with Source code replace source text information be described) corresponding to abstract syntax tree.Wherein, above-mentioned syntax tree (abstract Syntax code, AST) be program codes all in above-mentioned source text abstract syntax structure tree-shaped expression, it is every on tree A kind of structure in a node all representation program codes.Why say and be abstracted, be because abstract syntax tree can't represent very Each details that real grammer occurs, can't be with for example, the nested parenthesis in program code can be implied in the structure of tree The form of node is presented.Specifically, syntax tree generation unit 30 after above-mentioned source code and target configuration parameter is got, can carry Take out the syntax tree parsing parameter included in target configuration parameter.Then parameter is parsed according to syntax tree to call the code specified Analysis structure parses above-mentioned source code, to obtain the target abstract syntax tree corresponding to above-mentioned source code.For example, grammer Tree generation unit 30 can call the code analysis function CSharpConmand Line.Default.Parse of Microsoft to upper predicate Method tree parsing parameter is parsed, and the corresponding parsing class object of parameter is parsed with above-mentioned syntax tree to obtain one.With above-mentioned Mechanical class object is inputted as the parameter of library function CSharpSyntaxTree.ParserText, passes through library function CSharpSyntaxTree.ParserText parses above-mentioned source text information, to obtain corresponding to above-mentioned source text information Target abstract syntax tree.
For syntax tree generation unit 30 after getting after above-mentioned abstract syntax tree, converting objects generation unit 40 will be above-mentioned Target abstract syntax tree and above-mentioned target abstract syntax tree generate class by preset grammer and generate language form converting objects.Tool Body, parameter first is configured according to above-mentioned target for converting objects generation unit 40 and the instantiation of above-mentioned target abstract syntax tree is preset Grammer generates class, to obtain grammer generation object.Then, converting objects generation unit 40 is adjustable is generated with predicate method in object Generating function be associated with above-mentioned target abstract syntax tree.Converting objects generation unit 40 can call preset code analysis semantic Model obtains the corresponding semantic model of above-mentioned target abstract syntax tree.For example, converting objects generation unit 40 can invocation target pumping As the corresponding preset Microsoft's code analysis semantic model Microsoft.CodeAnalysis.SemanticModel of syntax tree To obtain the semantic model of above-mentioned target abstract syntax tree.And according to above-mentioned semantic model and the conversion class life of preset syntactic node Into syntactic node converting objects.Then, converting objects generation unit 40 is adjustable generates the root section included in object with predicate method Point obtains function to obtain the root node of above-mentioned target abstract syntax tree, and the root node of above-mentioned target abstract syntax tree is converted Into the object of the first kind.Wherein, the object of the above-mentioned first kind can be in Microsoft's code analysis library The object of CompilationUnitSyntax types.Finally, converting objects generation unit 40 can be according to above-mentioned specific type object In traversal function traverse each syntactic node in above-mentioned target abstract syntax tree, according to the language included in above-mentioned converting objects Method transformation rule, generation are abstracted the associated language form converting objects of tree with above-mentioned target grammer.Wherein, above-mentioned language form turns Change the target text information for acting as being converted to the source text information of first language type second language type of object.Its In, above-mentioned second language type may include Lua and JavaScript, not limit herein.
After above-mentioned language form converting objects is got, converting unit 50 can obtain above-mentioned converting objects generation unit 40 The flow object of one control iostream of target text coordinates measurement that language form converting objects includes.Then conversion is single Member 50 initializes preset write-in object using above-mentioned flow object.Wherein, said write object is used for according to default write-in rule Into target text, write-in is by the transformed code of language form.Then, converting unit 50 is converted by above-mentioned language form To language form conversion should be carried out to syntactic node each in above-mentioned target abstract syntax tree.Specifically, converting unit 50 passes through Language form converting objects extracts any one syntactic node k in above-mentioned target abstract syntax tree, then passes through language form Converting objects obtains and the associated language form transformation rule functions of above-mentioned syntactic node k.Then converting unit 50 is by above-mentioned The above-mentioned syntactic node k of language form transformation rule function pair carries out language form conversion, corresponding with syntactic node k to obtain Target subcode.Wherein, the program language type of above-mentioned target subcode is above-mentioned second language type.For example, the second language Say that type can be Lua.Then, converting unit 50 can call the write-in object after above-mentioned initialization that above-mentioned target subcode is written Into preset text.When converting unit 50 completes above-mentioned turn to all syntactic nodes in above-mentioned target abstract syntax tree After changing operation and write operation, final acquired pre-set text is target text.All text envelopes in above-mentioned target text Breath is target text information.
The embodiment of the present invention first obtains source configuration parameter, source file path parameter is included at least in source configuration parameter.Root Source text information is obtained according to above-mentioned source file path parameter.Source text information is parsed again to obtain source text information correspondence Target abstract syntax tree.Parameter is configured according to source to determine the source text information of first language type being converted to second language Target configuration parameter needed for the target text information of type.Parameter is configured in above-mentioned target and above-mentioned target abstract syntax tree leads to Cross preset grammer generation class generation language form converting objects.Class is finally generated according to above-mentioned grammer and above-mentioned language form turns It changes object and above-mentioned target abstract syntax tree is converted into above-mentioned target text information.It can be saved using journey using the embodiment of the present invention The sequence development time improves the efficiency of application development.
Fig. 5 is referred to, is a kind of terminal device schematic block diagram that another embodiment of the present invention provides.As shown in figure 5, this reality Applying the terminal device in example can include:One or more input equipments 100;Memory 200, one or more processors 300 With one or more output equipments 400.Above-mentioned processor 300, input equipment 100, output equipment 400 and memory 200 pass through Bus 500 connects.For memory 200 for storing computer program, above computer program includes program instruction, processor 300 For performing the program instruction of the storage of memory 200.Wherein, processor 300 is configured for that above procedure instruction is called to perform: Terminal device first obtains source panoramic picture and image to be synthesized with same target object under the same conditions.Then from waiting to close The characteristic information of target object is obtained into image, and synthesis zone is determined in above-mentioned source panoramic picture according to this feature information Domain.Finally image to be synthesized is synthesized in above-mentioned synthesis region to obtain target panoramic picture.
It should be appreciated that in embodiments of the present invention, alleged processor 300 can be central processing unit (Central Processing Unit, CPU), which can also be other general processors, digital signal processor (Digital Signal Processor, DSP), application-specific integrated circuit (Application SpecificIntegrated Circuit, ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic Device, discrete gate or transistor logic, discrete hardware components etc..General processor can be microprocessor or this at It can also be any conventional processor etc. to manage device.
Input equipment 100 can include Trackpad, fingerprint and adopt sensor (for acquiring the finger print information of user and fingerprint Directional information), microphone etc., output equipment 400 can include display (LCD etc.), loud speaker etc..
The memory 200 can include read-only memory and random access memory, and to processor 300 provide instruction and Data.The a part of of memory 200 can also include nonvolatile RAM.For example, memory 200 can also be deposited Store up the information of device type.
In the specific implementation, processor 300, input equipment 100, the output equipment 200 described in the embodiment of the present invention can The realization method described in the first embodiment and second embodiment of image processing method provided in an embodiment of the present invention is performed, Also the realization method of the described terminal device of the embodiment of the present invention is can perform, details are not described herein.
A kind of computer readable storage medium, above computer readable storage medium are provided in another embodiment of the invention Matter is stored with computer program, and above computer program includes program instruction, and above procedure instruction is realized when being executed by processor: Source configuration parameter is first obtained, source file path parameter is included at least in source configuration parameter.According to above-mentioned source file path parameter Obtain source text information.Source text information is parsed again to obtain the corresponding target abstract syntax tree of source text information.Root Determine to be converted to the source text information of first language type the target text information of second language type according to source configuration parameter Required target configuration parameter.Parameter and above-mentioned target abstract syntax tree is configured in above-mentioned target, class is generated by preset grammer Generate language form converting objects.Class is finally generated according to above-mentioned grammer and above-mentioned target is taken out in above-mentioned language form converting objects As syntax tree is converted into above-mentioned target text information.
Above computer readable storage medium storing program for executing can be the storage inside list of the terminal device described in aforementioned any embodiment Member, such as the hard disk or memory of terminal device.Above computer readable storage medium storing program for executing can also be the outside of above-mentioned terminal device The plug-in type hard disk being equipped in storage device, such as the terminal device, intelligent memory card (Smart Media Card, SMC), Secure digital (Secure Digital, SD) blocks, flash card (FlashCard) etc..Further, above computer readable storage Medium can also both include the internal storage unit of above-mentioned terminal device or including External memory equipment.Above computer is readable to deposit Storage media is used to store above computer program and other programs and data needed for above-mentioned terminal device.Above computer can Storage medium is read to can be also used for temporarily storing the data that has exported or will export.
Those of ordinary skill in the art may realize that each exemplary lists described with reference to the embodiments described herein Member and algorithm steps can be realized with the combination of electronic hardware, computer software or the two, in order to clearly demonstrate hardware With the interchangeability of software, each exemplary composition and step are generally described according to function in the above description.This A little functions are performed actually with hardware or software mode, specific application and design constraint depending on technical solution.Specially Industry technical staff can realize described function to each specific application using distinct methods, but this realization is not It is considered as beyond the scope of this invention.
It is apparent to those skilled in the art that for convenience of description and succinctly, foregoing description terminal The specific work process of equipment and unit can refer to the corresponding process in preceding method embodiment, and details are not described herein.
In several embodiments provided herein, it should be understood that disclosed terminal device and method, Ke Yitong Other modes are crossed to realize.For example, the apparatus embodiments described above are merely exemplary, for example, the unit is drawn Point, only a kind of division of logic function can have other dividing mode, such as multiple units or component can in actual implementation To combine or be desirably integrated into another system or some features can be ignored or does not perform.It is in addition, shown or discussed Mutual coupling, direct-coupling or communication connection can be by the INDIRECT COUPLING of some interfaces, device or unit or Communication connection or electricity, the connection of mechanical or other forms.
The above-mentioned unit illustrated as separating component may or may not be physically separate, be shown as unit The component shown may or may not be physical unit, you can be located at a place or can also be distributed to multiple In network element.Some or all of unit therein can be selected according to the actual needs to realize the embodiment of the present invention Purpose.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, it can also It is that each unit is individually physically present or two or more units integrate in a unit.It is above-mentioned integrated The form that hardware had both may be used in unit is realized, can also be realized in the form of SFU software functional unit.
If above-mentioned integrated unit is realized in the form of SFU software functional unit and is independent product sale or uses When, it can be stored in a computer read/write memory medium.Based on such understanding, technical scheme of the present invention is substantially The part to contribute in other words to the prior art or all or part of the technical solution can be in the form of software products It embodies, which is stored in a storage medium, is used including some instructions so that a computer Equipment (can be personal computer, server or the network equipment etc.) performs the complete of each embodiment the method for the present invention Portion or part steps.And aforementioned storage medium includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD etc. are various can store journey The medium of sequence code.

Claims (10)

  1. A kind of 1. method of programming language transformation, which is characterized in that the method includes:
    Parameter is configured in acquisition source, and the source file path parameter being configured in parameter according to the source obtains source text information, described The program language type of source text information is first language type;
    According to the source be configured parameter determine the source text information being converted to target text information needed for target configuration Parameter, the program language type of the file destination information is second language type;
    Parameter is configured according to the target source text information is parsed to obtain the corresponding mesh of the source text information Mark abstract syntax tree;
    Parameter and the target abstract syntax tree is configured in the target, class generation language form turn is generated by preset grammer Change object;
    Class is generated according to the grammer and the target abstract syntax tree is converted into the mesh by the language form converting objects Mark text message.
  2. 2. according to the method described in claim 1, it is characterized in that, described be abstracted target configuration parameter and the target Syntax tree generates class generation language form converting objects by preset grammer and includes:
    Parameter is configured according to the target and the target abstract syntax tree instantiates preset grammer generation class, to obtain grammer Generate object;
    The corresponding semantic model of target abstract syntax tree described in object acquisition is generated, and according to the semantic mould by the grammer Type and the conversion class generative grammar node converting objects of preset syntactic node;
    The root node of target abstract syntax tree according to the grammer generates object acquisition, and by the target abstract syntax tree Root node be converted into the object of the first kind;
    Tree is abstracted according to the object of the first kind and syntactic node converting objects generation with the target grammer to be associated with Language form converting objects.
  3. 3. method according to claim 1 or 2, which is characterized in that the target abstract syntax tree includes M grammer section Point, it is described that the target abstract syntax tree is converted by target according to grammer generation class and the language form converting objects Text message includes:
    Class generation write-in object is generated by the grammer according to the source file address parameter, wherein, said write object is used It is written according to default write-in rule into pre-set text by the transformed code of program language type;
    According to the language form converting objects and said write object to any syntactic node j in the M syntactic node into Row is following to be operated:
    Preset in the language form converting objects and associated language form transformation rules of the syntactic node j are called by institute It states syntactic node j and is converted into target subcode, wherein, the program language type of the target subcode is the second language class Type;
    The target subcode is written in preset target text by said write object according to default write-in rule, with Update the target text;
    Target text information is obtained according to the target text that update is completed.
  4. 4. according to the method described in claim 3, it is characterized in that, source configuration parameter includes N number of source parameter, the basis The target configuration parameter that the source configuration parameter is determined to be converted to the source text information needed for target text information includes:
    Following handle is carried out to any source parameter i in N number of source parameter:
    The value of the source parameter i is obtained, and the value of the source parameter i is passed into default parameter and handles class;
    According to the value life with the associated processing functions of the source parameter i and the source parameter i in the default parameter processing class Into target parameter;
    Mesh according to needed for the handling result of N number of source parameter obtains the source text information being converted to target text information Standard configuration puts parameter.
  5. 5. according to claim 1-4 any one of them methods, which is characterized in that described before the acquisition configuration parameter Method further includes:
    Judge whether to receive source configuration parameter acquisition instruction;
    If being judged as NO, configuration parameter input prompting is shown in the user interface.
  6. 6. according to claim 1-5 any one of them methods, which is characterized in that the first language type is C#, described the Two language forms include Lua or JavaScript.
  7. 7. a kind of programming language transformation terminal device, which is characterized in that the terminal includes:
    Acquiring unit, for obtaining source configuration parameter, and the source file path parameter being configured in parameter according to the source obtains source Text message, the program language type of the source text information is first language type;
    Parameter processing unit is configured, determines the source text information being converted to target text for parameter to be configured according to the source Target configuration parameter needed for this information, the program language type of the file destination information is second language type;
    Syntax tree generation unit, for being parsed the source text information that the second acquisition unit obtains to obtain State the corresponding target abstract syntax tree of source text information;
    Converting objects generation unit, for the target configuration parameter for obtaining the configuration parameter processing unit and the syntax tree The target abstract syntax tree of generation unit generation generates class by preset grammer and generates language form converting objects;
    Converting unit, the language form for generating class and converting objects generation unit generation according to the grammer turn It changes object and the target abstract syntax tree is converted into the target text information.
  8. 8. terminal device according to claim 7, which is characterized in that the converting objects generation unit is used for:
    Described in the target configuration parameter obtained according to the configuration parameter processing unit and syntax tree generation unit generation Target abstract syntax tree instantiates preset grammer generation class, to obtain grammer generation object;
    The corresponding semantic model of target abstract syntax tree described in object acquisition is generated, and according to the semantic mould by the grammer Type and the conversion class generative grammar node converting objects of preset syntactic node;
    The root node of target abstract syntax tree according to the grammer generates object acquisition, and by the target abstract syntax tree Root node be converted into the object of the first kind;
    Tree is abstracted according to the object of the first kind and syntactic node converting objects generation with the target grammer to be associated with Language form converting objects.
  9. 9. a kind of terminal device, which is characterized in that including processor, input equipment, output equipment and memory, the processing Device, input equipment, output equipment and memory are connected with each other, wherein, the memory is used to store computer program, the meter Calculation machine program includes program instruction, and the processor is configured for calling described program instruction, performs claim 1-6 such as and appoint Method described in one.
  10. 10. a kind of computer readable storage medium, which is characterized in that the computer storage media is stored with computer program, The computer program includes program instruction, and described program instruction makes the processor perform such as right when being executed by a processor It is required that 1-6 any one of them methods.
CN201711466295.1A 2017-12-28 2017-12-28 Program language conversion method, terminal device and computer readable medium Active CN108182069B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711466295.1A CN108182069B (en) 2017-12-28 2017-12-28 Program language conversion method, terminal device and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711466295.1A CN108182069B (en) 2017-12-28 2017-12-28 Program language conversion method, terminal device and computer readable medium

Publications (2)

Publication Number Publication Date
CN108182069A true CN108182069A (en) 2018-06-19
CN108182069B CN108182069B (en) 2021-03-02

Family

ID=62548503

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711466295.1A Active CN108182069B (en) 2017-12-28 2017-12-28 Program language conversion method, terminal device and computer readable medium

Country Status (1)

Country Link
CN (1) CN108182069B (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408247A (en) * 2018-09-17 2019-03-01 天津龙拳风暴科技有限公司 Interaction data processing method and device
CN109584056A (en) * 2018-09-20 2019-04-05 招商证券股份有限公司 A kind of share-selecting method and device based on natural language
CN110795142A (en) * 2019-10-18 2020-02-14 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN111309301A (en) * 2020-01-17 2020-06-19 广东三维家信息科技有限公司 Program language conversion method, device and conversion equipment
CN111367527A (en) * 2020-02-18 2020-07-03 北京字节跳动网络技术有限公司 Language processing method, device, medium and electronic equipment
CN111414441A (en) * 2019-01-04 2020-07-14 阿里巴巴集团控股有限公司 Map data inspection system and method, inspection rule configuration system and method
CN111539200A (en) * 2020-04-22 2020-08-14 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating rich text
CN111796829A (en) * 2020-05-19 2020-10-20 北京三快在线科技有限公司 Applet updating method and device, electronic equipment and computer readable storage medium
CN111831384A (en) * 2020-07-20 2020-10-27 北京百度网讯科技有限公司 Language switching method and device, equipment and storage medium
CN112667240A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Program code conversion method and related device
CN112749552A (en) * 2021-01-29 2021-05-04 北京小米松果电子有限公司 Text conversion method and device, storage medium and electronic equipment
CN113608745A (en) * 2021-08-11 2021-11-05 平安国际智慧城市科技股份有限公司 Method for initializing user authority and storage medium
CN114816425A (en) * 2022-04-27 2022-07-29 珠海市奥德维科技有限公司 Method, system, electronic device and storage medium for converting an automation language program into a LUA language program
CN117075912A (en) * 2023-10-16 2023-11-17 芯行纪科技有限公司 Method for program language conversion, compiling method and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090064091A1 (en) * 2005-06-27 2009-03-05 Albert Donald Tonkin Code transformation
CN102222004A (en) * 2011-07-01 2011-10-19 福建富士通信息软件有限公司 Method for transforming switch special language into C language
CN104391730A (en) * 2014-08-03 2015-03-04 浙江网新恒天软件有限公司 Software source code language translation system and method
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
CN105335366A (en) * 2014-05-30 2016-02-17 北大方正信息产业集团有限公司 SQL statement processing method and apparatus and server

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090064091A1 (en) * 2005-06-27 2009-03-05 Albert Donald Tonkin Code transformation
CN102222004A (en) * 2011-07-01 2011-10-19 福建富士通信息软件有限公司 Method for transforming switch special language into C language
CN105335366A (en) * 2014-05-30 2016-02-17 北大方正信息产业集团有限公司 SQL statement processing method and apparatus and server
CN104391730A (en) * 2014-08-03 2015-03-04 浙江网新恒天软件有限公司 Software source code language translation system and method
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王万山: ""从Java语言到XML语言的转换"", 《中国优秀硕博士学位论文全文数据库(硕士) 信息科技辑》 *

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408247A (en) * 2018-09-17 2019-03-01 天津龙拳风暴科技有限公司 Interaction data processing method and device
CN109584056A (en) * 2018-09-20 2019-04-05 招商证券股份有限公司 A kind of share-selecting method and device based on natural language
CN111414441B (en) * 2019-01-04 2023-05-26 阿里巴巴集团控股有限公司 Map data inspection system and method, inspection rule configuration system and method
CN111414441A (en) * 2019-01-04 2020-07-14 阿里巴巴集团控股有限公司 Map data inspection system and method, inspection rule configuration system and method
CN110795142B (en) * 2019-10-18 2023-04-07 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN110795142A (en) * 2019-10-18 2020-02-14 郑州阿帕斯科技有限公司 Configuration file generation method and device
CN111309301A (en) * 2020-01-17 2020-06-19 广东三维家信息科技有限公司 Program language conversion method, device and conversion equipment
CN111309301B (en) * 2020-01-17 2023-09-01 广东三维家信息科技有限公司 Program language conversion method, device and conversion equipment
CN111367527A (en) * 2020-02-18 2020-07-03 北京字节跳动网络技术有限公司 Language processing method, device, medium and electronic equipment
CN111367527B (en) * 2020-02-18 2023-03-28 北京字节跳动网络技术有限公司 Language processing method, device, medium and electronic equipment
CN111539200A (en) * 2020-04-22 2020-08-14 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating rich text
CN111539200B (en) * 2020-04-22 2023-08-18 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for generating rich text
CN111796829A (en) * 2020-05-19 2020-10-20 北京三快在线科技有限公司 Applet updating method and device, electronic equipment and computer readable storage medium
CN111796829B (en) * 2020-05-19 2024-06-07 北京三快在线科技有限公司 Applet updating method, device, electronic equipment and computer readable storage medium
CN111831384A (en) * 2020-07-20 2020-10-27 北京百度网讯科技有限公司 Language switching method and device, equipment and storage medium
CN111831384B (en) * 2020-07-20 2024-01-09 北京百度网讯科技有限公司 Language switching method, device, equipment and storage medium
CN112667240A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Program code conversion method and related device
CN112749552A (en) * 2021-01-29 2021-05-04 北京小米松果电子有限公司 Text conversion method and device, storage medium and electronic equipment
CN112749552B (en) * 2021-01-29 2023-11-21 北京小米松果电子有限公司 Text conversion method and device, storage medium and electronic equipment
CN113608745A (en) * 2021-08-11 2021-11-05 平安国际智慧城市科技股份有限公司 Method for initializing user authority and storage medium
CN114816425A (en) * 2022-04-27 2022-07-29 珠海市奥德维科技有限公司 Method, system, electronic device and storage medium for converting an automation language program into a LUA language program
CN117075912A (en) * 2023-10-16 2023-11-17 芯行纪科技有限公司 Method for program language conversion, compiling method and related equipment
CN117075912B (en) * 2023-10-16 2023-12-26 芯行纪科技有限公司 Method for program language conversion, compiling method and related equipment

Also Published As

Publication number Publication date
CN108182069B (en) 2021-03-02

Similar Documents

Publication Publication Date Title
CN108182069A (en) Programming language transformation method, terminal device and computer-readable medium
CN111026470B (en) System and method for verification and conversion of input data
CN110162296A (en) Generation method, device and the terminal device of application programming interface document
US9886268B1 (en) Dual programming interface
US9733901B2 (en) Domain specific language design
CN106293653B (en) Code processing method and device and computer readable medium
CN107610698A (en) A kind of method for realizing Voice command, robot and computer-readable recording medium
CN109891374B (en) Method and computing device for force-based interaction with digital agents
CN108108094A (en) A kind of information processing method, terminal and computer-readable medium
CN107943691A (en) A kind of method and device for the functional test page for automatically generating intelligent contract
US8631049B2 (en) Constructing declarative componentized applications
CN108241464A (en) A kind of method, terminal and computer readable storage medium for showing chat message
CN106601256B (en) The method and mobile terminal of speech recognition
CN108829371A (en) interface control method, device, storage medium and electronic equipment
CN106952655A (en) A kind of input method and terminal
US20130332897A1 (en) Creating a user model using component based approach
CN114445047B (en) Workflow generation method and device, electronic equipment and storage medium
CN116306396A (en) Chip verification method and device, equipment and medium
US20220198153A1 (en) Model training
CN109614094B (en) Drawing method of GPU glCallList view model based on UML
US9418148B2 (en) System and method to label unlabeled data
CN107783932A (en) Information processing method, mobile terminal and the computer-readable recording medium of calculator
CN117194625A (en) Intelligent dialogue method and device for digital person, electronic equipment and storage medium
US8898625B2 (en) Optimized storage of function variables
KR101985491B1 (en) Result generating and monitoring apparatus using visualzation of formula with diagram mode

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
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address

Address after: 518000 unit 01, 16 / F, unit 2, building a, Kexing Science Park, Keyuan Road, Central District, Nanshan District, Shenzhen City, Guangdong Province

Patentee after: SHENZHEN IDREAMSKY TECHNOLOGY Co.,Ltd.

Address before: 518000 unit 01, 16 / F, unit 2, building a, Kexing Science Park, Keyuan Road, Central District, Nanshan District, Shenzhen City, Guangdong Province

Patentee before: SHENZHEN IDREAMSKY TECHNOLOGY Co.,Ltd.

CP03 Change of name, title or address