CN109947433A - A kind of generation method of small routine, update method and device - Google Patents

A kind of generation method of small routine, update method and device Download PDF

Info

Publication number
CN109947433A
CN109947433A CN201910245927.4A CN201910245927A CN109947433A CN 109947433 A CN109947433 A CN 109947433A CN 201910245927 A CN201910245927 A CN 201910245927A CN 109947433 A CN109947433 A CN 109947433A
Authority
CN
China
Prior art keywords
code file
code
functional unit
platform
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910245927.4A
Other languages
Chinese (zh)
Inventor
杨森
张加鹏
李树亮
于孟康
范国峰
邱慧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Best Faith Racket (beijing) Mdt Infotech Ltd
Original Assignee
Best Faith Racket (beijing) Mdt Infotech 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 Best Faith Racket (beijing) Mdt Infotech Ltd filed Critical Best Faith Racket (beijing) Mdt Infotech Ltd
Priority to CN201910245927.4A priority Critical patent/CN109947433A/en
Publication of CN109947433A publication Critical patent/CN109947433A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides the generation method, update method and device of a kind of small routine.The described method includes: after the platform identification of the initial code file for getting functional unit corresponding to small routine to be generated and the target platform for running the small routine to be generated, can the initial code file to functional unit parse, and it can be according to the initial code file of functional unit obtained after parsing, it the corresponding initial code structure of initial code file and is stored in advance and identifying code structure corresponding with platform identification, to determine object code file of the functional unit in target platform, and then the small routine to be generated can be generated according to object code file.In this way, developer only needs to write a code file, the code file suitable for different platform can be generated by parsing, greatly reduce the operating pressure of developer, save the time of exploitation and the maintenance of small routine, improves the efficiency of small routine exploitation.

Description

A kind of generation method of small routine, update method and device
Technical field
This application involves computer software technical field, in particular to a kind of generation method of small routine, update method and Device.
Background technique
With the application installed in the continuous development of terminal technology and Internet technology, such as mobile phone, tablet computer terminal Program is more and more, these application programs occupy a large amount of memory of terminal, be easy to cause terminal low memory, operation slow etc. Problem.Appearance based on these problems, small routine come into being.
Small routine is that one kind does not need the i.e. workable application of downloading installation, it realizes the dream of application " within reach " Think, user is by scanning the two-dimensional code or the i.e. openable application of search key.Since small routine itself does not need peace loading and unloading It carries, therefore small routine also embodies the theory of " be finished and walk ", user does not have to be concerned about whether terminal installs too many application program The memory usage amount of terminal is greatly saved in problem.Many enterprises see the application prospect of small routine, and providing one after another can Support platform of small routine operation, such as wechat platform, top platform, Baidu's platform and fast application platform etc..However, due to not It is had differences between the code structure being applicable in platform, therefore, even for a small routine, developer is also required to Different code files is write for different platform respectively, this results in the development process of small routine to take time and effort, development efficiency Low problem.
Based on this, a kind of generation method of small routine is needed at present, for solving the exploitation of small routine in the prior art Journey takes time and effort, the low problem of development efficiency.
Summary of the invention
This application provides a kind of generation method of small routine, update method and device, can be used for solving in the prior art The development process of middle small routine takes time and effort, the low technical problem of development efficiency.
In a first aspect, the embodiment of the present application provides a kind of generation method of small routine, which comprises
It obtains the initial code file of the corresponding functional unit of small routine to be generated and runs the little Cheng to be generated The mark of the target platform of sequence;
The initial code file of the functional unit is parsed, the initial code file corresponding initial generation is obtained Code structure;
According to the initial code file of the functional unit, the corresponding initial code structure of the initial code file and It is stored in advance and identifying code structure corresponding with the platform identification, determines the functional unit in the target platform Object code file;
According to object code file of the functional unit in the target platform, the little Cheng to be generated is generated Sequence.
Using method provided by the embodiment of the present application, developer only needs to write a code file, by parsing The code file suitable for different platform can be generated, greatly reduce the operating pressure of developer, save small routine The time of exploitation and maintenance improves the efficiency of small routine exploitation.
In one possible implementation, according to the initial code file of the functional unit, initial code text It the corresponding initial code structure of part and is stored in advance and identifying code structure corresponding with the platform identification, determines the function Object code file of the energy component in the target platform, comprising:
It is stored in advance and identifying code structure corresponding with the platform identification is to the initial code file according to described Corresponding initial code structure is adjusted, and obtains object code structure of the functional unit in the target platform;
According to the initial code file of the functional unit and the object code structure, determine the functional unit in institute State the object code file in target platform.
Using code structure, then the mode of determining object code file is first adjusted, be conducive to improve object code file Accuracy.
In one possible implementation, the initial code structure is abstract syntax tree AST code structure.
In this way, needing not rely upon code in code file in resolving using AST code structure as initial code structure Context, it is applied widely.
In one possible implementation, the initial code file of the functional unit includes hypertext markup language In the code file of the code file of html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of;
The initial code file of the functional unit is parsed, the initial code file corresponding initial generation is obtained Code structure, comprising:
The code file of the html format is parsed, the corresponding AST of code file of the html format is obtained Code structure;
And the code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the code file of the JS format is parsed, obtain the corresponding AST of code file of the JS format Code structure.
Second aspect, the embodiment of the present application provide a kind of update method of small routine, the method also includes:
Obtain the corresponding update code file of functional unit and the functional group to be updated to be updated in small routine The corresponding mark for updating platform of part;
The corresponding update code file of the functional unit to be updated is parsed, the update code file is obtained Corresponding code structure;
According to the corresponding update code file of the functional unit to be updated, the corresponding code of the update code file It structure and is stored in advance and identifying code structure corresponding with the update mark of platform, determines the function to be updated Target update code file of the component in the update platform;
The component to be updated is updated in the update platform according to the target update code file.
In this way, for a small routine, on the one hand, developer can only write primary code file to be updated, The code file suitable for different platform can be generated by parsing, so as to reduce the operating pressure of developer, save The renewal time of small routine improves the efficiency of small routine update.On the other hand, even if the small routine is deposited in different platforms In different, i.e., method provided by the embodiments of the present application can also be updated respectively for different platforms, so as to Meet upgrading demand for different platform.
In one possible implementation, according to the corresponding update code file of the functional unit to be updated, institute It states and updates the corresponding code structure of code file and be stored in advance and identifying code corresponding with the update mark of platform Structure determines target update code file of the functional unit to be updated in the update platform, comprising:
It is stored in advance and identifying code structure corresponding with the update mark of platform is to the update generation according to described The corresponding code structure of code file is adjusted, and obtains target of the functional unit to be updated in the update platform more Fresh code structure;
According to the corresponding update code file of the functional unit to be updated and the target update code structure, determine Target update code file of the functional unit to be updated in the update platform.
In one possible implementation, the corresponding code structure of the update code file is abstract syntax tree AST Code structure.
In one possible implementation, the corresponding update code file of the functional unit to be updated includes super literary The generation of the code file of this markup language html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of in code file;
The corresponding update code file of the functional unit to be updated is parsed, the update code file is obtained Corresponding code structure, comprising:
The update code file of the html format is parsed, the code file for obtaining the html format is corresponding AST code structure;
And the update code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the update code file of the JS format is parsed, the code file for obtaining the JS format is corresponding AST code structure.
The third aspect, the embodiment of the present application provide a kind of generating means of small routine, and described device includes:
Acquiring unit, for obtaining initial code file and the operation of the corresponding multiple functional units of small routine to be generated The platform identification of the target platform of the small routine to be generated;
Processing unit is parsed for the initial code file to the functional unit, obtains the initial code text The corresponding initial code structure of part;And it is corresponding according to the initial code file of the functional unit, the initial code file It initial code structure and is stored in advance and identifying code structure corresponding with the platform identification, determines that the functional unit exists Object code file in the target platform;
Generation unit, for the object code file according to the functional unit in the target platform, described in generation Small routine to be generated.
In one possible implementation, the processing unit is specifically used for:
It is stored in advance and identifying code structure corresponding with the platform identification is to the initial code file according to described Corresponding initial code structure is adjusted, and obtains object code structure of the functional unit in the target platform;
According to the initial code file of the functional unit and the object code structure, determine the functional unit in institute State the object code file in target platform.
In one possible implementation, the initial code structure is abstract syntax tree AST code structure.
In one possible implementation, the initial code file of the functional unit includes hypertext markup language In the code file of the code file of html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of;
The processing unit is specifically used for:
The code file of the html format is parsed, the corresponding AST of code file of the html format is obtained Code structure;
And the code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the code file of the JS format is parsed, obtain the corresponding AST of code file of the JS format Code structure.
Fourth aspect, the embodiment of the present application provide a kind of updating device of small routine, described device further include:
Acquiring unit, for obtain the corresponding update code file of functional unit to be updated in small routine and it is described to The corresponding mark for updating platform of the functional unit of update;
Processing unit obtains institute for parsing to the corresponding update code file of the functional unit to be updated It states and updates the corresponding code structure of code file;
The processing unit, be also used to according to the corresponding update code file of the functional unit to be updated, it is described more It the corresponding code structure of fresh code file and is stored in advance and identifying code structure corresponding with the update mark of platform, Determine target update code file of the functional unit to be updated in the update platform;
Updating unit, for according to the target update code file in the update platform to the component to be updated It is updated.
In one possible implementation, the processing unit is specifically used for:
It is stored in advance and identifying code structure corresponding with the update mark of platform is to the update generation according to described The corresponding code structure of code file is adjusted, and obtains target of the functional unit to be updated in the update platform more Fresh code structure;
According to the corresponding update code file of the functional unit to be updated and the target update code structure, determine Target update code file of the functional unit to be updated in the update platform.
In one possible implementation, the corresponding code structure of the update code file is abstract syntax tree AST Code structure.
In one possible implementation, the corresponding update code file of the functional unit to be updated includes super literary The generation of the code file of this markup language html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of in code file;
The processing unit is specifically used for:
The update code file of the html format is parsed, the code file for obtaining the html format is corresponding AST code structure;
And the update code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the update code file of the JS format is parsed, the code file for obtaining the JS format is corresponding AST code structure.
Detailed description of the invention
Fig. 1 is a kind of structural schematic diagram for system that the embodiment of the present application is applicable in;
Fig. 2 is flow diagram corresponding to a kind of generation method of small routine provided by the embodiments of the present application;
Fig. 3 is a kind of generation schematic diagram of the object code file of html format provided by the embodiments of the present application;
Fig. 4 is a kind of generation schematic diagram of the object code file of CSS format provided by the embodiments of the present application;
Fig. 5 is a kind of generation schematic diagram of the object code file of JS format provided by the embodiments of the present application;
Fig. 6 is flow diagram corresponding to a kind of update method of small routine provided by the embodiments of the present application;
Fig. 7 is a kind of structural schematic diagram of the generating means of small routine provided by the embodiments of the present application;
Fig. 8 is a kind of structural schematic diagram of the updating device of small routine provided by the embodiments of the present application.
Specific embodiment
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with attached drawing to the application embodiment party Formula is described in further detail.
The possible system architecture for combining Fig. 1 to be applicable in the embodiment of the present application first below is introduced.
Referring to FIG. 1, its structural schematic diagram for illustrating a kind of applicable system of the embodiment of the present application.The system 100 may include generic resource module 101, platform catalogue module 102, processing module 103, configuration module 104 and expanded mode Block 105.
Wherein, generic resource module 101 may include two parts of custom feature component and general utility functions component, with For " excellent letter " small routine, " excellent letter certified component " can be regarded as custom feature component, and " network request fetch component " can It is general utility functions component with reading.
Platform catalogue module 102 may include top platform, wechat platform, Baidu's platform and fast application platform etc., platform Catalogue module can be previously stored with the identifying code structure of each platform, can specifically be stored in a manner of code directory.
Processing module 103 may include monitoring module 1031, collector 1032 and output module 1033.Wherein, it monitors The group obtained after the content combination that module 1031 can monitor generic resource module 101 and platform catalogue module 102 exports respectively Conjunction project monitors module 1031 when having listened to the generation of combination project or having listened to combination Xiang Mingda, can be to compiling Module 1032 sends the content listened to, and carries out code compilation by collector 1032, and collector 1032 can will compile Code afterwards is sent to output module 1033.
Configuration module 104 may include monitoring configuration, compiling configuration, outgoing route configuration and precompile configuration etc..To compile It translates and dub and is set to example, the version number of collector 1032 can be set in configuration module 104, specifically can order " npm by operation Install " obtains relevant configuration information.
Expansion module 105 is mainly used for supporting some extension functions, for example, code rule have can be set in expansion module 105 The plug-in unit of model plug-in unit (such as ESlint plug-in unit) type.
It should be noted that system 100 can use command-line tool (Command Line in specific implementation process Interface, CLI) Lai Qidong, or can also be started using other way, for example send the mode of signaling, it does not do specifically It limits.After system 100 starts, the monitoring module 1031 in processing module 103 monitors generic resource module 101 and platform mesh in real time Module 102 is recorded, (the combination project is raw by generic resource module 101 and platform catalogue module 102 if having listened to combination project At) generation or listened to combination Xiang Mingda when, can to the collector 1032 in processing module 103 send listen to Content, and code compilation is carried out by collector 1032, the code after compiling can be sent to processing by collector 1032 Output module 1033 in module 103.
Based on system architecture shown in FIG. 1, Fig. 2 illustrates a kind of life of small routine provided by the embodiments of the present application At flow diagram corresponding to method.As shown in Fig. 2, specifically comprising the following steps:
Step 201, it obtains described in initial code file and the operation of the corresponding multiple functional units of small routine to be generated The platform identification of the target platform of small routine to be generated.
Step 202, the initial code file of the functional unit is parsed, it is corresponding obtains the initial code file Initial code structure;
Step 203, according to the initial code file of the functional unit, the corresponding initial code of the initial code file It structure and is stored in advance and identifying code structure corresponding with the platform identification, determines the functional unit in the target Object code file in platform.
Step 204, the object code file according to the functional unit in the target platform generates described to be generated Small routine.
In this way, for a small routine, in the initial code for getting functional unit corresponding to small routine to be generated File and after running the mark of target platform of the small routine to be generated, can initial code file to functional unit carry out Parsing, and can be according to initial code file, initial code the file corresponding initial generation of functional unit obtained after parsing It code structure and is stored in advance and identifying code structure corresponding with platform identification, to determine functional unit in target platform Object code file, and then the small routine to be generated can be generated according to object code file.Using the embodiment of the present application institute The method of offer, developer only need to write a code file, and the generation suitable for different platform can be generated by parsing Code file, greatly reduces the operating pressure of developer, saves the time of exploitation and the maintenance of small routine, improve little Cheng The efficiency of sequence exploitation.
It should be noted that above-mentioned steps 201 to step 204 can be by Fig. 1 in conjunction with system architecture shown in fig. 1 The processing module 103 that shows executes.
Before being specifically described, the scene that the embodiment of the present application is applicable in is introduced first, which can be small Identical small routine is developed in program development in different platform;Alternatively, be also possible to small routine transplanting, i.e., it will be in some platform Small routine be transplanted in another platform;Alternatively, being also possible to the scene that other design small routines generate, do not limit specifically It is fixed.
Specifically, in step 201, the specific acquisition modes of initial code file can there are many, for example, it may be from It is obtained at developer;Alternatively, be also possible to obtain from code database;Alternatively, in the scene of small routine transplanting, What initial code file was also possible to obtain from source platform, specifically without limitation.
The acquisition modes of the mark of target platform can by a variety of, for example, it may be by developer input, Huo Zheye It can be and got from predeterminated position, specifically without limitation.
Small routine to be generated may include multiple functional units, these functional units are grouped together, and that this can be generated is small Program.Also, each functional unit has corresponding initial code file.Wherein, functional unit may include customized function It can component and general utility functions component.For example, custom feature component may include " certified component ", " view functional group Part ", " multimedia function component ", " navigation feature component " etc.;General utility functions component may include " network request fetch mould Block ", " operation order command module " etc..Correspondingly, " authentication function component " it is corresponding just to be provided with " authentication function component " Beginning code file, " view functional unit " are provided with " view functional unit " corresponding initial code file, other functional units Also it is respectively arranged with corresponding initial code file, will not enumerate herein.
Target platform can refer to the platform for running small routine to be generated, for example, if desired in wechat platform The small routine is run, then wechat platform can regard target platform as.Further, the platform identification of target platform can be used In uniquely indicating the target platform.The platform identification of target platform any one of can be in the form of letter, number, symbol etc. Or the form of any combination is presented, specifically without limitation.
In step 202, there are many analysis modes of initial code file, and a kind of possible implementation is that setting is initial Code structure is abstract syntax tree (Abstract Syntax Tree, AST) code structure, that is to say, that can be to functional group The initial code file of part is parsed, to obtain the corresponding AST code structure of initial code file.Wherein, AST is source generation The tree-shaped form of expression of the abstract syntax structure of code, in particular to the source code of programming language.In general, turning in source code It translates in compilation process, syntax analyzer is created that parsing tree.Once AST is created out, in subsequent treatment process, than Such as the semantic analysis stage, some information can be added wherein.In this way, using AST code structure as initial code structure, parsing Code Context content in code file is needed not rely upon in the process, it is applied widely.
Further, the initial code file of functional unit includes hypertext markup language (Hyper Text Markup Language, HTML) code file of format, cascading style sheets (Cascading Style Sheets, CSS) format code At least one of in the code file of file and scripting language (JavaScript, JS) format.Wherein, HTML is a kind of for creating The standard markup language of networking page, may operate on browser, be parsed by browser;CSS is that one kind is used to show HTML Or the computer language of the files pattern such as extensible markup language (eXtensible Markup Language, XML), not only may be used With statically modified web page, various scripting languages can also be cooperated dynamically to be formatted to webpage each element;JS is a kind of Regime type, weak type, the language based on prototype, built-in support type, its interpreter are referred to as JavaScript engine, are A part of browser is widely used in the scripting language of client, can use on html web page, is used to increase to html web page Dynamic function.
Based on the diversity of the corresponding language of initial code file, when being parsed to initial code file, can be directed to Different types of language is parsed respectively.Specifically, initial code file may include with Types Below: (1) only including The code file of html format;(2) only including the code file of CSS format;(3) only including the code file of JS format;(4) it wraps Include the code file of html format and the code file of CSS format;(5) include html format code file and JS format generation Code file;(6) include CSS format code file and JS format code file;(7) include html format code file, The code file of CSS format and the code file of JS format.
Above-mentioned different types of initial code file is specifically described separately below.
(1) only including the code file of html format
In the embodiment of the present application, the code file of html format can be parsed, to obtain the generation of html format The corresponding AST code structure of code file.It specifically, can be using language parser (HTML5Parser) to the generation of html format Code file is parsed, or can also be parsed using other analytical tools to the code file of html format, specifically not It limits.
Illustratively, the structure of individual node can be as follows in AST code structure corresponding to html format:
(2) only including the code file of CSS format
In the embodiment of the present application, the code file of CSS format can be parsed, to obtain the code of CSS format The corresponding AST code structure of file.Specifically, developer can according to default rule, to the code file of CSS format into Row parsing;Developer can also turn the tool of AST to parse, specifically without limitation using the code file of CSS format.
(3) only including the code file of JS format
In the embodiment of the present application, the code file of JS format can be parsed, to obtain the code text of JS format The corresponding AST code structure of part.
Specifically, compared with the code file of html format and the code file of CSS format, to the code file of JS format The slightly aobvious complexity of the process parsed.Specifically include following procedure:
Firstly, it is necessary to carry out application programming interface (Application Programming Interface, API) Conversion, it can the API of small routine to be generated is packaged, for subsequent calls.
Secondly, need to carry out the conversion of ccf layer, the conversion of ccf layer includes the conversion of life cycle function and to be generated At small routine grammer conversion.It, can be using Esprima resolver to the code of JS format when carrying out the conversion of ccf layer File is parsed, or can also be parsed using other analytical tools to the code file of JS format, is not limited specifically It is fixed.
Illustratively, the scene transplanted with reference to small routine, it is assumed that need some small routine in wechat platform " methods " functional unit is transplanted to top platform, wherein " methods " functional unit of the small routine in wechat platform Code file it is as follows:
The code text of " methods " functional unit using Esprima resolver to above-mentioned small routine in wechat platform After part is parsed, obtained AST code structure is as follows:
As can be seen that each node has one " type " from above-mentioned AST code structure, " type " of root node is "Program".Feature Dependence is in " type " of node, that is to say, that AST code structure determines the type of this node.Often A " type " has its corresponding nodal community, it is not possible to individually change.
4) include html format code file and CSS format code file
In the embodiment of the present application, can the code file respectively to the code file of html format and CSS format solve Analysis, thus the code file corresponding AST generation of the corresponding AST code structure of the code file for obtaining html format and CSS format Code structure.
(5) include html format code file and JS format code file
In the embodiment of the present application, can the code file respectively to the code file of html format and JS format solve Analysis, thus the corresponding AST code of code file of the corresponding AST code structure of the code file for obtaining html format and JS format Structure.
(6) include CSS format code file and JS format code file
In the embodiment of the present application, the code file to CSS format and the code file of JS format it can parse respectively, To obtain the corresponding AST code structure of code file of CSS format and the corresponding AST code knot of code file of JS format Structure.
(7) include the code file of html format, the code file of CSS format and JS format code file
It, can the code file to the code file of html format, CSS format and JS format respectively in the embodiment of the present application Code file parsed, thus the code of the corresponding AST code structure of the code file for obtaining html format, CSS format The corresponding AST code structure of code file of the corresponding AST code structure of file and JS format.
In other possible implementations, initial code file can also be solved by the way of canonical replacement Analysis parses initial code file with AST code structure two ways alternatively, canonical replacement can also be integrated, this field Technical staff rule of thumb can select suitable analysis mode with actual conditions, specifically without limitation.
It, can be according to the first of functional unit after the initial code file to functional unit parses in step 203 The corresponding ginseng of mark of the corresponding initial code structure of beginning code file, initial code file and pre-stored target platform Code structure is examined, to determine object code file of the functional unit in target platform.Using first adjusting code structure, then determine The mode of object code file is conducive to the accuracy for improving object code file.It specifically, can be with mesh according to the pre-stored data The corresponding identifying code structure of mark of mark platform is adjusted the corresponding initial code structure of initial code file, obtains function Object code structure of the energy component in target platform, and then can be according to the initial code file and object code of functional unit Structure determines object code file of the functional unit in target platform.
By taking the code file of html format as an example, Fig. 3 illustrates a kind of HTML lattice provided by the embodiments of the present application The generation schematic diagram of the object code file of formula.As shown in figure 3, specifically comprising the following steps:
Step 301, it is parsed using code file of the HTML5Parser language parser to the first html format.
Wherein, the code file of the first html format can refer to that any functional unit is corresponding in small routine to be generated The code file of html format.
By taking small routine develops scene as an example, the code file of the first html format can be developer for any function The code file that component is write, the code file that developer writes herein can refer to general code file, not be applicable in In the code file of some platform.
By taking small routine transplants scene as an example, the code file of the first html format can be times got from source platform The corresponding code file of one functional unit.Herein, the corresponding code file of any functional unit got from source platform can To refer to the code file for being suitable for source platform, but it is not necessarily suitable target platform.Wherein, source platform can be previously provided with Small routine to be generated.
Step 302, the corresponding first AST code structure of code file of the first html format after parsing is obtained.
By taking small routine develops scene as an example, the first AST code structure can be general code structure, not be applicable in Mr. Yu The code structure of a platform.
By taking small routine transplants scene as an example, the first AST code structure can be the code structure suitable for source platform, but not Centainly it is suitable for target platform.
Step 303, the first AST code structure is adjusted according to the corresponding identifying code structure of target platform.
By taking small routine develops scene as an example, the corresponding identifying code structure of target platform can be compared to universal code structure Between difference, then the first AST code structure is adjusted according to this difference.
It is corresponding with source platform that the corresponding identifying code structure of target platform can be compared so that small routine transplants scene as an example Then difference between identifying code structure is adjusted the first AST code structure according to this difference.
It should be noted that " difference " as described above may include that component Name, event binding, data binding etc. are more The difference of a aspect.
Step 304, the 2nd AST code structure adjusted is obtained.
Wherein, the 2nd AST code structure can refer to the object code structure suitable for target platform.
Step 305, according to the code file of the first html format and the 2nd AST code structure, reverse resolution is carried out, is obtained The code file of the second html format suitable for target platform.
Wherein, the code file of the second html format can be the object code file referred in target platform.
In order to clearly describe schematic diagram illustrated in fig. 3, it is exemplified below.
Assuming that need in the code file by html format "<view></view>" it is revised as the applicable mesh of target platform In mark code file "<div></div>", then detailed process is as follows:
It is possible, firstly, to obtain corresponding first AST language to the code file of the first html format using HTML5Parser Method structure.It is then possible to traverse each node in the first AST syntactic structure by the way of such as html.walk etc, and repair Change bookmark name (i.e. will "<view></view>" be revised as "<div></div>"), to obtain the 2nd AST syntactic structure.Most Afterwards, reverse resolution can be carried out, the 2nd HTML is obtained according to the code file and the 2nd AST syntactic structure of the first html format The code file of format.
It is similar with the code file of html format by taking the code file of CSS format as an example, as shown in figure 4, real for the application The generation schematic diagram for applying a kind of object code file of CSS format of example offer, specifically comprises the following steps:
Step 401, it is parsed using code file of the preset rules to initial CSS format, it is first after being parsed The corresponding initial AST code structure of the code file of the CSS format of beginning.
Step 402, initial AST code structure is adjusted according to the corresponding identifying code structure of target platform, is obtained To target AST code structure.
Step 403, according to the code file of initial CSS format and target AST code structure, reverse resolution is carried out, is obtained To the code file for the target CSS format for being suitable for target platform.
By taking the code file of JS format as an example, Fig. 5 illustrates a kind of JS format provided by the embodiments of the present application The generation schematic diagram of object code file.As shown in figure 5, specifically comprising the following steps:
Step 501, the API of small routine to be generated is packaged.
Step 502, it is parsed using code file of the Esprima tool to initial JS format, obtains JS format The corresponding AST code structure of code file.
Step 503, AST code structure is adjusted according to target platform corresponding identifying code structure, obtains target AST code structure.
Step 504, according to the code file of initial JS format and target AST code structure, reverse resolution is carried out, is obtained The code file of JS format suitable for target platform.
During in view of small routine operation, with the extension of runing time, the problem of version updating can be faced, because This, is based on same inventive concept, and Fig. 6 illustrates a kind of update method institute of small routine provided by the embodiments of the present application Corresponding flow diagram, as shown in fig. 6, specifically comprising the following steps:
Step 601, the corresponding update code file of functional unit to be updated and function to be updated in small routine are obtained It can the corresponding mark for updating platform of component.
Wherein, functional unit to be updated can refer to the functional unit that needs update.For example, being needed in some small routine It updates " certified component ", i.e., " certified component " can be functional unit to be updated.
The platform that needs update can be referred to by updating platform.For example, some small routine operated in platform A needs to update " certified component ", i.e. platform A are to update platform.It should be noted that if the small routine is run in platform B simultaneously, and flat The small routine is not necessarily to update " certified component " in platform B, then platform B and non-update platform.
Step 602, the corresponding update code file of functional unit to be updated is parsed, obtains updating code file Corresponding code structure.
Step 603, according to the corresponding update code file of functional unit to be updated, the corresponding code of update code file Structure and be stored in advance and with update the corresponding identifying code structure of the mark of platform, determine functional unit to be updated more Target update code file in new platform.
Step 604, component to be updated is updated in updating platform according to target update code file.
It should be noted that above-mentioned steps 602 are into step 603, the parsing to code file is updated, and determine target The process for updating code file can be with reference to method described in above step 202, and details are not described herein again.
In this way, for a small routine, on the one hand, developer can only write primary code file to be updated, The code file suitable for different platform can be generated by parsing, so as to reduce the operating pressure of developer, save The renewal time of small routine improves the efficiency of small routine update.On the other hand, even if the small routine is deposited in different platforms In different, for example there is functional unit a in platform A, but does not have functional unit a in platform B, then, in function When component a upgrades demand, it targetedly can only update the functional unit a in platform A, i.e., it is provided by the embodiments of the present application Method can also be updated respectively for different platforms, so as to meet upgrading demand for different platform.
Following is the application Installation practice, can be used for executing the application embodiment of the method.It is real for the application device Undisclosed details in example is applied, the application embodiment of the method is please referred to.
Fig. 7 illustrates a kind of structural schematic diagram of the generating means of small routine provided by the embodiments of the present application.Such as Shown in Fig. 7, which has the function of realizing that the generation method of above-mentioned small routine, the function can be by hardware realizations, can also To execute corresponding software realization by hardware.The apparatus may include: acquiring unit 701, processing unit 702 and generation unit 703。
Acquiring unit 701, for obtain the corresponding multiple functional units of small routine to be generated initial code file and Run the platform identification of the target platform of the small routine to be generated;
Processing unit 702 parses for the initial code file to the functional unit, obtains the initial code The corresponding initial code structure of file;And it is corresponding according to the initial code file of the functional unit, the initial code file Initial code structure and be stored in advance and identifying code structure corresponding with the platform identification, determine the functional unit Object code file in the target platform;
Generation unit 703 generates institute for the object code file according to the functional unit in the target platform State small routine to be generated.
In one possible implementation, the processing unit 702 is specifically used for:
It is stored in advance and identifying code structure corresponding with the platform identification is to the initial code file according to described Corresponding initial code structure is adjusted, and obtains object code structure of the functional unit in the target platform;
According to the initial code file of the functional unit and the object code structure, determine the functional unit in institute State the object code file in target platform.
In one possible implementation, the initial code structure is abstract syntax tree AST code structure.
In one possible implementation, the initial code file of the functional unit includes hypertext markup language In the code file of the code file of html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of;
The processing unit 702 is specifically used for:
The code file of the html format is parsed, and the code file corresponding AST generation of the html format is obtained Code structure;
And the code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the code file of the JS format is parsed, obtain the corresponding AST of code file of the JS format Code structure.
Fig. 8 illustrates a kind of structural schematic diagram of the updating device of small routine provided by the embodiments of the present application.Such as Shown in Fig. 8, which has the function of realizing that the update method of above-mentioned small routine, the function can be by hardware realizations, can also To execute corresponding software realization by hardware.The apparatus may include: acquiring unit 801, processing unit 802 and updating unit 803。
Acquiring unit 801, for obtaining the corresponding update code file of functional unit to be updated in small routine and institute State the corresponding mark for updating platform of functional unit to be updated;
Processing unit 802 is obtained for parsing to the corresponding update code file of the functional unit to be updated The corresponding code structure of the update code file;
The processing unit 802 is also used to according to the corresponding update code file of the functional unit to be updated, described It updates the corresponding code structure of code file and is stored in advance and identifying code knot corresponding with the update mark of platform Structure determines target update code file of the functional unit to be updated in the update platform;
Updating unit 803, for according to the target update code file in the update platform to described to be updated Component is updated.
In one possible implementation, the processing unit 802 is specifically used for:
It is stored in advance and identifying code structure corresponding with the update mark of platform is to the update generation according to described The corresponding code structure of code file is adjusted, and obtains target of the functional unit to be updated in the update platform more Fresh code structure;
According to the corresponding update code file of the functional unit to be updated and the target update code structure, determine Target update code file of the functional unit to be updated in the update platform.
In one possible implementation, the corresponding code structure of the update code file is abstract syntax tree AST Code structure.
In one possible implementation, the corresponding update code file of the functional unit to be updated includes super literary The generation of the code file of this markup language html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of in code file;
The processing unit 802 is specifically used for:
The update code file of the html format is parsed, the code file for obtaining the html format is corresponding AST code structure;
And the update code file of the CSS format is parsed, the code file for obtaining the CSS format is corresponding AST code structure;
And the update code file of the JS format is parsed, the code file for obtaining the JS format is corresponding AST code structure.
In the exemplary embodiment, a kind of computer readable storage medium is additionally provided, is stored in the storage medium Computer program or intelligent contract, the computer program or intelligent contract are loaded and executed by nodes to realize above-described embodiment The transaction methods of offer.Optionally, above-mentioned computer readable storage medium can be read-only memory (Read- Only Memory, ROM), random access memory (Random Access Memory, RAM), CD-ROM, tape, floppy disk and Optical data storage devices etc..
It is required that those skilled in the art can be understood that the technology in the embodiment of the present application can add by software The mode of general hardware platform realize.Based on this understanding, the technical solution in the embodiment of the present application substantially or Say that the part that contributes to existing technology can be embodied in the form of software products, which can deposit Storage is in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are used so that computer equipment (can be with It is personal computer, server or the network equipment etc.) execute certain part institutes of each embodiment of the application or embodiment The method stated.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the disclosure Its embodiment.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes or Person's adaptive change follows the general principles of this disclosure and including the undocumented common knowledge in the art of the disclosure Or conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the disclosure are by following Claim is pointed out.
It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and And various modifications and changes may be made without departing from the scope thereof.The scope of the present disclosure is only limited by the accompanying claims.

Claims (10)

1. a kind of generation method of small routine, which is characterized in that the described method includes:
It obtains the initial code file of functional unit corresponding to small routine to be generated and runs the small routine to be generated The platform identification of target platform;
The initial code file of the functional unit is parsed, the corresponding initial code knot of the initial code file is obtained Structure;
According to the initial code file of the functional unit, the corresponding initial code structure of the initial code file and in advance Storage and identifying code structure corresponding with the platform identification, determine target of the functional unit in the target platform Code file;
According to object code file of the functional unit in the target platform, the small routine to be generated is generated.
2. the method according to claim 1, wherein according to the initial code file of the functional unit, described It the corresponding initial code structure of initial code file and is stored in advance and identifying code structure corresponding with the platform identification, Determine object code file of the functional unit in the target platform, comprising:
It is stored in advance and identifying code structure corresponding with the platform identification is corresponding to the initial code file according to described Initial code structure be adjusted, obtain object code structure of the functional unit in the target platform;
According to the initial code file of the functional unit and the object code structure, determine the functional unit in the mesh Mark the object code file in platform.
3. the method according to claim 1, wherein the initial code structure is abstract syntax tree AST code Structure.
4. according to the method described in claim 3, it is characterized in that, the initial code file of the functional unit includes hypertext The code of the code file of markup language html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of in file;
The initial code file of the functional unit is parsed, the corresponding initial code knot of the initial code file is obtained Structure, comprising:
The code file of the html format is parsed, the corresponding AST code of code file of the html format is obtained Structure;
And the code file of the CSS format is parsed, obtain the code file corresponding AST generation of the CSS format Code structure;
And the code file of the JS format is parsed, obtain the corresponding AST code of code file of the JS format Structure.
5. a kind of update method of small routine, which is characterized in that the method also includes:
Obtain the corresponding update code file of functional unit to be updated and the functional unit pair to be updated in small routine The mark for the update platform answered;
The corresponding update code file of the functional unit to be updated is parsed, it is corresponding to obtain the update code file Code structure;
According to the corresponding update code file of the functional unit to be updated, the corresponding code structure of the update code file And be stored in advance and identifying code structure corresponding with the update mark of platform, determine the functional unit to be updated Target update code file in the update platform;
The component to be updated is updated in the update platform according to the target update code file.
6. a kind of generating means of small routine, which is characterized in that described device includes:
Acquiring unit, for obtaining the initial code file of the corresponding functional unit of small routine to be generated and running described to be generated At small routine target platform platform identification;
Processing unit is parsed for the initial code file to the functional unit, obtains the initial code file pair The initial code structure answered;And it is corresponding initial according to the initial code file of the functional unit, the initial code file It code structure and is stored in advance and identifying code structure corresponding with the platform identification, determines the functional unit described Object code file in target platform;
Generation unit generates described to be generated for the object code file according to the functional unit in the target platform At small routine.
7. device according to claim 6, which is characterized in that the processing unit is specifically used for:
It is stored in advance and identifying code structure corresponding with the platform identification is corresponding to the initial code file according to described Initial code structure be adjusted, obtain object code structure of the functional unit in the target platform;
According to the initial code file of the functional unit and the object code structure, determine the functional unit in the mesh Mark the object code file in platform.
8. device according to claim 6, which is characterized in that the initial code structure is abstract syntax tree AST code Structure.
9. device according to claim 8, which is characterized in that the initial code file of the functional unit includes hypertext The code of the code file of markup language html format, the code file of cascading style sheets CSS format and scripting language JS format At least one of in file;
The processing unit is specifically used for:
The code file of the html format is parsed, the corresponding AST code of code file of the html format is obtained Structure;
And the code file of the CSS format is parsed, obtain the code file corresponding AST generation of the CSS format Code structure;
And the code file of the JS format is parsed, obtain the corresponding AST code of code file of the JS format Structure.
10. a kind of updating device of small routine, which is characterized in that described device further include:
Acquiring unit, for obtaining the corresponding update code file of functional unit to be updated in small routine and described to be updated Functional unit it is corresponding update platform mark;
Processing unit, for being parsed to the corresponding update code file of the functional unit to be updated, obtain it is described more The corresponding code structure of fresh code file;
The processing unit is also used to according to the corresponding update code file of the functional unit to be updated, the update generation It the corresponding code structure of code file and is stored in advance and identifying code structure corresponding with the updates mark of platform, determination Target update code file of the functional unit to be updated in the update platform;
Updating unit, for being carried out in the update platform to the component to be updated according to the target update code file It updates.
CN201910245927.4A 2019-03-28 2019-03-28 A kind of generation method of small routine, update method and device Pending CN109947433A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910245927.4A CN109947433A (en) 2019-03-28 2019-03-28 A kind of generation method of small routine, update method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910245927.4A CN109947433A (en) 2019-03-28 2019-03-28 A kind of generation method of small routine, update method and device

Publications (1)

Publication Number Publication Date
CN109947433A true CN109947433A (en) 2019-06-28

Family

ID=67012647

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910245927.4A Pending CN109947433A (en) 2019-03-28 2019-03-28 A kind of generation method of small routine, update method and device

Country Status (1)

Country Link
CN (1) CN109947433A (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110347387A (en) * 2019-07-09 2019-10-18 湖南微谷云科技有限公司 Mobile terminal light application creation method and system
CN110704053A (en) * 2019-09-03 2020-01-17 五八有限公司 Method and device for processing style information
CN110780874A (en) * 2019-10-25 2020-02-11 北京百度网讯科技有限公司 Method and apparatus for generating information
CN110888645A (en) * 2019-10-12 2020-03-17 贝壳技术有限公司 Method, device and storage medium for converting into small program
CN111045707A (en) * 2019-12-20 2020-04-21 深圳市珍爱捷云信息技术有限公司 Method and device for updating small program, computer equipment and storage medium
CN111338633A (en) * 2020-02-10 2020-06-26 Oppo(重庆)智能科技有限公司 Installation-free file generation method and device and electronic equipment
CN111367527A (en) * 2020-02-18 2020-07-03 北京字节跳动网络技术有限公司 Language processing method, device, medium and electronic equipment
CN111381825A (en) * 2020-03-06 2020-07-07 北京五八信息技术有限公司 Method and device for generating small program
CN111796829A (en) * 2020-05-19 2020-10-20 北京三快在线科技有限公司 Applet updating method and device, electronic equipment and computer readable storage medium
CN113010157A (en) * 2021-03-08 2021-06-22 北京达佳互联信息技术有限公司 Code generation method and device
WO2021143371A1 (en) * 2020-01-16 2021-07-22 支付宝(杭州)信息技术有限公司 Method, apparatus, and device for generating applet page
CN113672224A (en) * 2021-08-20 2021-11-19 上海哔哩哔哩科技有限公司 Method and device for generating small program page code and computer equipment
CN114625379A (en) * 2022-05-16 2022-06-14 杭州兑吧网络科技有限公司 H5 project source code generation method and H5 project source code development system
WO2023035563A1 (en) * 2021-09-10 2023-03-16 中国银联股份有限公司 Applet cross-application migration method, device, terminal, system and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015184756A (en) * 2014-03-20 2015-10-22 東芝テック株式会社 Program converter and conversion processing program
CN108268262A (en) * 2017-12-27 2018-07-10 广东耐思尼克信息技术有限公司 Realize the method, apparatus and system that HTML is converted to wechat small routine
CN108664248A (en) * 2018-05-14 2018-10-16 北京汉能光伏投资有限公司 A kind of generation method and device of wechat small routine
CN109032691A (en) * 2018-06-25 2018-12-18 腾讯科技(深圳)有限公司 A kind of small routine operation method, device and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015184756A (en) * 2014-03-20 2015-10-22 東芝テック株式会社 Program converter and conversion processing program
CN108268262A (en) * 2017-12-27 2018-07-10 广东耐思尼克信息技术有限公司 Realize the method, apparatus and system that HTML is converted to wechat small routine
CN108664248A (en) * 2018-05-14 2018-10-16 北京汉能光伏投资有限公司 A kind of generation method and device of wechat small routine
CN109032691A (en) * 2018-06-25 2018-12-18 腾讯科技(深圳)有限公司 A kind of small routine operation method, device and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
WEB手艺人: "AST—小程序间的互转", 《HTTPS://MP.WEIXIN.QQ.COM/S/RCTTEAYWQ-HKRFNUYFEU7W》 *

Cited By (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110347387A (en) * 2019-07-09 2019-10-18 湖南微谷云科技有限公司 Mobile terminal light application creation method and system
CN110704053A (en) * 2019-09-03 2020-01-17 五八有限公司 Method and device for processing style information
CN110704053B (en) * 2019-09-03 2023-05-23 五八有限公司 Style information processing method and device
CN110888645A (en) * 2019-10-12 2020-03-17 贝壳技术有限公司 Method, device and storage medium for converting into small program
CN110780874A (en) * 2019-10-25 2020-02-11 北京百度网讯科技有限公司 Method and apparatus for generating information
CN111045707A (en) * 2019-12-20 2020-04-21 深圳市珍爱捷云信息技术有限公司 Method and device for updating small program, computer equipment and storage medium
CN111045707B (en) * 2019-12-20 2024-04-09 深圳市珍爱捷云信息技术有限公司 Method, apparatus, computer device and storage medium for updating applet
WO2021143371A1 (en) * 2020-01-16 2021-07-22 支付宝(杭州)信息技术有限公司 Method, apparatus, and device for generating applet page
CN111338633A (en) * 2020-02-10 2020-06-26 Oppo(重庆)智能科技有限公司 Installation-free file generation method and device and electronic equipment
CN111338633B (en) * 2020-02-10 2023-08-15 Oppo(重庆)智能科技有限公司 Method and device for generating installation-free file and electronic 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
CN112965719A (en) * 2020-03-06 2021-06-15 北京五八信息技术有限公司 Method and device for generating small program
CN113110825A (en) * 2020-03-06 2021-07-13 北京五八信息技术有限公司 Method and device for converting interfaces of small programs
CN113110825B (en) * 2020-03-06 2022-06-03 北京五八信息技术有限公司 Method and device for converting interfaces of small programs
CN111381825B (en) * 2020-03-06 2021-04-09 北京五八信息技术有限公司 Method and device for generating small program
CN111381825A (en) * 2020-03-06 2020-07-07 北京五八信息技术有限公司 Method and device for generating small program
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
CN113010157A (en) * 2021-03-08 2021-06-22 北京达佳互联信息技术有限公司 Code generation method and device
CN113672224A (en) * 2021-08-20 2021-11-19 上海哔哩哔哩科技有限公司 Method and device for generating small program page code and computer equipment
WO2023035563A1 (en) * 2021-09-10 2023-03-16 中国银联股份有限公司 Applet cross-application migration method, device, terminal, system and storage medium
CN114625379A (en) * 2022-05-16 2022-06-14 杭州兑吧网络科技有限公司 H5 project source code generation method and H5 project source code development system

Similar Documents

Publication Publication Date Title
CN109947433A (en) A kind of generation method of small routine, update method and device
US8949792B2 (en) Methods and systems for data service development
JP5204070B2 (en) Method for generating a tool for merging customizations made to a first version of a software product when migrating to a second version of the software product, a computer usable medium and a data processing system
US20040158820A1 (en) System for generating an application framework and components
US8726231B2 (en) Support for heterogeneous database artifacts in a single project
CN102566984B (en) Method and device for configuring parameters
Ying et al. Refactoring legacy AJAX applications to improve the efficiency of the data exchange component
WO2012034440A1 (en) Method and device for generating database upgrading script
US7908598B2 (en) Automated creation of model and view code
US20070050707A1 (en) Enablement of multiple schema management and versioning for application-specific xml parsers
JP2007249785A (en) Compile program, production method for virtual database remote access program and remote access method for virtual database
CN108920496B (en) Rendering method and device
US20090013336A1 (en) Method and system for building compound extensible ajax applications
CN103744680A (en) Method and device for business process processing
CN101499063A (en) Tracing-based database schema evolution method and system
EP2557496A1 (en) Silent migration of business process binaries
CN103473034A (en) Method and device for dynamically publishing Web service
Pinandito et al. Framework design for modular web-based application using model-collectionservice-controller-presenter (mccp) pattern
US7716653B2 (en) Configurable importers and resource writers for converting data into another format
US20070050706A1 (en) Method of xml transformation and presentation utilizing an application-specific parser
US20040230587A1 (en) System and method for specifying application services and distributing them across multiple processors using XML
US7266814B2 (en) Namespace based function invocation
Zhang et al. Research of web front-end engineering solution in public cultural service project
Ping et al. Refactoring web sites to the controller-centric architecture
CN111857710A (en) Method and device for developing Eclipse plug-in based on embedded chromium

Legal Events

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

Application publication date: 20190628