Wechat applet source code generation method based on WXCL and storage medium
Generating WeChat applet source code through WXCL language solves the problems of complexity and high learning threshold for WeChat applet development, achieves fast and low-cost development efficiency, and meets the development needs of ordinary users.
Patent Information
- Application Number
- CN202411803976.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-01-07
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The development of WeChat mini-programs is complex, requiring developers to have multi-field technical knowledge and high learning thresholds, which leads to high development costs and long-term consumption, making it difficult to meet the rapid development needs of ordinary users.
Using the source code generation method of WeChat applets based on WXCL, the WXCL language is set, including the lexical grammar definition, lexical analyzer, grammar analyzer and translation program, combined with the back-end code translation system, the WXCL language is translated into WeChat applets in real time Program source code, reducing development threshold and learning costs.
It realizes the rapid construction and development of WeChat applets, lowers the writing threshold, and improves development efficiency. Users can customize styles and functions through simple XML syntax to generate cost-effective WeChat applet source code.
Smart Images

Figure CN119271212A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automatic generation of WeChat applet source code, and in particular to a WeChat applet source code generation method and storage medium based on WXCL. Background Art
[0002] As an innovative technical solution, WeChat Mini Programs have penetrated into many industries and fields, demonstrating their wide application potential and practical value, and providing users with a convenient service experience. However, the development of WeChat Mini Programs involves front-end technologies such as HTML, CSS, and JavaScript, as well as server-side programming skills. In addition to programming language skills, the development of WeChat Mini Programs often requires designers to design the front-end, which is a tedious, time-consuming and very costly task. This requires developers to have cross-domain technical knowledge and a high learning threshold to ensure the stable operation of the Mini Programs and an excellent user experience.
[0003] The following is an introduction to the main components of the existing WeChat applet source code: Project configuration file (app.json); This is the global configuration file of the mini program, which defines the global settings of the mini program, including page path, navigation bar style, window performance, network timeout setting, bottom tab, etc. This file is the entry point of the mini program, which tells the mini program framework how to start and run.
[0004] Page configuration file (xxx.json); Each mini program page can have a corresponding configuration file, which is used to set the window performance of a single page, such as navigation bar title, navigation bar color, navigation bar button, etc. These configuration files allow developers to customize different appearances and behaviors for each page.
[0005] WXML (WeiXin Markup Language); WXML is the hypertext markup language of WeChat Mini Programs, which is used to define the structure of the page. The file suffix is .wxml. It is similar to HTML, but is designed specifically for Mini Programs and contains some Mini Program-specific tags such as swiper and icon. WXML allows developers to define the layout and elements of the page, such as text, images, lists, etc.
[0006] WXSS (WeiXin Style Sheets); WXSS is the style sheet language of WeChat Mini Programs, similar to CSS, used to describe the style of a page, with a file suffix of .wxss. It allows developers to set style attributes such as color, size, and layout of elements. WXSS also supports some style attributes unique to Mini Programs to better meet the layout requirements of Mini Programs.
[0007] JavaScript: JavaScript is the main programming language for mini programs, used to process user interactions, data requests, page logic, etc., and the file suffix is .js. The JavaScript code for mini programs is similar to the JavaScript code for web pages, but there are some APIs unique to mini programs, such as page navigation, data binding, network requests, etc. In addition, the local data corresponding to the WeChat mini program page is stored in the AppData object. Developers can use the API provided by the mini program to store and read local data, which helps improve the response speed and user experience of the mini program.
[0008] WXS (WeiXin Script); WXS is a scripting language for WeChat Mini Programs. It is written in .wxml files and runs in the view layer of the Mini Program to process the logic of the view layer. WXS cannot directly operate the data layer, but can operate the data of the view layer. It allows developers to implement some complex view operations and data processing without touching JavaScript.
[0009] Pictures, media static files: static resource files such as pictures, audio, and video used in mini programs are usually placed in a specific directory of the project. These resource files are used to enhance the visual effects and user experience of the mini program.
[0010] Custom components: Mini programs support custom components, which allow developers to create reusable code modules. Custom components can contain WXML, WXSS, JavaScript, and JSON configuration files, allowing developers to encapsulate complex interfaces and logic, and then reuse them in different pages.
[0011] Cloud development: WeChat Mini Programs provide cloud development capabilities, which is a backend service platform that allows developers to store data, run code, etc. in WeChat's cloud environment. This makes it easier for developers to implement functions such as data storage, user authentication, and server-side logic.
[0012] Backend services: Although WeChat Mini Programs are mainly run on the client side, many functions require the support of backend services, such as database operations, user authentication, payment processing, etc. Developers can build backend services themselves or use third-party services.
[0013] sitemap.json; This is a configuration file that is used to define the inclusion of Mini Program pages and affect search results. Through this file, developers can control whether Mini Program pages are included by search engines and how they are included. Summary of the invention
[0014] The present invention proposes a cost-effective method, device and storage medium for automatically generating WeChat applet source code based on formal customization of simple user needs, that is, a method for customizing the style and function of WeChat applet in an XML grammar-based language (WeChat Customization Language, WXCL) that is easy to learn and write, and translating it into deployable WeChat applet source code through the technical means proposed by the present invention.
[0015] To achieve the above object, the present invention adopts the following technical solutions: A WXCL-based WeChat applet source code generation method, based on the WeChat applet platform, sets the intermediate code WXCL language, including setting lexical and grammatical definition formulas, lexical analyzers, grammatical analyzers, and a translation program from the WXCL language to the target code, for generating the final WeChat applet code; It also includes a backend code translation system, which deploys the WXCL language translation software on the server background to translate the WXCL language into WeChat applet source code in real time and send it to users.
[0016] Further, the WXCL language specification explains as follows: The content in '' is a terminal symbol, and the analyzer can translate it when it reads the terminal symbol; =>The content after is gui, which corresponds to the wxss style sheet content, and the content is enclosed by "". The symbols on the left and right sides of '|' are in parallel relationship and can appear at the same time; 'XXXXXX' and 'string' represent paths; ()* means the number of times the content in the brackets appears is greater than or equal to 0; ()+ means the number of times the content in the brackets appears is greater than or equal to 1; ()? Indicates that the number of times the content in the brackets appears is 0 or 1; ';' is used to separate styles within "" and to separate components in other places.
[0017] Furthermore, the meanings of the keywords in the intermediate code WXCL are as follows: Project is the general term for the entire project; content is used to describe the content of the page; pageList is used to define the sequence number of the page; Describe is used to summarize the page content; Component contains all the components required by WeChat Mini Program; Swiper is used to store pictures for carousel; nevigator is used for page navigation jump; Image is a picture component; list is a list component; Input is an input box component; function indicates the button function; pageLocation indicates the page path. Further, the steps include: S1. First, clarify the final style, page and corresponding functions of the WeChat Mini Program; S2. Modify the WXCL language sample document so that the final WXCL document can accurately describe the style, page and corresponding functions of the final WeChat applet; S3, check the correctness of the generated WXCL code, and submit the WXCL code to the WXCL language lexical analyzer; S4, the lexical analyzer of the WXCL language checks whether there is a lexical error in the input WXCL code; if there is a lexical error, it returns to step S2, otherwise the token stream after lexical analysis is input to step S5, where token is a meaningful word unit in the WXCL language code; S5. The syntax analyzer of the WXCL language performs syntax analysis on the input token stream; if there is a syntax error, it will return to step S2 for the user to further modify, otherwise it will generate a syntax tree corresponding to the WXCL code; S6. The WXCL language traverser traverses the syntax tree of the WXCL code and calls the WXCL language listener at each node for translation, and finally translates the corresponding WeChat applet source code.
[0018] Furthermore, the specific steps of the syntax analyzer of the WXCL language are as follows: first read the token stream, perform top-down syntax analysis on the token symbols therein according to the WXCL syntax definition, verify the syntax correctness and build a data structure called a syntax tree, in which the root node of each subtree uses an abstract name to name the contained elements, that is, the root node of the subtree corresponds to the name of the grammar rule, and the leaf nodes of the tree are symbols or lexical symbols in the sentence.
[0019] Furthermore, the traversal step in step S6 includes: The traverser performs a pre-order traversal of the syntax tree, and calls the entry callback function and exit callback function of the corresponding node in the listener respectively when entering and exiting each node; the order of calling the entry callback function of each node is the pre-order traversal, and the exit callback function is the post-order traversal; The listener is specifically a collection of callback functions, which is called by the traverser when the syntax tree is traversed and translated. It corresponds the WXCL language and the WeChat applet source code, and uses a judgment loop to write the callback function of each node so that it can be accurately translated from WXCL to the WeChat applet source code.
[0020] Furthermore, after step S6, the following steps are further included: S7. After obtaining the source code of the WeChat mini program, you can import the obtained project into the WeChat developer tool and preview the final effect in real time. You can directly modify the source code and then upload the code to the WeChat public platform. After filing, filing review, and code review, the mini program can be published on the WeChat public platform.
[0021] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the above method.
[0022] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.
[0023] It can be seen from the above technical scheme that a method for generating source code of WeChat applet based on WXCL of the present invention adopts the intermediate code WXCL that can describe the structure of WeChat applet, including the lexical and grammatical definition of the language, lexical analyzer, grammatical analyzer and translation program from WXCL to target code, which can facilitate the generation of the final WeChat applet code; a set of BS system, access to the pre-trained large model for generating WXCL code, realizes the ideal solution of obtaining users through human-computer interaction, and also includes a back-end code translation system, deploys the translation software of WXCL in the server background, and translates WXCL into WeChat applet source code in real time and sends it to users. Its high cost performance is reflected in the extremely low learning cost, extremely short time and good effect of users, thereby solving the problems of complex structure, high learning threshold and high time cost of WeChat applet development for ordinary users.
[0024] The beneficial effects of the present invention include: 1. Since the WXCL language code is highly generalized to the WeChat applet code, developers can build and develop WeChat applet more quickly by learning the WXCL document, which greatly reduces the threshold for writing applet.
[0025] 2. The present invention has undergone targeted lexical and grammatical analyzer construction and optimization, and more accurately translates the WXCL language into the WeChat applet source code, which is less prone to errors than directly using a large model to generate a WeChat applet source code.
[0026] 3. The present invention utilizes the front-end human-computer interaction function to conduct targeted training on the WXCL language, which can enable the large model to obtain user requirements more accurately and generate ideal code, and can directly modify the WXCL language to change the final generated style, making the development process more intuitive. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a flowchart of an embodiment of the present invention; Figure 2 The WXCL language lexical analyzer function of the embodiment of the present invention; Figure 3 The grammar analysis tree obtained by grammar analysis of the WXCL code of example code 2; Figure 4 This is the final effect displayed on the mobile terminal device after deploying the WeChat applet source code obtained by translating the WXCL code in Example Code 2. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments.
[0029] A WeChat applet source code generation method of an embodiment of the present invention adopts a strategy based on WXCL (WeiXinCustomization Language). Specifically, a WeChat applet source code generation method based on WXCL of the present invention adopts an intermediate code WXCL that can describe the structure of the WeChat applet, including the lexical and grammatical definition of the language, a lexical analyzer, a grammatical analyzer, and a translation program from WXCL to the target code, which can facilitate the generation of the final WeChat applet code; a set of BS systems, connected to a pre-trained large model for generating WXCL code, realizes the ideal solution for users through human-computer interaction, and also includes a back-end code translation system, deploying the WXCL translation software in the server background to translate WXCL into WeChat applet source code in real time and send it to users.
[0030] The specific implementation method is explained in detail below. Figure 1 : S1. Users of the present invention clarify the final style, page and corresponding functions of the WeChat applet through discussions and other forms.
[0031] S2. The user of the present invention modifies the WXCL sample document so that the final WXCL document can accurately describe the style, page and corresponding functions of the final WeChat applet. If there are any unclear parts, return to S1 for further discussion and other activities.
[0032] The following code is a sample document of WXCL; Code 1: grammar wxcl; options { language = Python3;} project: 'content' ':' 'style' '<' Theme '>' pageList ; pageList: page+ ; page:'page' Number ':' Describe'{' pageContent '}' ; pageContent: (component)+; component: (swiper / / component type | text | image | button | list | input | nevigator) ('=>' gui )? ';' ; swiper: 'swiper' '[' ablum ']' ; ablum: ( '"' string '"' ';' )+ ; text: 'text' '-' '"'string '"' ; image: 'image' '-' '"' string '"' ; button: 'button' '-' function ; function: 'navigation' '<' pageLocation '>' | 'LogIn' | 'Pay' | 'LogOut' ; pageLocation: 'page' Number ; / / page location list: 'list' '[' pageContent ']' ; input: 'input' '-' InputType ; nevigator: 'nevigator' '<' Describe '>' '[' pageContent ']'; Code 1 is a partial WXCL language definition (component and page location definition) of an embodiment of the present invention.
[0033] The WXCL language specification in the figure is explained as follows: The content in '' is a terminal symbol, and the analyzer can translate it when it reads the terminal symbol; =>The content after is gui, which corresponds to the wxss style sheet content, and the content is enclosed by "". The symbols on the left and right sides of '|' are in parallel relationship and can appear at the same time; 'XXXXXX' and 'string' represent paths; ()* means the number of times the content in the brackets appears is greater than or equal to 0; ()+ means the number of times the content in the brackets appears is greater than or equal to 1; ()? Indicates that the number of times the content in the brackets appears is 0 or 1; ';' is used to separate styles within "" and to separate components in other places.
[0034] In addition, the key words have the following meanings: Project is the general term for the entire project; content is used to describe the content of the page; pageList is used to define the sequence number of the page; Describe is used to summarize the page content; Component includes various components required by WeChat applet, etc. Swiper is used to store pictures for carousel; Navigator is used to navigate the page; Image is a picture component; list is a list component; Input is an input box component; function indicates the button function; pageLocation indicates the page path; S3. The user of the present invention checks the correctness of the generated WXCL code and submits the WXCL code to the WXCL language lexical analyzer.
[0035] S4, the lexical analyzer of the WXCL language checks whether there is a lexical error in the input WXCL code. If there is a lexical error, it will return to S2, otherwise the token stream after lexical analysis will be input to step S5. Here, token is a meaningful word unit in the WXCL code.
[0036] The lexical analyzer of the WXCL language can be constructed based on the state transition diagram, or it can be generated using existing lexical analyzer automatic generation tools, such as ANTLR. The functional diagram of the lexical analyzer is shown in the figure. Figure 2 The lexical analyzer of WXCL language can process WXCL language code and generate meaningful lexical units, as shown in Table 1.
[0037] Table 1 Token types and storage methods obtained by the WXCL language lexical analyzer
[0038] S5. The syntax analyzer of the WXCL language performs syntax analysis on the input token stream. If there is a syntax error, it will return to step S2 for further modification by the user, otherwise it will generate a syntax tree corresponding to the WXCL code.
[0039] The specific steps of the syntax analyzer of the WXCL language are as follows: first read the token stream, perform top-down syntax analysis on the token symbols according to the WXCL syntax definition, and build a data structure called a syntax tree while verifying the syntax correctness. The root node of each subtree uses an abstract name to name the elements it contains. That is, the root node of the subtree corresponds to the name of the syntax rule. The leaf nodes of the tree are symbols or lexical symbols in the sentence.
[0040] S6. The WXCL language traverser traverses the syntax tree of the WXCL code and calls the WXCL language listener at each node for translation, and finally translates the corresponding WeChat applet source code.
[0041] According to the structure of the syntax tree and the final source code, the traverser can be designed to perform pre-order traversal, in-order traversal, post-order traversal, etc. on the syntax tree. According to the tag structure of the WXML language, which is one of the source codes, the present invention designs the WXCL traverser to adopt a combination of pre-order traversal and post-order traversal. The specific operation is as follows: the traverser performs pre-order traversal on the syntax tree, and calls the entry callback function and the exit callback function of the corresponding node in the listener when entering and exiting each node respectively. The call order of the entry callback function of each node is the pre-order traversal, and the exit callback function is the post-order traversal. Such a design has a good translation effect on the final code WXML containing a large number of structures such as "<component>nested content< / component>".
[0042] The listener is specifically a set of callback functions, which are called by the traverser during the traversal and translation of the syntax tree. By corresponding WXCL to the source code of the WeChat mini-program and using methods such as judgment loops, the callback functions of each node are written so that it can accurately translate from WXCL to the source code of the WeChat mini-program.
[0043] S7. After obtaining the source code of the WeChat mini-program, the user of the present invention can import the obtained project in the WeChat Developer Tools and preview the final effect in real time. If necessary, the source code can be directly modified, and then the code can be uploaded to the WeChat Public Platform. After submitting for filing (the filing materials include the certificates of the sponsoring unit, the main person in charge, the person in charge of the mini-program, etc.), filing review, and code review, the mini-program can be published on the WeChat Public Platform.
[0044] The following specifically illustrates the above steps through examples: Based on the above steps S1, S2, S3 and in accordance with the above WXCL language syntax definition, a set of WXCL codes for describing the style, page and functions of the WeChat mini-program can be written.
[0045] Code Two: content:style <simple> page1:Home { swiper[ "xxxxxxxx"; "xxxxxxxx";]=>"height:300rpx;interval:4000;"; list[ nevigator <mypage>[ image - "xxxxxxx"=>"height:190rpx;width:300rpx;position:center;"; ]; nevigator <mypage>[ image - "xxxxxxx"=>"height:190rpx;width:300rpx;position:center;"; ]; ]=>"position:center;listCol:2;listColHeight:300rpx;"; list[ nevigator <mypage>[ image - "xxxxxxx"=>"height:160rpx;width:200rpx;position:center;"; ]; nevigator <mypage>[ image - "xxxxxxx"=>"height:160rpx;width:200rpx;position:center;"; ]; nevigator <mypage>[ image - "xxxxxxx"=>"height:160rpx;width:200rpx;position:center;"; ]; ]=>"position:center;listCol:3;listColHeight:220rpx;"; image - "xxxxxxx"=>"width:100%;"; } Code 2 is an example code of the WXCL language of an embodiment of the present invention; Code 2 is the definition of a set of WeChat applet written in WXCL, and its content includes a main page named page1, which contains a swiper, a navigator, an image component, etc. Among them, each component is followed by gui to describe the component style, which corresponds to the final generated WXSS style.
[0046] The function part is the button function. This method provides two methods to implement the function: the first is to provide the button component with optional functional keywords, such as Login, Logout, etc., and write a translation program for such words before translation, integrate and encapsulate the WeChat applet code of related functions, and generate the corresponding source code when the program recognizes it. The second is to write the overall source code for the functional interface in Describe, such as OrderPage. This overall function includes the overall component layout, the processing of data sent by the front end, the access and call of the database, the import of information and other specific functions. At the same time, a series of functions required for this page, including ordering, payment, address query, etc., will be encapsulated into the translation system.
[0047] After completing the WXCL code writing according to S4, it is input into the lexical analyzer for analysis. The lexical analysis result is shown in Code 3.
[0048] Code three: (1,'content') (0,':') (1,'style') (0,'<') (1,'simple') (0,'>') (1,'page') (1,'1') (0,':') (1,'Home') (0,'0') (1,'swiper') (0,'D') (0,' "xxxxxxxx" ') (0,';') (0,' "xxxxxxxx" ') (0,')') (0,'=>') (1,' "height:425rpx;interval:4000;" ') (1,'list') (0,'D') (1,'navigator') (0,'<') (1,'MyPage') (0,'>') (0,'D') (1,'image') (0,'-') (0,' "xxxxxxx" ') (0,'=>') (1,' "height:120rpx;width:120rpx;position:center;" ') (0,')') Code 3 is a token stream obtained by lexical analysis of the WXCL code in Code 2; according to the above step S5, the token stream shown in Code 3 is input into the WXCL parser for analysis, and a grammar analysis tree is obtained as shown in FIG. Figure 3 shown.
[0049] According to the above step S6, the designed listener is used to traverse the syntax tree in pre-order, and the corresponding listening function is called back when entering and exiting the node to translate the corresponding code and input it into the corresponding file.
[0050] Code 4: <!--pages / home / home.wxml--> <swiper autoplay="true" interval="4000"> <swiper-item> < / swiper-item> <swiper-item> < / swiper-item> < / swiper> <view class="list1"> <navigator url="" class="list1-item" open-type="navigate"> < / navigator> <navigator url="" class="list1-item" open-type="navigate"> < / navigator> < / view> <view class="list2"> <navigator url="" class="list2-item" open-type="navigate"> < / navigator> <navigator url="" class="list2-item" open-type="navigate"> < / navigator> <navigator url="" class="list2-item" open-type="navigate"> < / navigator> < / view> Code 4 is the WeChat applet source code obtained by translating the WXCL code of Code 3; the final code of the WeChat applet obtained after translation according to the above step S7 is shown in Code 4, which implements the style, page and function defined by the WXCL code shown in Code 2.
[0051] The final page effect is as follows Figure 4 As shown, there is a swiper at the top, followed by five navigator components below, and finally an image component.
[0052] In summary, WeChat Mini Programs integrate many APIs that are beneficial to development, such as <button>Tag, directly use it to create a button to display on the page, which is very convenient. The intermediate code WXCL set in the embodiment of the present invention is further simplified on the basis of it. For example, the function field followed by the button component can directly describe the function of the button, and the required code can be generated in one step.
[0053] Specifically, the embodiment of the present invention constructs a method with a low learning threshold and extremely low cost to obtain the source code of the WeChat applet for ordinary users who intend to develop the source code of the WeChat applet but have limited development capabilities, time or costs. Based on the method proposed in the present invention, the user only needs to understand the simple XML language syntax to use the WXCL language to customize the appearance and functions of the desired WeChat applet, and obtain the source code of the WeChat applet based on the WeChat applet translation algorithm for WXCL proposed in the present invention. The WXCL language is an intermediate language that is conducive to the automatic generation of WeChat applets. It is different from the so-called intermediate code in the traditional field of compiler theory. In the field of compiler theory, intermediate code generation is a language processing method that is conducive to obtaining the target code, and converts the source program into an intermediate representation. The input of WXCL is provided by the user, and no source code is required as input.
[0054] On the other hand, the present invention further discloses a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the above method.
[0055] On the other hand, the present invention further discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the above method.
[0056] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the WeChat applet source code generation methods based on WXCL in the above embodiments.
[0057] It is understandable that the system, device and storage medium provided in the embodiments of the present invention correspond to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above methods.
[0058] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0059] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0060] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0061] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / button> < / mypage> < / mypage> < / mypage> < / mypage> < / mypage> < / simple>
Claims
1. A method for generating source code of WeChat applet based on WXCL, based on WeChat applet platform, characterized in that: Set the intermediate code WXCL language, including setting the lexical and grammatical definition, lexical analyzer, grammatical analyzer, and WXCL language to target code translation program, which is used to generate the final WeChat applet code; It also includes a backend code translation system, which deploys the WXCL language translation software on the server background to translate the WXCL language into WeChat applet source code in real time and send it to users.
2. The WXCL-based WeChat applet source code generation method according to claim 1, characterized in that: The WXCL language specification explains as follows: The content in '' is a terminal symbol, and the analyzer can translate it as soon as it reads the terminal symbol; =>The content after is GUI, namely Graphical User Interface. GUI corresponds to the content of wxss style sheet, and the content is enclosed by ""; The symbols on the left and right sides of '|' are in parallel relationship and can appear at the same time; 'XXXXXX' and 'string' represent paths; ()* means the number of times the content in the brackets appears is greater than or equal to 0; ()+ means the number of times the content in the brackets appears is greater than or equal to 1; ()? Indicates that the number of times the content in the brackets appears is 0 or 1; ';' is used to separate styles in "" and to separate components in other places.
3. The method for generating WeChat applet source code based on WXCL according to claim 2, characterized in that: The keywords and their meanings of the intermediate code WXCL are as follows: Project is the general term for the entire project; content is used to describe the content of the page; pageList is used to define the sequence number of the page; Describe is used to summarize the page content; Component contains all the components required by WeChat Mini Program; Swiper is used to store pictures for carousel; Navigator is used to navigate the page; Image is a picture component; list is a list component; Input is an input box component; function indicates the button function; pageLocation indicates the page path.
4. The method for generating WeChat applet source code based on WXCL according to claim 3, characterized in that: The following steps are included: S1. First, clarify the final style, page and corresponding functions of the WeChat Mini Program; S2. Modify the WXCL language sample document so that the final WXCL document can accurately describe the style, page and corresponding functions of the final WeChat applet; S3, check the correctness of the generated WXCL code, and submit the WXCL code to the WXCL language lexical analyzer; S4, the lexical analyzer of the WXCL language checks whether there is a lexical error in the input WXCL code; if there is a lexical error, it returns to step S2, otherwise the token stream after lexical analysis is input to step S5, where token is a meaningful word unit in the WXCL language code; S5. The syntax analyzer of the WXCL language performs syntax analysis on the input token stream; if there is a syntax error, it will return to step S2 for the user to further modify, otherwise it will generate a syntax tree corresponding to the WXCL code; S6. The WXCL language traverser traverses the syntax tree of the WXCL code and calls the WXCL language listener at each node for translation, and finally translates the corresponding WeChat applet source code.
5. The method for generating WeChat applet source code based on WXCL according to claim 4, characterized in that: The specific steps of the WXCL language syntax analyzer are as follows: first read the token stream, perform top-down syntax analysis on the token symbols according to the WXCL syntax definition, verify the syntax correctness and build a data structure called a syntax tree. The root node of each subtree uses an abstract name to name the contained elements, that is, the root node of the subtree corresponds to the name of the syntax rule, and the leaf nodes of the tree are symbols or lexical symbols in the sentence.
6. The method for generating WeChat applet source code based on WXCL according to claim 4, characterized in that: The traversal steps in step S6 include: The traverser performs a pre-order traversal of the syntax tree, and calls the entry callback function and exit callback function of the corresponding node in the listener respectively when entering and exiting each node; the order of calling the entry callback function of each node is the pre-order traversal, and the exit callback function is the post-order traversal; The listener is specifically a collection of callback functions, which is called by the traverser when the syntax tree is traversed and translated. It corresponds the WXCL language and the WeChat applet source code, and uses a judgment loop to write the callback function of each node so that it can be accurately translated from WXCL to the WeChat applet source code.
7. The WXCL-based WeChat applet source code generation method according to claim 6, characterized in that: After step S6, the following steps are also included: S7. After obtaining the source code of the WeChat mini program, you can import the obtained project into the WeChat developer tool and preview the final effect in real time. You can directly modify the source code and then upload the code to the WeChat public platform. After filing, filing review, and code review, the mini program can be published on the WeChat public platform.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Automatic code conversion method and device, code converter and medium
CN110471666A
ST-to-C code conversion method, related device and storage medium
CN118838604A