CN110109681B - Method and system for converting codes between different platforms - Google Patents

Method and system for converting codes between different platforms Download PDF

Info

Publication number
CN110109681B
CN110109681B CN201910380916.7A CN201910380916A CN110109681B CN 110109681 B CN110109681 B CN 110109681B CN 201910380916 A CN201910380916 A CN 201910380916A CN 110109681 B CN110109681 B CN 110109681B
Authority
CN
China
Prior art keywords
platform
conversion
codes
under
code
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.)
Active
Application number
CN201910380916.7A
Other languages
Chinese (zh)
Other versions
CN110109681A (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.)
Shanghai Ctrip Business Co Ltd
Original Assignee
Shanghai Ctrip Business Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Ctrip Business Co Ltd filed Critical Shanghai Ctrip Business Co Ltd
Priority to CN201910380916.7A priority Critical patent/CN110109681B/en
Publication of CN110109681A publication Critical patent/CN110109681A/en
Application granted granted Critical
Publication of CN110109681B publication Critical patent/CN110109681B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Abstract

The invention discloses a method and a system for converting codes among different platforms, wherein the codes comprise service codes, and the conversion method comprises the following steps: converting the business codes under the first platform into grammar trees through a conversion tool; and carrying out batch processing on the node contents in the grammar tree according to a preset conversion rule to obtain service codes under a second platform corresponding to the service codes under the first platform. The invention can realize the use of multiple platforms under the condition of developing only one set of codes, thereby reducing the workload and development period of developers, simultaneously reducing the learning cost under different platforms and the maintenance cost for the codes under different platforms, on the other hand, greatly improving the upper line speed of the related APP and leading the user experience to be better.

Description

Method and system for converting codes between different platforms
Technical Field
The invention relates to the technical field of computer information, in particular to a method and a system for converting codes among different platforms.
Background
With the rapid development of computer information technology, various types of APPs (applications) are emerging continuously, and developers generally need to develop the same APP under different platforms, which is a common practice to develop APPs under different platforms respectively, which conform to the grammar rules under different platforms and the same functions of the underlying architecture.
Disclosure of Invention
The invention aims to overcome the defect that APP with the same function needs to be developed for many times under different platforms in the prior art, and provides a method and a system for converting codes between different platforms.
The invention solves the technical problems by the following technical scheme:
the invention provides a conversion method of codes among different platforms, wherein the codes comprise service codes, and the conversion method comprises the following steps:
converting the business codes under the first platform into grammar trees through a conversion tool;
wherein the service code includes both a page portion and a component portion.
And carrying out batch processing on the node contents in the grammar tree according to a preset conversion rule to obtain service codes under a second platform corresponding to the service codes under the first platform.
Preferably, the step of performing batch processing on the node content in the syntax tree according to a preset conversion rule to obtain a service code under a second platform corresponding to the service code under the first platform includes: retrieving events and functions in the service codes under the first platform through the grammar tree; retrieving conversion rules corresponding to the events and functions in the registry, and putting the retrieved conversion rules into the grammar tree at the positions corresponding to the events and functions; the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform; converting the grammar tree into service codes under a second platform through the conversion tool;
and/or the number of the groups of groups,
the step of converting the business codes under the first platform into grammar trees by the conversion tool further comprises the following steps: carrying out standardization processing on the service codes under the first platform;
and/or the number of the groups of groups,
the step of searching the conversion rule corresponding to the event and the function in the registry further comprises the following steps: comparing the service codes under the first platform with the service codes under the second platform to obtain the difference points of the service codes under the two platforms; according to the difference points, a registry is manufactured, and the conversion rules in the registry comprise any one of grammar conversion, dependency injection and plug-in injection;
and/or the number of the groups of groups,
the types of the service codes comprise: any one of production cycle event processing, routing processing, state processing, static files, picture resource processing, and color theme processing and storage processing;
and/or the number of the groups of groups,
the transformation tool is an AST (abstract syntax tree).
Preferably, the code further comprises frame code; the conversion method comprises the following steps:
defining a mapping library, wherein the mapping library comprises a preset conversion rule for converting the frame codes under the first platform into the frame codes under the second platform; converting the frame codes under the first platform into frame codes under the second platform through the mapping library;
and/or the number of the groups of groups,
after the step of converting the syntax tree into the service code under the second platform by the conversion tool, the method further includes: and changing parameters of the front-end code of the first platform so as to enable the theme of the first platform to be matched with the theme of the second platform.
Preferably, the codes under the first platform are stored in a first folder;
the codes under the second platform are stored in a second folder;
the conversion method further includes:
traversing the first folder and classifying codes in the first folder into different categories, wherein the categories comprise business codes, frame codes and common codes; the common code is the same code under the first platform and the second platform;
copying the common codes into the second folder.
Preferably, the conversion method further comprises:
and detecting whether the conversion file corresponding to each preset path is contained in the preset path in the second folder, and if yes, converting successfully.
The invention also provides a conversion system of codes among different platforms, wherein the codes comprise service codes, and the conversion system comprises a grammar tree conversion module and a service code conversion module;
the grammar tree conversion module is used for converting the business codes under the first platform into grammar trees through a conversion tool;
the service code conversion module is used for carrying out batch processing on the node content in the grammar tree according to a preset conversion rule so as to obtain the service code under the second platform corresponding to the service code under the first platform.
Wherein the service code includes both a page portion and a component portion.
Preferably, the service transcoding module comprises: the event retrieval unit is used for retrieving events and functions in the business codes under the first platform through the grammar tree; the conversion rule searching unit is used for searching the conversion rule corresponding to the event and the function in the registry and placing the searched conversion rule into a position corresponding to the event and the function in the grammar tree; the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform; a code conversion unit, configured to convert, by using the conversion tool, the syntax tree into a service code under a second platform;
and/or the number of the groups of groups,
the conversion system further includes: the standardization module is used for carrying out standardization processing on the service codes under the first platform;
and/or the number of the groups of groups,
the conversion system further includes: the comparison module and the registry preparation module; the comparison unit is used for comparing the service codes under the first platform with the service codes under the second platform to obtain the difference points of the service codes under the two platforms; the registry making module is used for making a registry according to the difference points, and the conversion rules in the registry comprise any one of grammar conversion, dependency injection and plug-in injection;
and/or the number of the groups of groups,
the types of the service codes comprise: any one of production cycle event processing, routing processing, status processing, static files, picture resource processing, and color theme processing and storage processing.
And/or the number of the groups of groups,
the conversion tool is an AST.
Preferably, the code further comprises frame code; the conversion system includes: the mapping module and the frame code conversion module;
the mapping module is used for defining a mapping library, and the mapping library comprises a preset conversion rule for converting the frame codes under the first platform into the frame codes under the second platform;
the frame code conversion module is used for converting the frame codes under the first platform into the frame codes under the second platform through the mapping library;
and/or the number of the groups of groups,
the conversion system further includes:
and the theme matching module is used for changing parameters of the front-end code of the first platform so as to match the theme of the first platform with the theme of the second platform.
Preferably, the codes under the first platform are stored in a first folder;
the codes under the second platform are stored in a second folder;
the conversion system further includes: a traversal module and a common code conversion module;
the traversing module is used for traversing the first folder and classifying codes in the first folder into different categories, wherein the categories comprise business codes, frame codes and common codes; the common code is the same code under the first platform and the second platform;
the common code conversion module is used for copying the common codes into the second folder.
Preferably, the conversion system further comprises:
and the verification module is used for detecting whether the conversion file corresponding to each preset path is contained in the preset path in the second folder, and if yes, the conversion is successful.
The invention has the positive progress effects that:
the invention compares the difference of the code realization under two platforms, and respectively realizes the conversion among the business code, the frame code and the common code according to the difference of the two platforms, thereby realizing the use of multiple platforms under the condition of only developing one set of code, reducing the workload and the development period of developers, simultaneously reducing the learning cost under different platforms and the maintenance cost of the code under different platforms, on the other hand, greatly improving the upper line speed of the related APP and leading the user experience to be better.
Drawings
Fig. 1 is a flowchart of a method for converting codes between different platforms in embodiment 1.
Fig. 2 is a schematic diagram of a certain section of service code in a specific application scenario in step 11 of embodiment 1.
Fig. 3 is a partial grammar tree diagram of the service code conversion in fig. 2 of embodiment 1.
Fig. 4 is a flowchart of a method for converting codes between different platforms in embodiment 2.
Fig. 5 is a schematic diagram of a method for obtaining a certain picture under the first platform of embodiment 2.
Fig. 6 is a schematic diagram of a method for obtaining a certain picture under the second platform of embodiment 2.
Fig. 7 is an explanatory diagram of the registry in embodiment 2.
Fig. 8 is a flowchart showing the steps of frame transcoding of the method for transcoding between different platforms in embodiment 2.
Fig. 9 is a schematic diagram of an implementation manner of embodiment 2 for whether code conversion is successful in a specific scenario.
FIG. 10 is a block diagram of a system for transcoding between different platforms in accordance with embodiment 3.
Fig. 11 is a schematic block diagram of a service transcoding module according to embodiment 3.
Detailed Description
The invention is further illustrated by means of the following examples, which are not intended to limit the scope of the invention.
Example 1
The embodiment provides a conversion method of codes between different platforms, which comprises the following steps:
step 11, converting the business codes under the first platform into grammar trees through a conversion tool;
step 12, searching events and functions in the service codes under the first platform through the grammar tree;
step 13, searching conversion rules corresponding to the events and functions in the registry, and putting the searched conversion rules into the grammar tree at the positions corresponding to the events and functions;
the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform;
and step 14, converting the grammar tree into service codes under a second platform through the conversion tool.
In this embodiment, conversion between the syntax tree and the code is implemented by AST, where the first conversion is to convert the code under the first platform into the syntax tree, the second conversion is to convert the updated syntax tree into the code under the second platform, fig. 2 is a schematic diagram of a certain section of service code under the first platform in a specific scene, fig. 3 is a schematic diagram of a part of the syntax tree, and as shown in fig. 2 and 3, quick conversion of the service code in fig. 2 into the syntax tree in fig. 3 can be implemented by AST, so that batch operation on the code can be implemented.
In this embodiment, the service code under the first platform is converted into the syntax tree, and then the corresponding function and event in the registry are converted into the service code under the second platform by the AST, so that batch processing of the corresponding function and event under the first platform can be realized, the same function does not need to be developed for the second time, thereby realizing efficient program development, greatly reducing the workload of developers, and improving the online speed of the program.
Example 2
The embodiment provides a method for converting codes between different platforms, and the method for converting codes is shown in fig. 4, and comprises the following steps:
step 21, comparing the service codes under the first platform with the service codes under the second platform to obtain the difference points of the service codes under the two platforms;
step 22, a registry is manufactured according to the difference points;
the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform;
step 23, normalizing the service codes under the first platform;
step 24, converting the business codes under the first platform into grammar trees through a conversion tool;
step 25, searching events and functions in the service codes under the first platform through the grammar tree;
step 26, searching the conversion rule corresponding to the event and the function in the registry, and putting the searched conversion rule into a grammar tree at a position corresponding to the event and the function;
and step 27, converting the grammar tree into service codes under a second platform through the conversion tool.
The type of the service code comprises any one of production cycle event processing, routing processing, state processing, static file processing, picture resource processing, color theme processing and storage processing. In order to better understand the present invention, the difference between codes of obtaining pictures under two platforms in a specific scene is shown in this embodiment, as shown in fig. 5, a required portion in a box is a manner of obtaining a certain picture path under a first platform, and contents in brackets behind the required portion in the figure are specific paths of a certain picture under the first platform. As shown in fig. 6, uri in the box is a path way of obtaining a certain picture under the second platform, where the content in the quotation mark behind uri is a specific path of the certain picture under the second platform. In this embodiment, a conversion rule is defined in the registry, so that a mode of obtaining a picture under a first platform is converted into a mode of obtaining a picture under a second platform, thereby realizing conversion of modes of obtaining pictures under both platforms.
Wherein the service code includes both a page portion and a component portion.
Where the conversion rules in the registry include grammar conversion, dependency injection, plug-in injection, etc., which generally only involve differences in grammar rules in functions or events, dependency injection generally involves cross-file processing, plug-in injection generally involves processing a particular type of file that can be invoked directly.
In this embodiment, different conversion rules are defined in the registry, so that flexibility of the whole conversion process can be improved, workload of developers can be reduced, and maintainability of the whole process can be improved.
In this embodiment, the registry for the corresponding functions under the two platforms is manufactured by comparing the differences of the two platforms in advance, so that the quick call of rules in the registry can be realized in a specific conversion process, the conversion speed is greatly improved, in addition, errors in the conversion process can be avoided through standardization processing of service codes, and the conversion between codes under different platforms can be realized faster and more accurately.
Fig. 7 is an illustration of a registry made in this embodiment, as shown in fig. 7, the name of each function or event to the left of the colon, and the implementation rules of the function to the left of the colon.
In this embodiment, all codes under the first platform are placed in the first folder and all codes under the second platform are placed in the second folder. By placing different codes in different folders, the method is convenient for developers to check, and confusion between codes under two platforms is avoided.
Since the implementation manners of the functions under different platforms may be different, some may relate to the business components and the bottom layer, some may be different and some may not be different in grammar rules, in this embodiment, before all codes are converted, the method further includes the steps of:
traversing the first folder and classifying codes in the first folder into different categories, wherein the categories comprise business codes, frame codes and common codes;
the processing manners of the different codes are different, and for the business codes, the processing manners of the steps 21-27 are mainly used for the difference of the grammar, while for the frame codes, the frame difference part between apps under different platforms is mainly used for the difference of business components and bottom layer implementation provided by different teams, so that the same manner as the business codes cannot be adopted, and as shown in fig. 8, the embodiment further comprises:
step 31, defining a mapping library, wherein the mapping library comprises a preset conversion rule for converting the frame codes under the first platform into the frame codes under the second platform;
and step 32, converting the frame codes under the first platform into the frame codes under the second platform through the mapping library.
In this embodiment, a mapping library is manually maintained, so that compatibility between libraries of corresponding functions under different platforms is realized, so that functions and events can be called without cost, and rapid conversion of frame codes is realized. For example, if code of a login function needs to be converted, a method of converting login function a.userlogic () under a first platform into login function b.login () under a second platform may be defined in a mapping library, thereby realizing cost-free conversion of a framework code.
The above-mentioned common code is a code that is not different between the first platform and the second platform, so in this embodiment, the method adopted for converting the common code is as follows:
copying the common codes into the second folder.
The conversion between the common codes can be realized through the steps.
In this embodiment, by distinguishing codes, different conversion rules can be used to convert different types of codes, so that the conversion efficiency of the codes under the whole first platform is higher, and the utilization efficiency of system resources is also higher.
In this embodiment, since there may be different topics of the APP under the first platform and the second platform, the present embodiment may further include the steps of:
and changing parameters of the front-end code of the first platform so as to enable the theme of the first platform to be matched with the theme of the second platform.
Because the difference between the themes generally only relates to the front end, but not to a specific business part or an underlying part, only the front end codes and parameters thereof are required to be changed, and therefore, theme skin can be quickly changed through the modification, so that the conversion efficiency between codes is higher.
In order to detect whether all codes under the first platform are successfully converted into codes under the second platform, the embodiment also needs to check the converted codes, where the checking can be performed by the following ways:
detecting whether the conversion file corresponding to each preset path is contained in the preset path in the second folder, if yes, successful conversion is achieved, and if not, conversion fails. Fig. 9 illustrates an implementation manner of checking whether the conversion is successful in a specific scenario, as shown in fig. 9, the preset path is included in each row of brackets, and whether the conversion is successful can be detected by checking whether there are converted files in the preset path and whether the converted files are matched with the preset number of files.
In this embodiment, by checking the files in the converted folder, it may be detected whether the code under the first platform is successfully converted into the code under the second platform, so that the accuracy of conversion may be improved.
In this embodiment, the method may further include a configuration step, and in the development engineering, by comparing whether the first under-platform APP module is different from the second under-platform APP module, the same function as the second under-platform APP module may be achieved after the first under-platform APP module is transcoded, if a certain module has an advertisement popup under the first platform but not under the second platform, then the converted APP needs to be configured without a popup under the second platform.
For a better understanding of the present invention, the present embodiment is further explained below by way of a specific example:
the method comprises the steps of storing codes under a first platform in a first folder, traversing the first folder, dividing the codes under the first platform into three types of service codes, framework codes and common codes after traversing, normalizing the service codes, defining pages, triggering states, components and the like of the service codes according to predefined specification rules, converting the service codes into grammar trees through AST (application specific server), specifically, completing the service codes through introduced third party libraries and servers, finding events and functions corresponding to the service codes under the first platform through nodes in the grammar trees, then putting the corresponding events and functions into a tool AST, converting the service codes into the service codes under a second platform through the tool, specifically, realizing conversion through a custom mapping library and copying for the framework codes and the common codes under the first platform, and after all the conversion is completed, modifying the front ends of the two platforms for realizing consistent skin codes. All codes under the second platform are stored in a second file home, in order to detect whether the codes under the first platform are successfully converted into the codes under the second platform, the second file folder can be traversed to detect whether a corresponding number of files exist under a preset path, and if yes, the conversion is successful; after the conversion is successful, all code can be executed under the second platform to complete further testing, and if all code can be executed, the program can be brought online.
In this embodiment, by classifying the codes under the first platform and setting different conversion rules for the codes of different types, not only can the conversion of the codes under different platforms be realized, but also the conversion efficiency is higher, so that the learning cost under different platforms is reduced, the code maintenance cost is lower, the workload and the working period of developers are reduced, the online speed of the APP is also improved, and the user experience is better.
Example 3
The embodiment provides a system for converting codes among different platforms, wherein in the embodiment, the codes under a first platform are stored in a first folder; codes under the second platform are stored in a second folder.
As shown in fig. 10, the conversion system includes: syntax tree conversion module 41, business code conversion module 42, specification module 43, comparison module 44, registry making module 45, mapping module 46, framework code conversion module 47, topic matching module 48, traversal module 49, normal code conversion module 50, and verification module 51.
The syntax tree conversion module 41 is configured to convert the service codes under the first platform into syntax trees by using a conversion tool. In this embodiment, the conversion tool is an AST.
The service code conversion module 42 is configured to perform batch processing on node contents in the syntax tree according to a preset conversion rule to obtain a service code under a second platform corresponding to the service code under the first platform.
Wherein, the types of the service codes comprise: any one of production cycle event processing, routing processing, status processing, static files, picture resource processing, and color theme processing and storage processing.
The normalization module 43 is configured to normalize the service code under the first platform.
The comparison module 44 is configured to compare the service code under the first platform with the service code under the second platform to obtain a difference point between the service codes under the two platforms;
the registry making module 45 is configured to make a registry according to the difference points, where the conversion rule in the registry includes any one of grammar conversion, dependency injection, and plug-in injection; .
The mapping module 46 is configured to define a mapping library, where the mapping library includes a preset conversion rule for converting the frame code under the first platform into the frame code under the second platform;
the frame code conversion module 47 is configured to convert the frame code under the first platform into the frame code under the second platform through the mapping library.
The theme matching module 48 is configured to alter parameters of the front-end code of the first platform so that the theme of the first platform matches the theme of the second platform.
The traversing module 49 is configured to traverse the first folder and divide codes in the first folder into different categories, where the categories include business codes, frame codes, and common codes; the common code is the same code under the first platform and the second platform;
the common code conversion module 50 is configured to copy the common code into the second folder.
The verification module 51 is configured to detect whether a conversion file corresponding to each preset path in the second folder is included in the preset path, and if yes, the conversion is successful.
As shown in fig. 11, the service transcoding module 42 in the present embodiment includes: event retrieval section 421, conversion rule retrieval section 422, and code conversion section 423.
The event retrieving unit 421 is configured to retrieve events and functions in the service code under the first platform through the syntax tree.
The conversion rule retrieving unit 422 is configured to retrieve a conversion rule corresponding to the event and the function in the registry, and place the retrieved conversion rule in a position corresponding to the event and the function in the syntax tree; the registry includes a preset conversion rule for converting the event and function under the first platform to the corresponding event and function under the second platform.
The code conversion unit 423 is configured to convert, by using the conversion tool, the syntax tree into a service code under a second platform.
In this embodiment, the service codes under the first platform are converted into the syntax trees by the syntax tree conversion module 41, and then the corresponding functions and events in the registry are converted into the service codes under the second platform by the service code conversion module 42, so that batch processing of the corresponding functions and events under the first platform can be realized, the same functions do not need to be developed for the second time, thereby realizing efficient program development, greatly reducing the workload of developers, and improving the online speed of the program.
In this embodiment, the difference between the two platforms is compared in advance by the comparison module 44, and then the registry for the corresponding functions under the two platforms is manufactured by the registry manufacturing module 45, so that the quick calling of rules in the registry can be realized in the specific conversion process, the conversion speed is greatly improved, in addition, the error in the conversion process can be avoided by the standardization processing of the service codes by the standardization module 43, and the conversion between the codes under different platforms can be realized faster and more accurately.
In this embodiment, the mapping module 46 is used to maintain the mapping library, so as to realize compatibility between libraries with corresponding functions under different platforms, and the framework code conversion module 47 can make the calling of functions and events cost-free, so as to realize rapid conversion of framework codes.
In this embodiment, the code is distinguished by the traversing module 49, and different conversion rules can be used for converting different kinds of codes, so that the conversion efficiency of the code under the whole first platform is higher, and the utilization efficiency of system resources is also higher.
In this embodiment, the theme matching module 48 is used to implement quick theme skin change under different platforms.
In this embodiment, by checking the files in the converted folder by the checking module 51, it can be detected whether the code under the first platform is successfully converted into the code under the second platform, so that the accuracy of conversion can be improved.
In this embodiment, by classifying the codes under the first platform and setting different conversion rules for the codes of different types, not only can the conversion of the codes under different platforms be realized, but also the conversion efficiency is higher, so that the learning cost under different platforms is reduced, the code maintenance cost is lower, the workload and the working period of developers are reduced, the online speed of the APP is also improved, and the user experience is better.
While specific embodiments of the invention have been described above, it will be appreciated by those skilled in the art that this is by way of example only, and the scope of the invention is defined by the appended claims. Various changes and modifications to these embodiments may be made by those skilled in the art without departing from the principles and spirit of the invention, but such changes and modifications fall within the scope of the invention.

Claims (10)

1. A method for converting codes between different platforms, wherein the codes comprise service codes, the method comprising:
converting the business codes under the first platform into grammar trees through a conversion tool;
batch processing is carried out on the node content in the grammar tree according to a preset conversion rule to obtain service codes under a second platform corresponding to the service codes under the first platform, and the method specifically comprises the following steps: retrieving events and functions in the service codes under the first platform through the grammar tree; retrieving conversion rules corresponding to the events and functions in the registry, and putting the retrieved conversion rules into the grammar tree at the positions corresponding to the events and functions; the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform; converting the grammar tree into service codes under a second platform through the conversion tool;
the step of searching the conversion rule corresponding to the event and the function in the registry further comprises the following steps: comparing the service codes under the first platform with the service codes under the second platform to obtain the difference points of the service codes under the two platforms; and according to the difference points, a registry is prepared, and the conversion rules in the registry comprise any one of grammar conversion, dependency injection and plug-in injection.
2. The method of transcoding between different platforms as claimed in claim 1,
the step of converting the business codes under the first platform into grammar trees by the conversion tool further comprises the following steps: carrying out standardization processing on the service codes under the first platform;
and/or the number of the groups of groups,
the type of the service code comprises any one of the following: production cycle event processing, routing processing, state processing, static file and picture resource processing, color theme processing and storage processing;
and/or the number of the groups of groups,
the conversion tool is an AST.
3. The method of transcoding between different platforms as claimed in claim 1,
the code further includes a frame code; the conversion method comprises the following steps:
defining a mapping library, wherein the mapping library comprises a preset conversion rule for converting the frame codes under the first platform into the frame codes under the second platform; converting the frame codes under the first platform into frame codes under the second platform through the mapping library;
and/or the number of the groups of groups,
after the step of converting the syntax tree into the service code under the second platform by the conversion tool, the method further includes: and changing parameters of the front-end code of the first platform so as to enable the theme of the first platform to be matched with the theme of the second platform.
4. A method of transcoding between different platforms as claimed in claim 3,
the codes under the first platform are stored in a first folder;
the codes under the second platform are stored in a second folder;
the conversion method further includes:
traversing the first folder and classifying codes in the first folder into different categories, wherein the categories comprise business codes, frame codes and common codes; the common code is the same code under the first platform and the second platform;
copying the common codes into the second folder.
5. The method for converting code between different platforms according to claim 4, wherein said converting method further comprises:
and detecting whether the conversion file corresponding to each preset path is contained in the preset path in the second folder, and if yes, converting successfully.
6. The conversion system of codes among different platforms is characterized in that the codes comprise service codes, and the conversion system comprises a grammar tree conversion module and a service code conversion module;
the grammar tree conversion module is used for converting the business codes under the first platform into grammar trees through a conversion tool;
the business code conversion module is used for carrying out batch processing on the node content in the grammar tree according to a preset conversion rule so as to obtain a business code under a second platform corresponding to the business code under the first platform;
the service code conversion module comprises: the event retrieval unit is used for retrieving events and functions in the business codes under the first platform through the grammar tree; the conversion rule searching unit is used for searching the conversion rule corresponding to the event and the function in the registry and placing the searched conversion rule into a position corresponding to the event and the function in the grammar tree; the registry comprises a preset conversion rule for converting the event and the function under the first platform to the corresponding event and function under the second platform; a code conversion unit, configured to convert, by using the conversion tool, the syntax tree into a service code under a second platform;
the conversion system further includes: the comparison module and the registry preparation module; the comparison module is used for comparing the service codes under the first platform with the service codes under the second platform to obtain the difference points of the service codes under the two platforms; the registry making module is used for making a registry according to the difference points, and the conversion rules in the registry comprise any one of grammar conversion, dependency injection and plug-in injection.
7. The system for transcoding between different platforms as claimed in claim 6,
the conversion system further includes: the standardization module is used for carrying out standardization processing on the service codes under the first platform;
and/or the number of the groups of groups,
the type of the service code comprises any one of the following: production cycle event processing, routing processing, state processing, static file and picture resource processing, color theme processing and storage processing;
and/or the number of the groups of groups,
the conversion tool is an AST.
8. The system for translating code between different platforms according to claim 6, wherein the code further comprises frame code; the conversion system includes: the mapping module and the frame code conversion module;
the mapping module is used for defining a mapping library, and the mapping library comprises a preset conversion rule for converting the frame codes under the first platform into the frame codes under the second platform; the frame code conversion module is used for converting the frame codes under the first platform into the frame codes under the second platform through the mapping library;
and/or the number of the groups of groups,
the conversion system further includes: and the theme matching module is used for changing parameters of the front-end code of the first platform so as to match the theme of the first platform with the theme of the second platform.
9. The system for transcoding between different platforms as claimed in claim 8,
the codes under the first platform are stored in a first folder;
the codes under the second platform are stored in a second folder;
the conversion system further includes: a traversal module and a common code conversion module;
the traversing module is used for traversing the first folder and classifying codes in the first folder into different categories, wherein the categories comprise business codes, frame codes and common codes; the common code is the same code under the first platform and the second platform;
the common code conversion module is used for copying the common codes into the second folder.
10. The conversion system of code between different platforms of claim 9, wherein said conversion system further comprises:
and the verification module is used for detecting whether the conversion file corresponding to each preset path is contained in the preset path in the second folder, and if yes, the conversion is successful.
CN201910380916.7A 2019-05-08 2019-05-08 Method and system for converting codes between different platforms Active CN110109681B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910380916.7A CN110109681B (en) 2019-05-08 2019-05-08 Method and system for converting codes between different platforms

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910380916.7A CN110109681B (en) 2019-05-08 2019-05-08 Method and system for converting codes between different platforms

Publications (2)

Publication Number Publication Date
CN110109681A CN110109681A (en) 2019-08-09
CN110109681B true CN110109681B (en) 2023-06-09

Family

ID=67488882

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910380916.7A Active CN110109681B (en) 2019-05-08 2019-05-08 Method and system for converting codes between different platforms

Country Status (1)

Country Link
CN (1) CN110109681B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110716746B (en) * 2019-09-03 2023-04-07 五八有限公司 Method and device for converting RN style code into applet style code
CN110704053B (en) * 2019-09-03 2023-05-23 五八有限公司 Style information processing method and device
CN111596965B (en) * 2020-07-22 2020-11-03 太平金融科技服务(上海)有限公司 Project engineering initialization method, device, computer equipment and storage medium
CN112346730B (en) * 2020-11-04 2021-08-27 星环信息科技(上海)股份有限公司 Intermediate representation generation method, computer equipment and storage medium
CN112667240A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Program code conversion method and related device
CN114417267A (en) * 2022-01-24 2022-04-29 中国电信股份有限公司 Code obfuscation method, device, electronic device and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108874396A (en) * 2018-05-31 2018-11-23 苏州蜗牛数字科技股份有限公司 The cross-compiler and Compilation Method of multi-platform multiple target language based on HLSL
CN108984163B (en) * 2018-07-13 2020-10-02 华东师范大学 IMCL model-based heterogeneous multi-platform code generation method

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100276086B1 (en) * 1997-11-12 2000-12-15 정선종 Method for generating a c++ code from lotos specitication
US7089541B2 (en) * 2001-11-30 2006-08-08 Sun Microsystems, Inc. Modular parser architecture with mini parsers
CN101841515B (en) * 2009-03-19 2014-01-08 北京理工大学 Target variable protocol data unit codec code automatic generation implementation method
CN103294666B (en) * 2013-05-28 2017-03-01 百度在线网络技术(北京)有限公司 Grammar compilation method, semantic analytic method and corresponding intrument
CN106293677B (en) * 2015-06-08 2019-09-27 阿里巴巴集团控股有限公司 A kind of code conversion method and device
CN106951404B (en) * 2017-03-22 2020-05-19 北京捷成世纪科技股份有限公司 Data format conversion method and device
CN106970820B (en) * 2017-04-26 2020-09-04 腾讯科技(深圳)有限公司 Code storage method and code storage device
CN107861728B (en) * 2017-10-25 2020-10-16 深圳四方精创资讯股份有限公司 Method and system for converting traditional program language into modern program language

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108874396A (en) * 2018-05-31 2018-11-23 苏州蜗牛数字科技股份有限公司 The cross-compiler and Compilation Method of multi-platform multiple target language based on HLSL
CN108984163B (en) * 2018-07-13 2020-10-02 华东师范大学 IMCL model-based heterogeneous multi-platform code generation method

Also Published As

Publication number Publication date
CN110109681A (en) 2019-08-09

Similar Documents

Publication Publication Date Title
CN110109681B (en) Method and system for converting codes between different platforms
US9342301B2 (en) Converting and input script to a natural language description
CN109800258B (en) Data file deployment method, device, computer equipment and storage medium
US7680668B2 (en) Method for generating a language-independent regression test script
CN113157651B (en) Method, system, equipment and medium for renaming resource files of android project in batches
CN116560683A (en) Software updating method, device, equipment and storage medium
CN106681904B (en) Method and device for analyzing coverage rate of test piece and coverage application interface
CN110362792A (en) RN file is converted to the method, apparatus and conversion equipment of small routine file
CN114416547A (en) Test case based test method
CN112274913B (en) Method and device for merging game servers, storage medium and electronic device
CN113515303A (en) Project transformation method, device and equipment
CN117112060A (en) Component library construction method and device, electronic equipment and storage medium
CN114579203B (en) Script file checking method and device, electronic equipment and storage medium
US20150347402A1 (en) System and method for enabling a client system to generate file system operations on a file system data set using a virtual namespace
US11775643B2 (en) Method and system for labeling object and generating security policy of operating system
CN112463596B (en) Test case data processing method, device and equipment and processing equipment
CN114490892A (en) Data transmission method and device based on datax
CN114528218A (en) Test program generation method, test program generation device, storage medium, and electronic device
US11327925B2 (en) Method and system for data transfer between databases
CN112463896A (en) Archive cataloging data processing method and device, computing equipment and storage medium
CN105930453A (en) Repeatability analyzing method and device
CN115562645B (en) Configuration fault prediction method based on program semantics
CN113806575B (en) Picture information acquisition method and device in warehouse splitting
CN113704122B (en) UI (user interface) automatic test system and method based on standard interface
CN113408250B (en) Project file processing method and device

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