CN116540986A - Method for constructing text programming language code editor based on Web end - Google Patents

Method for constructing text programming language code editor based on Web end Download PDF

Info

Publication number
CN116540986A
CN116540986A CN202310440086.9A CN202310440086A CN116540986A CN 116540986 A CN116540986 A CN 116540986A CN 202310440086 A CN202310440086 A CN 202310440086A CN 116540986 A CN116540986 A CN 116540986A
Authority
CN
China
Prior art keywords
grammar
programming language
target
plug
checking
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310440086.9A
Other languages
Chinese (zh)
Inventor
周笑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jishan Zhigong Suzhou Technology Co ltd
Original Assignee
Jishan Zhigong Suzhou 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 Jishan Zhigong Suzhou Technology Co ltd filed Critical Jishan Zhigong Suzhou Technology Co ltd
Priority to CN202310440086.9A priority Critical patent/CN116540986A/en
Publication of CN116540986A publication Critical patent/CN116540986A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • 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/425Lexical analysis
    • 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/60Software deployment
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
    • G06F9/45529Embedded in an application, e.g. JavaScript in a Web browser
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention relates to a text programming language code editor construction method based on Web end, adopting totally new architecture design, firstly describing the grammar structure of target text programming language to obtain target grammar description file; then analyzing the target grammar description file to obtain an abstract grammar tree and a virtual tree carrying text information; and finally, constructing each plug-in unit and each component for realizing the preset code operation function through recursion inspection, configuring the plug-in units and the components on the target Web end online editor, namely forming a code editor for the target text programming language, integrating the code editor into Web items, and calling the corresponding Web items through a browser in application to realize code programming of target hardware about the target text programming language, thereby effectively improving the efficiency of hardware coding.

Description

Method for constructing text programming language code editor based on Web end
Technical Field
The invention relates to a method for constructing a text programming language code editor based on a Web end, and belongs to the technical field of industrial PLC programming.
Background
The PLC (Programmable Logic Controller ) is a novel universal automatic control device formed by integrating communication technology, computer technology and automatic control technology based on a microprocessor, and is widely applied to the field of industrial control at present.
In the IEC61131-3 standard, which is set by the International electrotechnical Commission, 5 PLC standard programming languages, namely, a Structured Text (ST), an instruction sheet (IL), a ladder diagram (LAD), a Function Block Diagram (FBD) and a sequential function diagram (SFC), are provided, and currently, a plurality of factories provide IDE integrated development software for PLC development, such as German code SYS, siemens, domestic and time of use and the like.
However, the above mentioned integrated development software is all desktop application, and needs to be installed through software packages, and because of platform differences, the software needs expensive development cost for adapting to different systems and different platforms, and the user operation interface is old, so that the user experience is poor, and the actual working efficiency is greatly affected.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a method for constructing a text programming language code editor based on a Web end, which adopts a totally new architecture design to create the code editor and realizes the efficient coding of hardware through the Web end.
The invention adopts the following technical scheme for solving the technical problems: the invention designs a method for constructing a text programming language code editor based on a Web end, which comprises the following steps of A to D, constructing a code editor based on the Web end and used for a target text programming language;
step A, according to a preset description rule, applying grammar structures of grammar description target text programming languages corresponding to an LR parser in a Lezer grammar parsing system to obtain a target grammar description file, and then entering step B;
b, an LR parser in a Lezer grammar parsing system is applied, a target grammar description file is parsed, an abstract grammar tree and a virtual tree carrying text information are obtained, and then the step C is carried out;
step C, recursively checking an abstract grammar tree and a virtual tree carrying text information, constructing each plug-in unit and each assembly for realizing the operation function of each preset code, and then entering the step D;
and D, configuring each plug-in and each component in the target web-end online editor, namely forming a code editor for the target text programming language, and integrating the plug-in and the components into the web project.
As a preferred technical scheme of the invention: in the step A, according to a preset description rule, a grammar corresponding to an LR parser in a Lezer grammar parsing system is applied to describe program statement, type statement, variable statement, IF statement, CASE statement, FOR loop statement, WHILE statement, REPEAT statement, assignment statement and definition internal keywords, so that the description of the grammar structure of the target text programming language is completed, and a target grammar description file is obtained.
As a preferred technical scheme of the invention: the preset description rule in the step A comprises the following steps:
(1) Based on marks corresponding to preset priorities, marking the corresponding marks of the corresponding priorities for each processing action of each data in a grammar structure of the target text programming language, and meeting the execution sequence of each processing action of each data in the grammar structure;
(2) Regarding the built-in keywords of the grammar structure of the target text programming language, defining the built-in keywords of the grammar structure of all the target text programming languages in a VAR { VAR } form based on a way of enumerating 26-bit English letters token;
regarding each object name used except the built-in keywords in the grammar structure of the target text programming language, judging whether the object name is declared by a user or not through a subsequent grammar checking stage and a grammar highlighting stage, if so, indicating that the object name is declared by the user and is correct to use; otherwise, the object name is not declared by the user and is not used correctly;
(3) In the grammar structure of the target text class programming language, each shorthand special keyword declared by a user is described according to VariableDeclaration { VariableName ":" TypeName ": =" VariableValue ";" so as to realize the assignment of each shorthand special keyword; when the shorthand special keyword declared by the user is matched with the TypeName, the shorthand special keyword is used as a type shorthand; when the shorthand special key declared by the user is matched with the variable value, if the shorthand special key is a variable name, the shorthand special key is used as the variable name declared by the user, and if the shorthand special key is a value of a data value type, the shorthand special key is used as the type of the data value;
(4) Regarding variable assignment in a grammar structure of a target text class programming language, firstly deriving an assigned value into a basic Number type so as to be successfully matched, and then obtaining the type of assigning the assigned value to the assigned variable according to the type designated by the assigned variable in a user statement through backtracking a grammar tree in a subsequent grammar checking stage to realize variable assignment.
As a preferred technical scheme of the invention: the object names comprise program names, type names, variable names and parameter names.
As a preferred technical scheme of the invention: in the step C, recursively checking an abstract syntax tree and a virtual tree carrying text information, and constructing various plug-ins and components for realizing the following preset code operation functions;
(1) A grammar checking plug-in for checking the virtual tree, eliminating the unprocessed lexical ambiguity in the grammar description stage, judging the validity of the tree node type, and locating and marking the abnormal node when the abnormality occurs;
(2) The grammar highlighting plug-in is used for distributing css class names for different node types and distinguishing the patterns of the nodes;
(3) A code prompt plug-in for checking the context of the node, deducing the content which the user may input next, and prompting the user;
(4) Setting a breakpoint plug-in, which is used for setting a breakpoint for the clicked code line;
(5) And the variable list mode switching component is used for generating corresponding array data according to variable attributes described in the IEC61131-3 programming language standard and supporting the mutual conversion between the target text class programming language of the variable part and the array.
As a preferred technical scheme of the invention: regarding the checking of the virtual tree by the grammar checking plug-in, based on the caching of the virtual tree, the code segments which are closed and have not changed are not subjected to grammar analysis, and the grammar checking plug-in executes grammar checking on the cached grammar tree; after the user stops inputting the preset time length, further executing grammar checking by the grammar checking plug-in based on grammar analysis processing.
As a preferred technical scheme of the invention: the target web end online editor is a codeMirror editor.
Compared with the prior art, the method for constructing the text programming language code editor based on the Web end has the following technical effects:
(1) The invention designs a method for constructing a text programming language code editor based on a Web end, which adopts an entirely new architecture design, firstly describes a grammar structure of a target text programming language and obtains a target grammar description file; then analyzing the target grammar description file to obtain an abstract grammar tree and a virtual tree carrying text information; finally, constructing each plug-in unit and each component for realizing the preset code operation function through recursion inspection, configuring the plug-in units and the components on the target Web end on-line editor, namely forming a code editor for the target text programming language, integrating the code editor into Web items, and calling the corresponding Web items through a browser in application to realize code programming of target hardware about the target text programming language, thereby effectively improving the efficiency of hardware coding;
(2) According to the method for constructing the text programming language code editor based on the Web end, which is designed by the invention, due to the advantage of cross-platform of the Web end, a developer does not need to pay attention to the difference of platforms, can pay more attention to the development of business logic, only needs to use a Javascript language to maintain a set of codes, and after compression and confusion by a compiling tool such as weback, a deployment scheme is flexibly selected according to requirements, such as deploying front-end resource files (html, css, compiled Javascript codes and the like) on a server by adopting a B/S (browser/server) architecture, or packaging the front-end resource files into desktop application (essentially a chrome open source version browser) by using an Electron construction tool, so that efficient hardware coding operation can be realized;
(3) The invention designs a text programming language code editor construction method based on a Web end, in the application, web pages and PLC IDE programming software of various large manufacturers in the prior art keep the same interactive logic (supporting grammar highlighting, grammar checking, code prompting, breakpoints, variable list supporting forms, editors and the like), so that when a user switches from using software to the Web end, the user has almost no learning cost.
Drawings
FIG. 1 is a flow chart of a method for constructing a text-based programming language code editor based on a Web end in accordance with the present invention;
FIG. 2 is an example of an interface in an embodiment of a design application of the present invention;
FIG. 3 is an editor schema for variable lists in an embodiment of a design application of the invention.
Detailed Description
The following describes the embodiments of the present invention in further detail with reference to the drawings.
In practical application, as shown in fig. 1, the method specifically executes the following steps a to D to construct the code editor based on the Web terminal and used for the target text programming language.
And step A, applying grammar structures of grammar description target text programming languages corresponding to the LR parser in the Lezer grammar parsing system according to preset description rules to obtain target grammar description files, and then entering step B.
In practical application, in the step a, a 4-point preset description rule is applied to describe a grammar corresponding to the LR parser in the Lezer grammar parsing system, and describe a program statement, a type statement, a variable statement, an IF statement, a CASE statement, a FOR loop statement, a WHILE statement, a REPEAT statement, an assignment statement, and define an internal keyword, thereby completing description of a grammar structure of a target text programming language and obtaining a target grammar description file.
(1) Based on marks corresponding to the preset priorities, marks corresponding to the priorities are respectively applied to each processing action related to each data in the grammar structure of the target text programming language, and the execution sequence of each processing action related to each data in the grammar structure is met.
For arithmetic expressions, e.gA := 1 + 2 * 3Should be calculated first 2 x 3 and then added to 1, if simply described asBinaryExpression { expression ("+" | "*") expression }Then the derived priorities for the resolvers are calculated sequentially((1 + 2) * 3). Therefore, it is desirable to increase the priority of multiplication symbols to allow the parser to preferentially match multiplications. As shown in the following code segment, the priority field indicates that the multi flag has a higher priority than plus, and in the BinaryExpression syntax expression, the multi flag is added before the multiplication symbol, and the plus flag is added before the addition symbol. In this way, the parser can effectively be identified as(1 + (2 * 3))
@precedence { multi @right, plus @right }
expression { Number | BinaryExpression }
BinaryExpression {
expression !multi "*" expression |
expression !plus "+" expression
}
@tokens {
Number { @digit+ }
}
(2) The manner of enumerating 26-bit english letters token based on built-in keywords for the grammar structure of the target text-based programming language is as follows:
@tokens {
a { $[aA] }
b { $[bB] }
c { $[cC] }
d { $[dD] }
e { $[eE] }
f { $[fF] }
g { $[gG] }
h { $[hH] }
i { $[iI] }
j { $[jJ] }
k { $[kK] }
l { $[lL] }
m { $[mM] }
n { $[nN] }
o { $[oO] }
p { $[pP] }
q { $[qQ] }
r { $[rR] }
s { $[sS] }
t { $[tT] }
u { $[uU] }
v { $[vV] }
w { $[wW] }
x { $[xX] }
y { $[yY] }
z { $[zZ] }
}
built-in keywords of the grammar structure of all target text-class programming languages are defined by VAR { VAR } form.
Regarding each object name used except for the built-in keywords in the grammar structure of the target text programming language, the use of the object names in the code segment is not case-independent, so that whether the object names are declared by a user or not is judged through the subsequent grammar checking stage and grammar highlighting stage, if yes, the object names are declared by the user, and the use is correct; otherwise, the object name is not declared by the user and is not used correctly. The object names here include program names, type names, variable names, and parameter names.
In writing program code, a grammar style should be uniformly used to promote code readability, although the grammar is case-independent.
(3) In the grammar structure of the target text class programming language, each shorthand special keyword declared by a user is described according to VariableDeclaration { VariableName ":" TypeName ": =" VariableValue ";" so as to realize the assignment of each shorthand special keyword; when the shorthand special keyword declared by the user is matched with the TypeName, the shorthand special keyword is used as a type shorthand; when the shorthand special key declared by the user is matched with the variable value, if the shorthand special key is a variable name, the shorthand special key is used as the variable name which is declared by the user, and if the shorthand special key is a value of a data value type, the shorthand special key is used as the type of the data value.
For example, in table 1 below, T, D, TOD, DT is a special key, either as a type name or as a declarative name, such as a variable name, in the grammar.
TABLE 1
The following assignment statements are syntactical in the case that the user has declared the shorthand variable.
Local 0: =t; (×t as variable name:)
Local 1: =t#1000ms; (.t as value type:)
Local 2T: =1000ms; (.t as type:)
Thus, the assignment statement is described as VariableDeclaration { VariableName ":" TypeName ": =" VariableValue ";" VariableValue "}. When the shorthand special keyword declared by the user is matched with the TypeName, the shorthand special keyword is T and is taken as a type shorthand T; when the shorthand special key declared by the user matches the variable value, if the shorthand special key is T, then T is the name of the variable that has been declared, and if the shorthand special key is a value of the T type, then T is the type of value. After the meaning of a specific T is obtained, more detailed processing is performed in the grammar checking and highlighting stage.
(4) Regarding variable assignment in a grammar structure of a target text class programming language, firstly deriving an assigned value into a basic Number type so as to be successfully matched, and then obtaining the type of assigning the assigned value to the assigned variable according to the type designated by the assigned variable in a user statement through backtracking a grammar tree in a subsequent grammar checking stage to realize variable assignment.
For example, when performing variable assignment in a code segment, the type of variable may not be obtained from the current statement. For example, when a segment of input is obtainedLOCALVAR0 := 1When it is required to obtain whether the value 1 is of the INT (signed integer) or UINT (unsigned integer) type, according to the design scheme: in the grammar description stage, 1 is deduced to be a basic Number type so that the basic Number type is successfully matched, in the subsequent grammar checking stage, the type of the LOCALVAR0 appointed in a variable declaration area is obtained through backtracking a grammar tree, namely, the type of 1 to be assigned to the LOCALVAR0 is obtained, and variable assignment is realized.
And B, analyzing the target grammar description file by using an LR analyzer in the Lezer grammar analysis system to obtain an abstract grammar tree and a virtual tree carrying text information, and then entering the step C.
And C, recursively checking the abstract grammar tree and the virtual tree carrying text information, developing and constructing each plug-in and each assembly for realizing the following preset code operation functions by using JavaScript language, and then entering step D.
(1) A grammar checking plug-in for checking the virtual tree, eliminating the unprocessed lexical ambiguity in the grammar description stage, judging the validity of the tree node type, and locating and marking the abnormal node when the abnormality occurs, such as prompting by using wave underline, as shown in the figure 2, wherein the code block of the IF ELSEIF is abnormal.
In practical application, regarding the checking of the virtual tree by the syntax checking plug-in, based on the caching of the virtual tree, the syntax checking plug-in performs syntax checking on the cached syntax tree without syntax parsing on the code segment which is not changed after being closed; after the user stops inputting the preset time length, further executing grammar checking by the grammar checking plug-in based on grammar analysis processing.
Particularly, due to the high-frequency input possibly occurring in the web-side editor, if high-time-consuming grammar checking operation is performed at the same time, the CPU and the memory are occupied, so that page clamping is caused, and user experience is reduced. The performance optimization scheme adopted according to the design is as follows: the virtual tree is cached and syntax parsing is not performed for code segments like VAR/end_var, IF/end_if etc. that have been closed unchanged, using the syntax tree that has been cached. The method of throttle checking is used, namely when a user stops inputting for a period of time (for example, after 30 ms), the grammar checking is performed based on grammar analysis processing, so that the performance loss can be greatly reduced, and the user experience is improved.
(2) And the grammar highlighting plug-in is used for distributing css class names to different node types and distinguishing the styles of the nodes.
(3) The code prompting plug-in is used for checking the context of the node, deducing the content possibly input by the user next and prompting the user, and as shown in fig. 2, the user inputs TON to prompt the input and output parameters of the on-delay function block.
(4) And setting a breakpoint plug-in for setting a breakpoint for the clicked code line.
(5) And the variable list mode switching component is used for generating corresponding array data according to variable attributes described in the IEC61131-3 programming language standard and supporting the mutual conversion between the target text class programming language of the variable part and the array.
Configuring each plug-in and components, namely a grammar checking plug-in, a grammar highlighting plug-in, a code prompting plug-in, a breakpoint setting plug-in and a variable list mode switching component on a target web-side online editor such as a codeMirror editor, thereby forming a code editor for a target text class programming language and integrating the code editor into web projects.
According to the design, a user can access the deployed web project by using a browser in any system and any platform to program codes of any target text programming language in the PLC (program logic controller) about ST structured texts and IL instruction sheets, as shown in fig. 2 and 3.
According to the text programming language code editor construction method based on the Web end designed by the technical scheme, due to the advantage of cross-platform of the Web end, developers do not need to pay attention to the difference of platforms, can pay more attention to the development of business logic, only need to use a Javascript language to maintain a set of codes, compress and confuse the codes through a compiling tool such as weback, flexibly select a deployment scheme according to requirements, for example, deploy front-end resource files (html, css, compiled Javascript codes and the like) to a server through a B/S (browser/server) architecture, or package the front-end resource files into desktop application (essentially a chrome open source version browser) through an Electron construction tool, so that efficient hardware coding operation can be realized; in practical application, web pages and PLC IDE programming software of each large manufacturer in the prior art keep the same interactive logic (supporting grammar highlighting, grammar checking, code prompting, breakpoint, variable list supporting form and editor modes and the like), so that when a user switches to a web end from using software, the learning cost is almost low.
The embodiments of the present invention have been described in detail with reference to the drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the spirit of the present invention.

Claims (7)

1. A method for constructing a text programming language code editor based on a Web end is characterized by comprising the following steps: the method comprises the steps of executing the following steps of A to D, and constructing a code editor which is based on a Web end and is used for a target text class programming language;
step A, according to a preset description rule, applying grammar structures of grammar description target text programming languages corresponding to an LR parser in a Lezer grammar parsing system to obtain a target grammar description file, and then entering step B;
b, an LR parser in a Lezer grammar parsing system is applied, a target grammar description file is parsed, an abstract grammar tree and a virtual tree carrying text information are obtained, and then the step C is carried out;
step C, recursively checking an abstract grammar tree and a virtual tree carrying text information, constructing each plug-in unit and each assembly for realizing the operation function of each preset code, and then entering the step D;
and D, configuring each plug-in and each component in the target web-end online editor, namely forming a code editor for the target text programming language, and integrating the plug-in and the components into the web project.
2. The method for constructing the text-based programming language code editor based on the Web terminal according to claim 1, wherein the method comprises the following steps: in the step A, according to a preset description rule, a grammar corresponding to an LR parser in a Lezer grammar parsing system is applied to describe program statement, type statement, variable statement, IF statement, CASE statement, FOR loop statement, WHILE statement, REPEAT statement, assignment statement and definition internal keywords, so that the description of the grammar structure of the target text programming language is completed, and a target grammar description file is obtained.
3. A method for constructing a text-based programming language code editor based on a Web terminal according to claim 1 or 2, wherein: the preset description rule in the step A comprises the following steps:
based on marks corresponding to preset priorities, marking the corresponding marks of the corresponding priorities for each processing action of each data in a grammar structure of the target text programming language, and meeting the execution sequence of each processing action of each data in the grammar structure;
regarding the built-in keywords of the grammar structure of the target text programming language, defining the built-in keywords of the grammar structure of all the target text programming languages in a VAR { VAR } form based on a way of enumerating 26-bit English letters token;
regarding each object name used except the built-in keywords in the grammar structure of the target text programming language, judging whether the object name is declared by a user or not through a subsequent grammar checking stage and a grammar highlighting stage, if so, indicating that the object name is declared by the user and is correct to use; otherwise, the object name is not declared by the user and is not used correctly;
in the grammar structure of the target text class programming language, each shorthand special keyword declared by a user is described according to VariableDeclaration { VariableName ":" TypeName ": =" VariableValue ";" so as to realize the assignment of each shorthand special keyword; when the shorthand special keyword declared by the user is matched with the TypeName, the shorthand special keyword is used as a type shorthand; when the shorthand special key declared by the user is matched with the variable value, if the shorthand special key is a variable name, the shorthand special key is used as the variable name declared by the user, and if the shorthand special key is a value of a data value type, the shorthand special key is used as the type of the data value;
regarding variable assignment in a grammar structure of a target text class programming language, firstly deriving an assigned value into a basic Number type so as to be successfully matched, and then obtaining the type of assigning the assigned value to the assigned variable according to the type designated by the assigned variable in a user statement through backtracking a grammar tree in a subsequent grammar checking stage to realize variable assignment.
4. A method for constructing a text-based programming language code editor based on a Web terminal according to claim 3, wherein: the object names comprise program names, type names, variable names and parameter names.
5. The method for constructing the text-based programming language code editor based on the Web terminal according to claim 1, wherein the method comprises the following steps: in the step C, recursively checking an abstract syntax tree and a virtual tree carrying text information, and constructing various plug-ins and components for realizing the following preset code operation functions;
a grammar checking plug-in for checking the virtual tree, eliminating the unprocessed lexical ambiguity in the grammar description stage, judging the validity of the tree node type, and locating and marking the abnormal node when the abnormality occurs;
the grammar highlighting plug-in is used for distributing css class names for different node types and distinguishing the patterns of the nodes;
a code prompt plug-in for checking the context of the node, deducing the content which the user may input next, and prompting the user;
setting a breakpoint plug-in, which is used for setting a breakpoint for the clicked code line;
and the variable list mode switching component is used for generating corresponding array data according to variable attributes described in the IEC61131-3 programming language standard and supporting the mutual conversion between the target text class programming language of the variable part and the array.
6. The method for constructing the text-based programming language code editor of the Web-based application of claim 5 wherein the steps of: regarding the checking of the virtual tree by the grammar checking plug-in, based on the caching of the virtual tree, the code segments which are closed and have not changed are not subjected to grammar analysis, and the grammar checking plug-in executes grammar checking on the cached grammar tree; after the user stops inputting the preset time length, further executing grammar checking by the grammar checking plug-in based on grammar analysis processing.
7. The method for constructing the text-based programming language code editor based on the Web terminal according to claim 1, wherein the method comprises the following steps: the target web end online editor is a codeMirror editor.
CN202310440086.9A 2023-04-23 2023-04-23 Method for constructing text programming language code editor based on Web end Pending CN116540986A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310440086.9A CN116540986A (en) 2023-04-23 2023-04-23 Method for constructing text programming language code editor based on Web end

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310440086.9A CN116540986A (en) 2023-04-23 2023-04-23 Method for constructing text programming language code editor based on Web end

Publications (1)

Publication Number Publication Date
CN116540986A true CN116540986A (en) 2023-08-04

Family

ID=87456964

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310440086.9A Pending CN116540986A (en) 2023-04-23 2023-04-23 Method for constructing text programming language code editor based on Web end

Country Status (1)

Country Link
CN (1) CN116540986A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117193739A (en) * 2023-11-03 2023-12-08 建信金融科技有限责任公司 Script editing method and device
CN117406973A (en) * 2023-12-13 2024-01-16 上海群之脉信息科技有限公司 Interactive data analysis method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117193739A (en) * 2023-11-03 2023-12-08 建信金融科技有限责任公司 Script editing method and device
CN117406973A (en) * 2023-12-13 2024-01-16 上海群之脉信息科技有限公司 Interactive data analysis method and device
CN117406973B (en) * 2023-12-13 2024-03-12 上海群之脉信息科技有限公司 Interactive data analysis method and device

Similar Documents

Publication Publication Date Title
CN109254776B (en) Multi-language code compiling method and compiler
CN116540986A (en) Method for constructing text programming language code editor based on Web end
US7657878B2 (en) Compiler, method of compiling and program development tool
CN109918081A (en) A kind of Compilation Method and compiler
CN110096264A (en) A kind of code operation method and device
CN113987405A (en) AST-based mathematical expression calculation algorithm
CN110442520B (en) Cross debugging system and method based on PLC programming language
RU2115158C1 (en) Method and device for confident estimation of semantic symbols in syntax analysis when passing forward from left to right
CN116595967A (en) Natural language rule writing method based on text and related device
KR20090011974A (en) Method for extracting the target files of compilation
Wipliez et al. Code generation for the MPEG reconfigurable video coding framework: From CAL actions to C functions
CN110737431B (en) Software development method, development platform, terminal device and storage medium
Masiero et al. Development and instantiation of a generic application generator
US6948159B2 (en) Automatic compilation of electronic telecommunications system message generation code
US7506287B2 (en) Method, system, and program product for pre-compile processing of hardware design language (HDL) source files
Silva Compiler Front-end for the IEC 61131-3 v3 Languages
Jordan et al. The Development of Lexer and Parser as parts of compiler for GAMA32 processor’s instruction-set using Python
Lu et al. A formal methodology using attributed grammars for multiprocessing-system software development. I. Design representation
Berezowski et al. A Brief Subset for Functional Safety in LabVIEW
KR100246544B1 (en) Thread creation method for parallel constructs on high speed parallel computer
CN114138641A (en) Logic diagram compiling detection method, system, electronic device and storage medium
CN117130610A (en) Page generation method, related device and computer storage medium
Staroletov Grammar-Based Testing a Process-Oriented Extension of the IEC 61131-3 Structured Text Language
Nagl Characterization of Shallow and Deep Reuse
Dahl et al. Prototyping Compiler and Simulation Tools with PCCTS

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