CN109614104B - Method and device for adding new semantic structure based on template preprocessing and electronic equipment - Google Patents

Method and device for adding new semantic structure based on template preprocessing and electronic equipment Download PDF

Info

Publication number
CN109614104B
CN109614104B CN201811406055.7A CN201811406055A CN109614104B CN 109614104 B CN109614104 B CN 109614104B CN 201811406055 A CN201811406055 A CN 201811406055A CN 109614104 B CN109614104 B CN 109614104B
Authority
CN
China
Prior art keywords
new semantic
native compiler
specific
semantic structure
native
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811406055.7A
Other languages
Chinese (zh)
Other versions
CN109614104A (en
Inventor
侯文杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201811406055.7A priority Critical patent/CN109614104B/en
Publication of CN109614104A publication Critical patent/CN109614104A/en
Application granted granted Critical
Publication of CN109614104B publication Critical patent/CN109614104B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

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

Abstract

The embodiment of the invention provides a method, a device and electronic equipment for adding a new semantic structure based on template preprocessing, belonging to the technical field of data processing and comprising the following steps: defining a new semantic structure which cannot be normally analyzed by a native compiler and comprises a preset calling interface in a code of a native compiler environment; setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment; when the new semantic structure is compiled by the native compiler, calling the specific analysis program by using the preset calling interface; and calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and an analyzable code in the compiling environment by the native compiler. The scheme of the application improves the efficiency of code compiling.

Description

Method and device for adding new semantic structure based on template preprocessing and electronic equipment
Technical Field
The invention relates to the technical field of data processing, in particular to a method and a device for adding a new semantic structure based on template preprocessing and electronic equipment.
Background
With the popularization of embedded applications and the popularization of the internet, embedded devices have already entered thousands of households, and can be widely applied to various information appliances and portable network terminals such as handheld devices, Web terminals, digital television set-top boxes and the like. Embedded browsers have become a bridge to connecting networks and individual users as an important user application on embedded devices.
The Web page scripting language enables information and users not only to be a display and browse relation, but also to achieve real-time, dynamic and interactive expression capacity, so that static HTML pages are replaced by Web pages which can provide dynamic real-time information and react to user operations, and the browser is required to provide support for script analysis and execution.
In the prior art, the analysis of the script language is only limited to a specific grammar structure supported by a compiler, and for a specific grammar capable of realizing a special effect, a user is often required to write a large amount of codes, so that the compiling efficiency of the codes is low.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a method, an apparatus, and an electronic device for adding a new semantic structure based on template preprocessing, which at least partially solve the problems in the prior art.
In a first aspect, an embodiment of the present invention provides a method for adding a new semantic structure based on template preprocessing, including:
defining a new semantic structure which cannot be normally analyzed by a native compiler and comprises a preset calling interface in a code of a native compiler environment;
setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment;
when the new semantic structure is compiled by the native compiler, calling the specific analysis program by using the preset calling interface;
and calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and an analyzable code in the compiling environment by the native compiler.
According to a specific implementation manner of the embodiment of the present invention, in a code of a native compiler environment, defining a new semantic structure including a preset call interface, which cannot be normally resolved by a native compiler, includes:
and defining a structural body containing different data type variables, wherein the structural body at least comprises two variables of a type and a value, and the fields of the type and the value also dynamically change along with the execution of the program.
According to a specific implementation manner of the embodiment of the present invention, in the code of the native compiler environment, a new semantic structure including a preset call interface, which cannot be normally resolved by the native compiler, is defined, and the method further includes:
defining a storage logic structure to describe the code, wherein the storage logic structure comprises a node domain, a brother domain and a parent domain, the node domain stores the property of the statement, the brother domain is used for representing the sequential execution relation, and the parent domain is used for representing the calling relation.
According to a specific implementation manner of the embodiment of the present invention, the setting of a specific parsing program for parsing the new semantic structure includes:
and setting a lexical analyzer in the specific analysis program, wherein the lexical analyzer comprises a preprocessing subprogram, an input buffer area, a scanner and a scanning buffer area, the preprocessing subprogram eliminates useless characters in the codes and then puts the processed input characters into the scanning buffer area, and the scanner identifies symbols in the codes from the scanning buffer area.
According to a specific implementation manner of the embodiment of the present invention, the setting of a specific parsing program for parsing the new semantic structure further includes:
and setting a grammar analyzer in the specific analysis program, wherein the grammar analyzer comprises a grammar analysis master controller, the grammar analysis master controller takes a word symbol bidirectional linked list generated by lexical analysis as input, analyzes the source program sentences one by one according to a grammar analysis method, and finally generates a statement flow chart and a data dictionary of the source program.
According to a specific implementation manner of the embodiment of the invention, the method is characterized in that:
the syntax analyzer further comprises a data dictionary used for storing program data, the data dictionary comprises global variables, function form parameters and local variables in statement blocks, and the data dictionary is used for searching required data when an expression stipulator of the interpretation executor carries out expression stipulation.
According to a specific implementation manner of the embodiment of the present invention, when the new semantic structure is compiled by the native compiler, the invoking the specific parser by using the preset invoking interface includes:
creating a base object in the native code of the specific parser run;
constructing an internal window object and an internal document object in the initialization code;
associating the internal window object and the internal document object with the base object and generating an initialization object;
invoking the specific parser with the initialization object.
According to a specific implementation manner of the embodiment of the present invention, the invoking the native compiler by the specific parser after the parsing is completed, and loading the parsed file generated by the specific parser into the native compiler includes:
judging whether a built-in object generated by the specific analysis program exists or not;
if yes, further enabling a mapping function of the built-in object, and calling the native compiler by using the mapping function.
In a second aspect, an embodiment of the present invention provides an apparatus for adding a new semantic structure based on template preprocessing, including:
the definition module is used for defining a new semantic structure which cannot be normally analyzed by the native compiler and comprises a preset calling interface in a code of a native compiler environment;
a setting module for setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment;
the calling module is used for calling the specific analysis program by utilizing the preset calling interface when the new semantic structure is compiled by the native compiler;
and the loading module is used for calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and the analyzable codes in the compiling environment together by the native compiler.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform a method of adding new semantic structures based on template preprocessing in any of the preceding aspects or any implementation of the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute a method for adding a new semantic structure based on template preprocessing in any one of the foregoing implementations of the first aspect or the first aspect.
In a fifth aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, when executed by a computer, cause the computer to perform the method for adding a new semantic structure based on template preprocessing in the foregoing first aspect or any implementation manner of the first aspect.
The scheme for adding the new semantic structure based on template preprocessing in the embodiment of the invention comprises the steps of defining a new semantic structure which cannot be normally analyzed by a native compiler and comprises a preset calling interface in a code of a native compiler environment; setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment; when the new semantic structure is compiled by the native compiler, calling the specific analysis program by using the preset calling interface; and calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and an analyzable code in the compiling environment by the native compiler. By the aid of the processing scheme, the efficiency of code compiling is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flow chart illustrating adding a new semantic structure based on template preprocessing according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a lexical analyzer according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating a parser structure according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart illustrating another example of adding a new semantic structure based on template preprocessing according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an apparatus for adding new semantic structures based on template preprocessing according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
The embodiments of the present disclosure are described below with specific examples, and other advantages and effects of the present disclosure will be readily apparent to those skilled in the art from the disclosure in the specification. It is to be understood that the described embodiments are merely illustrative of some, and not restrictive, of the embodiments of the disclosure. The disclosure may be embodied or carried out in various other specific embodiments, and various modifications and changes may be made in the details within the description without departing from the spirit of the disclosure. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
It is noted that various aspects of the embodiments are described below within the scope of the appended claims. It should be apparent that the aspects described herein may be embodied in a wide variety of forms and that any specific structure and/or function described herein is merely illustrative. Based on the disclosure, one skilled in the art should appreciate that one aspect described herein may be implemented independently of any other aspects and that two or more of these aspects may be combined in various ways. For example, an apparatus may be implemented and/or a method practiced using any number of the aspects set forth herein. Additionally, such an apparatus may be implemented and/or such a method may be practiced using other structure and/or functionality in addition to one or more of the aspects set forth herein.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present disclosure, and the drawings only show the components related to the present disclosure rather than the number, shape and size of the components in actual implementation, and the type, amount and ratio of the components in actual implementation may be changed arbitrarily, and the layout of the components may be more complicated.
In addition, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects may be practiced without these specific details.
The embodiment of the disclosure provides a method for adding a new semantic structure based on template preprocessing. The method for adding a new semantic structure based on template preprocessing provided by the embodiment can be executed by a computing device, which can be implemented as software or implemented as a combination of software and hardware, and can be integrally disposed in a server, a terminal device, and the like.
Referring to fig. 1, a method for adding a new semantic structure based on template preprocessing provided by the embodiment of the present invention includes the following steps:
s101, defining a new semantic structure which cannot be normally analyzed by a native compiler and comprises a preset calling interface in a code of a native compiler environment.
In the process of writing code, some advanced features are usually written according to actual needs, while a compiler in a native compiler environment usually only provides conventional compiling functions, and for the code in the native compiler environment, the code must be written in a way that conforms to the rules of the compiler. For example, the definition of data type is defined according to the type that the compiler can resolve. Limitations in these areas can lead to inefficient code writing by users.
In order to add a new custom function to the native compiler, a new semantic structure may be defined in the native compiler, and the new semantic structure cannot be normally analyzed when the native compiler compiles, for this reason, a new preset call interface needs to be added in the original compilation environment, the preset call interface is a code that can be recognized and normally analyzed by the native compiler, and other objects may be called to analyze the new semantic structure through the preset call interface.
S102, setting a specific analysis program for analyzing the new semantic structure, wherein the specific analysis program can be loaded into the native compiler environment.
Corresponding to the new semantic structure, a specific program is required to efficiently parse the new semantic structure. For this purpose, a specific parser for parsing the new semantic structure is set, which is capable of parsing the code in the new semantic structure and converting it into a language that can be parsed and compiled by a native compiler.
Since the preset call interface is set in step S101 to call the specific parsing program, when the specific parsing program is called in the preset manner, the specific parsing program is loaded into the native compiler environment, and the specific parsing program feeds back a result of parsing the new semantic structure to the native compiler for the native compiler to continue to perform the compiling operation.
S103, when the new semantic structure is compiled by the native compiler, the specific analysis program is called by using the preset calling interface.
When the native compiler compiles the codes in the compiler, all code identifiers in the codes are identified, when the compiler identifies the codes corresponding to the preset calling interface, whether a corresponding specific analytic function exists in the compiling environment is searched based on the function corresponding to the preset calling interface, and if the specific analytic function exists, the specific analytic program is loaded into the native compiler environment.
S104, the specific analysis program calls the native compiler after the analysis is finished, an analysis file generated by the specific analysis program is loaded into the native compiler, and the native compiler compiles the analysis file and the analyzable codes in the compiling environment together.
After the specific analysis program is called, the codes in the new semantic structure can be analyzed, a corresponding analysis file is generated, and the analysis file is an object which can be identified and normally analyzed by the original compiler, so that the original compiler can compile the analysis file and the analyzable codes (except the codes of the new semantic structure) in the compiling environment together, and the efficiency of code compiling is improved.
Through the implementation mode, a user can define the function or the effect which cannot be normally analyzed by a plurality of native compilers in the native compiler environment, and when the user needs to use the function or the effect, the user only needs to call the new meaning structure, so that the working efficiency is improved.
According to a specific implementation manner of the embodiment of the present invention, in a code of a native compiler environment, defining a new semantic structure including a preset call interface that cannot be normally resolved by a native compiler includes: and defining a structural body containing different data type variables, wherein the structural body at least comprises two variables of a type and a value, and the fields of the type and the value also dynamically change along with the execution of the program. Through the setting mode, the new semantic structure can be ensured to have stronger adaptability in the native compiler environment.
According to a specific implementation manner of the embodiment of the present invention, in the code of the native compiler environment, defining a new semantic structure including a preset call interface that cannot be normally resolved by the native compiler, further includes: defining a storage logic structure to describe the code, wherein the storage logic structure comprises a node domain, a brother domain and a parent domain, the node domain stores the property of the statement, the brother domain is used for representing the sequential execution relation, and the parent domain is used for representing the calling relation. By the arrangement mode, the codes in the new semantic structure can be effectively executed.
Corresponding to the new semantic structure, a corresponding specific parsing program needs to be set, referring to fig. 2, according to a specific implementation manner of the embodiment of the present invention, the setting of the specific parsing program for parsing the new semantic structure includes: and setting a lexical analyzer in the specific analysis program, wherein the lexical analyzer comprises a preprocessing subprogram, an input buffer area, a scanner and a scanning buffer area, the preprocessing subprogram eliminates useless characters in the codes and then puts the processed input characters into the scanning buffer area, and the scanner identifies symbols in the codes from the scanning buffer area. Through the setting mode, the specific analysis program can be ensured to effectively identify the codes in the new semantic structure.
In addition to the requirement of recognizing the lexical method, the specific parser also needs to analyze the grammar of the new semantic structure, referring to fig. 3, according to a specific implementation manner of the embodiment of the present invention, the setting of the specific parser for parsing the new semantic structure further includes: and setting a grammar analyzer in the specific analysis program, wherein the grammar analyzer comprises a grammar analysis master controller, the grammar analysis master controller takes a word symbol bidirectional linked list generated by lexical analysis as input, analyzes the source program sentences one by one according to a grammar analysis method, and finally generates a statement flow chart and a data dictionary of the source program.
The parser also includes a sentence recognizer that performs recognition of a single sentence, with a sentence recognizer corresponding to each of the different kinds of sentences. And the sentence recognizer recognizes the sentences according to the grammar rules and semantics of the sentences.
The parser also includes a data dictionary for storing program data, the data dictionary including global variables, function parameters and local variables in the statement block, the data dictionary being used for the expression stipulator of the interpretation executor to search for required data when performing expression stipulation.
Referring to fig. 4, according to a specific implementation manner of the embodiment of the present invention, when the new semantic structure is compiled by the native compiler, the invoking the specific parser by using the preset invocation interface includes:
s401, a base object is created in the local code operated by the specific analysis program.
The framework base object is exposed to the driver through the interface. By setting the base object, a basic function common to all the framework object types can be provided. Providing a basis for the subsequent creation of other objects.
S402, an internal window object and an internal document object are constructed in the initialization code.
By building internal window objects and internal document objects, the internal window objects and internal document objects may be associated with a base object in preparation for invoking the particular parser.
S403, associating the internal window object and the internal document object with the base object and generating an initialization object.
S404, calling the specific analysis program by utilizing the initialization object.
According to a specific implementation manner of the embodiment of the present invention, the invoking the native compiler by the specific parser after the parsing is completed, and loading the parsed file generated by the specific parser into the native compiler includes: and judging whether the built-in object generated by the specific analysis program exists or not. If yes, further enabling a mapping function of the built-in object, and calling the native compiler by using the mapping function.
Corresponding to the above method embodiment, referring to fig. 5, an embodiment of the present invention further provides an apparatus 50 for adding a new semantic structure based on template preprocessing, including:
the defining module 501 is configured to define, in the code of the native compiler environment, a new semantic structure including a preset call interface that cannot be normally resolved by the native compiler.
In the process of writing code, some advanced features are usually written according to actual needs, while a compiler in a native compiler environment usually only provides conventional compiling functions, and for the code in the native compiler environment, the code must be written in a way that conforms to the rules of the compiler. For example, the definition of data type is defined according to the type that the compiler can resolve. Limitations in these areas can lead to inefficient code writing by users.
In order to add a new custom function to the native compiler, a new semantic structure may be defined in the native compiler, and the new semantic structure cannot be normally analyzed when the native compiler compiles, for this reason, a new preset call interface needs to be added in the original compilation environment, the preset call interface is a code that can be recognized and normally analyzed by the native compiler, and other objects may be called to analyze the new semantic structure through the preset call interface.
A setting module 502 for setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment.
Corresponding to the new semantic structure, a specific program is required to efficiently parse the new semantic structure. For this purpose, a specific parser for parsing the new semantic structure is set, which is capable of parsing the code in the new semantic structure and converting it into a language that can be parsed and compiled by a native compiler.
Due to the fact that the preset calling interface is set to call the specific analysis program, when the specific analysis program is called in a preset mode, the specific analysis program is loaded into the native compiler environment, and the specific analysis program feeds back a result analyzed by aiming at the new semantic structure to the native compiler so that the native compiler can continue to execute the compiling operation.
The calling module 503 is configured to call the specific parser by using the preset calling interface when the new semantic structure is compiled by the native compiler.
When the native compiler compiles the codes in the compiler, all code identifiers in the codes are identified, when the compiler identifies the codes corresponding to the preset calling interface, whether a corresponding specific analytic function exists in the compiling environment is searched based on the function corresponding to the preset calling interface, and if the specific analytic function exists, the specific analytic program is loaded into the native compiler environment.
A loading module 504, configured to invoke the native compiler after the specific parser completes parsing, and load a parsing file generated by the specific parser into the native compiler, where the native compiler compiles the parsing file with parsable codes in the compiling environment.
After the specific analysis program is called, the codes in the new semantic structure can be analyzed, a corresponding analysis file is generated, and the analysis file is an object which can be identified and normally analyzed by the original compiler, so that the original compiler can compile the analysis file and the analyzable codes (except the codes of the new semantic structure) in the compiling environment together, and the efficiency of code compiling is improved.
The apparatus shown in fig. 5 may correspondingly execute the content in the above method embodiment, and details of the part not described in detail in this embodiment refer to the content described in the above method embodiment, which is not described again here.
Referring to fig. 6, an embodiment of the present invention further provides an electronic device 60, including:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of the preceding method embodiment for adding new semantic structures based on template preprocessing.
Embodiments of the present invention also provide a non-transitory computer-readable storage medium storing computer instructions for causing a computer to perform the foregoing method embodiments.
Embodiments of the present invention also provide a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, where the computer program includes program instructions, and when the program instructions are executed by a computer, the computer is caused to execute the method for adding a new semantic structure based on template preprocessing in the foregoing method embodiments.
Referring now to FIG. 6, a schematic diagram of an electronic device 60 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, the electronic device 60 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 60 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 60 to communicate with other devices wirelessly or by wire to exchange data. While the figures illustrate an electronic device 60 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring at least two internet protocol addresses; sending a node evaluation request comprising the at least two internet protocol addresses to node evaluation equipment, wherein the node evaluation equipment selects the internet protocol addresses from the at least two internet protocol addresses and returns the internet protocol addresses; receiving an internet protocol address returned by the node evaluation equipment; wherein the obtained internet protocol address indicates an edge node in the content distribution network.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: receiving a node evaluation request comprising at least two internet protocol addresses; selecting an internet protocol address from the at least two internet protocol addresses; returning the selected internet protocol address; wherein the received internet protocol address indicates an edge node in the content distribution network.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation of the unit itself, for example, the first retrieving unit may also be described as a "unit for retrieving at least two internet protocol addresses".
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (11)

1. A method for adding new semantic structures based on template preprocessing is characterized by comprising the following steps:
defining a new semantic structure which cannot be normally analyzed by a native compiler and comprises a preset calling interface in a code of a native compiler environment for code writing, wherein the calling interface is used for calling other objects to analyze the new semantic structure;
setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment;
when the new semantic structure is compiled by the native compiler, calling the specific analysis program by using the preset calling interface;
and calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and an analyzable code in the compiling environment by the native compiler.
2. The method of claim 1, wherein defining a new semantic structure containing a default call interface that cannot be normally resolved by a native compiler in the code of the native compiler environment comprises:
and defining a structural body containing different data type variables, wherein the structural body at least comprises two variables of a type and a value, and the fields of the type and the value also dynamically change along with the execution of the program.
3. The method of claim 2, wherein defining a new semantic structure containing a default call interface that cannot be normally resolved by a native compiler in the code of the native compiler environment further comprises:
defining a storage logic structure to describe the code, wherein the storage logic structure comprises a node domain, a brother domain and a parent domain, the node domain stores the property of the statement, the brother domain is used for representing the sequential execution relation, and the parent domain is used for representing the calling relation.
4. The method according to claim 3, wherein said setting up a specific parser for parsing said new semantic structure comprises:
and setting a lexical analyzer in the specific analysis program, wherein the lexical analyzer comprises a preprocessing subprogram, an input buffer area, a scanner and a scanning buffer area, the preprocessing subprogram eliminates useless characters in the codes and then puts the processed input characters into the scanning buffer area, and the scanner identifies symbols in the codes from the scanning buffer area.
5. The method according to claim 4, wherein said setting up a specific parser for parsing said new semantic structure further comprises:
and setting a grammar analyzer in the specific analysis program, wherein the grammar analyzer comprises a grammar analysis master controller, the grammar analysis master controller takes a word symbol bidirectional linked list generated by lexical analysis as input, analyzes the source program sentences one by one according to a grammar analysis method, and finally generates a statement flow chart and a data dictionary of the source program.
6. The method of claim 5, wherein:
the syntax analyzer further comprises a data dictionary used for storing program data, the data dictionary comprises global variables, function form parameters and local variables in statement blocks, and the data dictionary is used for searching required data when an expression stipulator of the interpretation executor carries out expression stipulation.
7. The method of claim 6, wherein the calling the specific parser using the pre-defined call interface when the new semantic structure is compiled by the native compiler comprises:
creating a base object in the native code of the specific parser run;
constructing an internal window object and an internal document object in the initialization code;
associating the internal window object and the internal document object with the base object and generating an initialization object;
invoking the specific parser with the initialization object.
8. The method of claim 7, wherein the specific parser calls the native compiler after parsing is completed, and loading the parsed file generated by the specific parser into the native compiler comprises:
judging whether a built-in object generated by the specific analysis program exists or not;
if yes, further enabling a mapping function of the built-in object, and calling the native compiler by using the mapping function.
9. An apparatus for adding new semantic structures based on template preprocessing, comprising:
the definition module is used for defining a new semantic structure which cannot be normally analyzed by the native compiler and comprises a preset calling interface in the code of the native compiler environment for code compiling, wherein the calling interface is used for calling other objects to analyze the new semantic structure;
a setting module for setting a specific parser for parsing the new semantic structure, the specific parser being loadable into the native compiler environment;
the calling module is used for calling the specific analysis program by utilizing the preset calling interface when the new semantic structure is compiled by the native compiler;
and the loading module is used for calling the native compiler after the specific analysis program completes analysis, loading an analysis file generated by the specific analysis program into the native compiler, and compiling the analysis file and the analyzable codes in the compiling environment together by the native compiler.
10. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method for adding new semantic structures based on template preprocessing according to any of the preceding claims 1-8.
11. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform the method of adding new semantic structures based on template preprocessing of any one of the preceding claims 1-8.
CN201811406055.7A 2018-11-23 2018-11-23 Method and device for adding new semantic structure based on template preprocessing and electronic equipment Active CN109614104B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811406055.7A CN109614104B (en) 2018-11-23 2018-11-23 Method and device for adding new semantic structure based on template preprocessing and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811406055.7A CN109614104B (en) 2018-11-23 2018-11-23 Method and device for adding new semantic structure based on template preprocessing and electronic equipment

Publications (2)

Publication Number Publication Date
CN109614104A CN109614104A (en) 2019-04-12
CN109614104B true CN109614104B (en) 2022-04-05

Family

ID=66004926

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811406055.7A Active CN109614104B (en) 2018-11-23 2018-11-23 Method and device for adding new semantic structure based on template preprocessing and electronic equipment

Country Status (1)

Country Link
CN (1) CN109614104B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416105B (en) * 2022-03-30 2022-06-24 北京中科弧光量子软件技术有限公司 Quantum operation compiling method and system, storage medium and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser
CN103902293A (en) * 2014-03-28 2014-07-02 上海下一代广播电视网应用实验室有限公司 Android based radio and television network browser middleware system constructing method
CN107391169A (en) * 2017-06-09 2017-11-24 口碑控股有限公司 The dynamic updating method and device of the Android page

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10089084B2 (en) * 2015-04-03 2018-10-02 Oracle International Corporation System and method for reusing JavaScript code available in a SOA middleware environment from a process defined by a process execution language

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102202242A (en) * 2011-05-19 2011-09-28 广东星海数字家庭产业技术研究院有限公司 Realization method of JavaScript interpreter based on set-top box browser
CN103902293A (en) * 2014-03-28 2014-07-02 上海下一代广播电视网应用实验室有限公司 Android based radio and television network browser middleware system constructing method
CN107391169A (en) * 2017-06-09 2017-11-24 口碑控股有限公司 The dynamic updating method and device of the Android page

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于IPTV嵌人式浏览器功能扩展的研究与设计;张云蛟;《中国优秀硕士学位论文全文数据库信息科技辑》;20160315;第9-65页 *
张云蛟.基于IPTV嵌人式浏览器功能扩展的研究与设计.《中国优秀硕士学位论文全文数据库信息科技辑》.2016,第9-65页. *

Also Published As

Publication number Publication date
CN109614104A (en) 2019-04-12

Similar Documents

Publication Publication Date Title
EP3605324B1 (en) Application development method and tool, and storage medium thereof
CN109739478B (en) Front-end project automatic construction method and device, storage medium and electronic equipment
CN109522018B (en) Page processing method and device and storage medium
CN111240684B (en) Cutting method and device of JS codes, medium and electronic equipment
CN113126990B (en) Page development method, device, equipment and storage medium
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN109062572B (en) Component calling method, device, equipment and storage medium
CN111324833A (en) Page display method, device, electronic design and computer readable medium
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN114153459A (en) Interface document generation method and device
CN113139390A (en) Language conversion method and device applied to code character strings
CN111078228A (en) Method and device for converting webpage into small program, server and storage medium
CN110389899B (en) Method and device for detecting API data type of JS program, medium and equipment
CN109614104B (en) Method and device for adding new semantic structure based on template preprocessing and electronic equipment
CN114217789A (en) Function component expansion method, device, equipment, storage medium and program product
CN113761871A (en) Rich text rendering method and device, electronic equipment and storage medium
CN113094138A (en) Interface display method and device, electronic equipment and storage medium
CN109408057B (en) Method, device, medium and computing equipment for automatically generating codes
CN110717134A (en) Product description issuing method and device, storage medium and electronic equipment
CN110442419A (en) The quick interface arrangement method and device of Android application
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN113961279A (en) Page rendering method, device, server and storage medium
CN113590125A (en) Applet development method and device
CN113138767A (en) Code language conversion method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant