CN111538504A - Syntax information extraction method, equipment and storage medium based on solid intelligent contract - Google Patents

Syntax information extraction method, equipment and storage medium based on solid intelligent contract Download PDF

Info

Publication number
CN111538504A
CN111538504A CN202010297066.7A CN202010297066A CN111538504A CN 111538504 A CN111538504 A CN 111538504A CN 202010297066 A CN202010297066 A CN 202010297066A CN 111538504 A CN111538504 A CN 111538504A
Authority
CN
China
Prior art keywords
grammar
node
information
current
service class
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
CN202010297066.7A
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.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian 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 Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202010297066.7A priority Critical patent/CN111538504A/en
Publication of CN111538504A publication Critical patent/CN111538504A/en
Pending legal-status Critical Current

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
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a syntax information extraction method, equipment and a storage medium based on a solid intelligent contract, which comprises the following steps: calling a first indexing algorithm to construct a first service class corresponding to the current grammar node and simultaneously storing an index relation of grammar information of the current grammar node; calling a grammar filling algorithm to fill grammar information of the current first service class; calling the next-layer grammar node service class to fill grammar information corresponding to the next-layer service class until all the service classes are filled; and sequencing the inheritance sequence of the contracts to acquire inheritance line information of each contract so as to accurately realize the tracing of each expression type in the contracts. The invention ensures that each grammar node can fully acquire the grammar information of the grammar node by recursively establishing a tree-shaped data structure consisting of the grammar node service classes, thereby solving the problems of incomplete and inaccurate grammar information extraction of the grammar information extraction method based on traversal of the grammar tree.

Description

Syntax information extraction method, equipment and storage medium based on solid intelligent contract
Technical Field
The application relates to the technical field of block chains, in particular to a syntax information extraction method, equipment and a storage medium based on a solid intelligent contract.
Background
Intelligent contracts are automatically executed by a computer system as a set of digitally defined commitments that govern digital assets and that contain the rights and obligations agreed upon by contract participants. The combination of intelligent contracts and the block chain technology is an emerging product, the technology is very immature, various business processes or technical bugs from an application business to a compiler to a virtual machine and then to the bottom layer of the block chain exist, and many online intelligent contract projects frequently reveal security problems. Because smart contracts are difficult to tamper with once deployed to a blockchain, how to fully secure the security of the smart contracts prior to deployment becomes a critical step. Most security solutions for verifying intelligent contracts need to analyze and audit contract codes at a grammatical level, and the completeness, the accuracy and the timeliness of grammar information acquisition cannot be guaranteed. The existing solutions based on syntax analysis can only judge whether the syntax elements with risks appear in the system from the code level, and such methods cannot judge the actual execution logic and the generated action result of the code, and have the following problems: 1. developers need to judge whether a certain section of code has risks according to actual experience and problems generated in program operation, only traverse problematic parts of a syntax tree according to established rules, and do not fully apply syntax information in the code; 2. static inspection only carries out grammatical matching and inspection on codes, context information in a program cannot be accurately sensed, obtained grammatical information is inaccurate, and false alarm is easy to generate; for example, an int type variable age is used for representing the age of a user, after the past year, the age of the user is +1, static inspection only verifies that the addition operation has overflow risk, but actually the age of the user cannot exceed 1000 years at most, and the syntax tree is traversed in a mode that only addition is used, but an operand using the addition cannot be found to be in an int type; 3. the information among all the grammar nodes is not related, the dynamic operation of a program is not considered, and the grammar information stated by other grammar nodes can not be considered when a grammar node is traversed.
Disclosure of Invention
In view of the above-mentioned drawbacks and deficiencies of the prior art, it is desirable to provide a method, an apparatus, and a storage medium for extracting syntax information based on a solid smart contract, which can accurately and completely extract the latest syntax information.
In a first aspect, the invention provides a method for extracting grammatical information based on a identity intelligent contract, which comprises the following steps:
calling a first index algorithm to construct a first service class corresponding to the current syntax node and simultaneously storing an index relation of the syntax information of the current syntax node in a second service class of a father node of the current node; repeatedly executing the calling step to establish a corresponding grammar service class for the child node until a leaf grammar node appears, wherein the construction parameters of the first service class comprise grammar information of the current grammar node and the second grammar service class;
calling a grammar filling algorithm to fill grammar information of the current first service class, and finishing type tracing of variables and determining scope of the variables; calling the next-layer grammar node service class to fill grammar information corresponding to the next-layer service class until all the service classes are filled;
and sequencing the inheritance sequence of the contracts to acquire inheritance line information of each contract so as to accurately realize the tracing of each expression type in the contracts.
Further, the step of calling a first indexing algorithm to construct a first service class corresponding to the current syntax node includes:
judging whether the current grammar node has a sub grammar node:
and if so, constructing the first service class according to the current grammar node information and the second language service class.
Further, the corresponding operations of calling the first indexing algorithm and calling the grammar filling algorithm are all executed from the root node of the grammar tree in a recursive mode.
Further, the simultaneously performing type tracing of the variables and determining the scope of the variables comprises:
judging whether the current grammar node contains a grammar node defined by variables: if yes, traversing upwards from the current grammar node to acquire the type information of the variable;
and copying and storing a first variable type table of a father syntax node service class of the current syntax node service class as a second variable type table of the current syntax node, and updating the variable definition type contained in the current syntax node according to the second variable type table.
Further, the invoking the grammar filling algorithm to fill grammar information of the current first service class includes at least one of: such as compiled versions, contract imports, contract definitions, enumeration definitions, structure definitions, function definitions, library definitions, modifier definitions, variable names, variable visibility, statement blocks, code statements, expressions.
Further, the step of ordering the inheritance sequence of the contracts to obtain inheritance line information of each contract so as to accurately realize tracing of each expression type in the contracts comprises the following steps: :
acquiring direct inheritance information of each contract according to contract definition information filled by calling a grammar filling algorithm, namely directly inheriting which contracts of the current contract, specifying the current contract in an inheritance specifier of the contract, analyzing inheritance relationships among different contracts in a contract file according to a C3 inheritance method observed by a solid multi-inheritance mechanism, and finally acquiring all contract information inherited by each contract;
when the expression is traced, if the current expression node contains a next-layer grammar node, determining the sub-expression node information of the current expression node according to the determined sub-expression node information, and determining the type information of the current expression according to the operation result;
and calling an expression type tracing method of the newly-established sub-grammar nodes according to the index relationship, so that the current expression service class recursively fills the next layer of expression type information until all expressions in the contract are determined to obtain specific types.
In a second aspect, the present invention also provides an apparatus comprising one or more processors and a memory, wherein the memory contains instructions executable by the one or more processors to cause the one or more processors to perform a method for syntax information extraction based on a identity smart contract provided according to embodiments of the present invention.
In a third aspect, the present invention further provides a storage medium storing a computer program for causing a computer to execute the syntax information extraction method based on the identity smart contract according to the embodiments of the present invention.
The syntax information extraction method, the equipment and the storage medium based on the intelligent contract for the identity based on the identity provided by the embodiments of the invention enable each syntax node to fully acquire the syntax information of the syntax node by a mode of recursively establishing a tree-shaped data structure composed of the service classes of each syntax node, and simultaneously can access the syntax information of a sub syntax node or a father syntax node through indexes among the syntax nodes, so as to acquire type information and expression information in a code, solve the problems of incomplete and inaccurate syntax information extraction of the syntax information extraction method based on syntax tree traversal, and realize the technical effect of fully acquiring the syntax information of the contract through the tree-shaped data structure composed of the service classes of the syntax nodes.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
fig. 1 is a flowchart of a syntax information extraction method based on a solid intelligent contract according to an embodiment of the present invention.
FIG. 2 is a flow diagram of a preferred embodiment of the method shown in FIG. 1.
Fig. 3 is a schematic view of a preferred embodiment of the method shown in fig. 2.
FIG. 4 is a flow chart of a preferred embodiment of the method of FIG. 1.
Fig. 5 is a flow chart of a preferred embodiment of step S13 of the method of fig. 1.
Fig. 6 is a schematic diagram of a backtracking process scenario of a preferred embodiment of the method shown in fig. 1.
Fig. 7 is a schematic structural diagram of an apparatus according to an embodiment of the present invention.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 is a flowchart of a syntax information extraction method based on a solid intelligent contract according to an embodiment of the present invention.
As shown in fig. 1, in this embodiment, the present invention provides a syntax information extraction method based on a identity smart contract, including:
s11, calling a first indexing algorithm to construct a first service class corresponding to the current syntax node and simultaneously saving the indexing relation of the syntax information of the current syntax node in a second service class of a father node of the current node; repeatedly executing the calling step to establish a corresponding grammar service class for the child node until a leaf grammar node appears, wherein the construction parameters of the first service class comprise grammar information of the current grammar node and the second grammar service class;
s12, calling a grammar filling algorithm to fill grammar information of the current first service class, and finishing type tracing of variables and determining scope of the variables; calling the next-layer grammar node service class to fill grammar information corresponding to the next-layer service class until all the service classes are filled;
and S13, sequencing the inheritance sequence of the contracts to acquire inheritance line information of each contract so as to accurately realize the tracing of each expression type in the contracts.
Specifically, before the method is applied, ANTLR grammar can be used for parsing, and a developer uses ANTLR to parse the grammar according to the identity grammar rule to obtain information of a grammar parsing tree corresponding to the current contract;
in step S11, traversing the grammar node, and creating an index of the grammar node corresponding to the service class. Traversing each grammar node from a root grammar node SourceUnit according to the relation of a parse tree, calling a first index algorithm to newly establish a service class corresponding to each grammar node, and establishing indexes among the grammar nodes at the same time, so that each grammar node service class can contain other grammar node service classes.
More, the business class corresponding to the contract file comprises a compilation control statement, a contract import statement and a contract definition. Wherein, business classes defined by various contract members are recursively established in the contract definition, and the main idea of the business classes is not particularly changed. However, in the whole recursion process, the statement block is used as a special service class, syntax extraction modes are different, when syntax extraction is performed on the block, extraction of the service class corresponding to the statement and extraction of the service class corresponding to the expression are performed, firstly, the corresponding service class needs to be created according to the type of the statement or the expression, and then traversal is performed.
In step S12, since the syntax node information is used as a member of the service class corresponding to the syntax node when the index is constructed, each service class can call a syntax filling algorithm to fill the corresponding field describing the syntax information in the service class according to the syntax node information corresponding to its own node. Meanwhile, in the process of filling the grammar information, the type of the variable and the scope of the variable are determined.
More, invoking the grammar filling algorithm to fill grammar information of the current first service class includes at least one of: such as compiled versions, contract importation, contract definitions, enumeration definitions, structure definitions, function definitions, library definitions, modifier definitions, variable names, variable visibility, statement blocks, code statements, expressions, and the like.
In step S13, since the service class of the contract import information is newly created in step S11, the syntax node information of the import sentence is filled in step S12. According to the C3 inheritance method followed by the Solidiy contract multi-inheritance mechanism, the inheritance sequence of the contract is sequenced by using an MRO algorithm, and inheritance line information of the contract is obtained, so that support is provided for finding a certain state variable definition or function definition in the contract in the following expression tracing.
In more embodiments, the calling methods all traverse from the root grammar node SourceUnit of the parse tree.
FIG. 2 is a flow diagram of a preferred embodiment of the method shown in FIG. 1. As shown in fig. 2, in this embodiment, invoking a first indexing algorithm to construct a first service class corresponding to the current syntax node includes:
s110, judging whether the current grammar node has a sub grammar node:
and if so, constructing the first service class according to the current grammar node information and the second language service class.
Specifically, as shown in fig. 3, an application scenario of the service class is constructed, and as can be seen from the abstract syntax tree, the function definition (functional definition) syntax node is composed of a function key (function), a function name identifier (identifier), a function parameter list (parameterList), a modifier list (modifierList), a return parameter (return parameters), and a statement block (block).
Only recursively constructing grammar node service classes for grammar nodes with child nodes when the grammar is extracted and the indexes are established; assuming that an upper-layer syntax node calls a method for establishing an index, a function definition syntax node service class (function definitionInfo) is established, and a method for establishing the index is called to establish the service class for a lower-layer syntax node; function name identifier (identifier) and function parameter list (parameterList) in the function-defined child node have child syntax nodes, so that the syntax node service classes corresponding to the function name identifier (identifier) and the function parameter list (parameterListInfo) are constructed, and when the service classes are constructed, the syntax information (Context) of the syntax node and the function definition service class (function DefinitionInfo) are referenced as parameters and are transmitted to the construction function of the service class. After the syntax node service classes are constructed, the function definition service classes store references to the service classes. Then, an indexing algorithm is called to recursively construct a lower-layer syntax node index. Until a syntax node is encountered which is a terminal node (terminalnode), i.e., a syntax node without children.
For example, a function parameter list service class (ParameterListInfo) is constructed for a function parameter list reference list (parameterList) of child nodes of a function definition syntax node (function definition), i.e., a reference of function list syntax node information (ParameterListContext) and a parent syntax node service class (function definitioninfo) is passed to a constructor.
FIG. 4 is a flow chart of a preferred embodiment of the method of FIG. 1. As shown in fig. 4, in this embodiment, the step S12 of simultaneously completing type tracing of the variable and determining the scope of the variable includes:
s122, judging whether the current grammar node contains a grammar node defined by variables: if yes, traversing upwards from the current grammar node to acquire the type information of the variable;
s123, copying and storing the first variable type table of the father grammar node service class of the current grammar node service class as a second variable type table of the current grammar node, and updating the variable definition type contained in the current grammar node according to the second variable type table.
Specifically, a variable list under the current context is built in each function (function), statement block (block). The specific method is to detect whether the statement is related to variable definition before filling grammar; for example, when filling the function definition, it is necessary to read the definition information of the state variable in the parent node, and then read the function entry parameter definition information and the function return value definition information of itself; when filling the block syntax node information, the block needs to copy a variable list from the father node, and then fill a new variable definition into the copied variable list according to the statement type defined in the block. And when a new block appears recursively later, in the same way, if the same-name variable appears, covering the previous definition at the current grammar node.
Fig. 5 is a flow chart of a preferred embodiment of step S13 of the method of fig. 1. As shown in fig. 5, in the present embodiment, step 13 includes:
s131, obtaining direct inheritance information of each contract according to the contract definition information filled by calling a grammar filling algorithm, namely, directly inheriting the contracts of the current contract, specifying the contracts in an inheritanceSpecifier of the contract, and finally obtaining all contract information inherited by each contract;
s132, during expression tracing, if the current expression node comprises a next-layer syntax node, determining sub-expression node information of the current expression node according to the determined sub-expression node information, and determining type information of the current expression according to an operation result;
and S133, calling an expression type tracing method of the newly-established sub-grammar nodes according to the index relationship, so that the current expression service class recursively fills the next layer of expression type information until all expressions in the contract are determined to obtain specific types.
Specifically, expression tracing is performed on all syntax node service classes containing expressions in a recursive manner from a root node. All the final recursion bases of the expression tracing are basic expressions (primaryExpression), and when the basic expression type is traced, definition information of variables can be searched from a statement block variable (block) list or a function keyword (function) variable list of the expression, a current contract and a parent contract, so that the type of the basic expression is obtained; and backtracking after filling the type of the basic expression, and determining the type of the current expression according to the type of the sub-expression and the operation type of the expression during backtracking.
The backtracking process of expression tracing is described by taking fig. 6 as an example.
For the expression h? And (d) e, (f) g), wherein a, b and c in the expression are int types, d and e are uint types, both are byte types, and h is a pool type. h is an identifier and represents a pool type variable, the expression is traced back to a leaf node, and the expression h is determined to be the pool type by tracing back to the previous layer.
According to the ANTLR rule, the expression can be parsed into an expression tree as shown in fig. 6, the expression is the root node of the whole tree, and is first parsed into an assignment statement according to the rule, the expression h is assigned, and is (a + b) × c > 0? And (d) assigning the calculation result of (f) to the expression h.
Firstly, expression tracing is carried out on an expression h, the expression h is an identifier, the expression h is a pool type, the expression tracing reaches a leaf node and reaches a recursion base, and the expression h is determined to be the pool type by tracing the previous layer.
In the case of expression (a + b) × c > 0? (d > e): (f ═ g) tracing an expression which is a trinocular arithmetic expression, if? The left conditional expression (a + b) × c >0, the expression result is the operation result (d > e) to the left of the colon, otherwise, the operation result (f ═ g) to the right of the colon.
Performing expression tracing on the three expressions recursively, and specifically comprising the following steps:
for an expression (a + b) × c >0 on the left of the question mark, which is a comparison operation expression, an operation expression on the left of the greater than mark and 0 on the right, the type can be determined to be an integer. The left expression (a + b) × c is a multiplication expression, the left is an (a + b) bracket expression, the right is a variable c, and c is determined to be an integer. And the left bracket expression (a + b) represents the priority of operation, the type of the expression is determined by the type of the a + b expression, the a + b expression is an addition expression, the type of the a is int, and the type of the b is int. At this time, the leaf node is reached, no child node which can recurse exists, and the trace is traced back to the next layer. Then the operation result of a + b is int type, the operation result of (a + b) × c is int type, and the operation result of (a + b) × c >0 is pool type.
For the parenthesized expression (d > e) to the left of the colon, the expression type is determined by the expression d > e; d > e is a comparison operation expression, the type of d is uint, and the type of e is uint. At this time, the root node is reached, no child nodes which can recurse exist, and the trace is traced back to the next layer. Then the result of the operation d > e is of the pool type and the result of the operation d > e is of the pool type.
Likewise, for the parenthetical expression (f ═ g) to the right of the colon, the expression type is determined by the expression f ═ g; f is a comparison operation expression, f is a byte, and g is a byte. At this time, the root node is reached, no child nodes which can recurse exist, and the trace is traced back to the next layer. Then the result of the operation of f ═ g is of the bool type and the result of the operation of f ═ g is of the bool type.
Thus, when three expressions (a + b) × c, (d > e), (f ═ g) are traced back, the expression (a + b) × c > 0? The type of (d > e): (f ═ g) can be determined as a bool type. Finally, go back to the whole expression h ═ 0? And (d) e, (f) g), determining that the expression is of the bool type, and thus finishing the tracing of the corresponding expression.
Fig. 7 is a schematic structural diagram of an apparatus according to an embodiment of the present invention.
As shown in fig. 7, as another aspect, the present application also provides an apparatus 600 including one or more Central Processing Units (CPUs) 601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the apparatus 600 are also stored. The CPU601, ROM602, and RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to an embodiment of the present disclosure, any of the above embodiments describes a syntax information extraction method based on a identity smart contract.
A computer program product comprising a computer program tangibly embodied on a machine-readable medium, the computer program including program code for performing a method for syntax information extraction based on a identity intelligence contract. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611.
As yet another aspect, the present application also provides a computer-readable storage medium, which may be the computer-readable storage medium included in the apparatus of the above-described embodiment; or it may be a separate computer readable storage medium not incorporated into the device. The computer readable storage medium stores one or more programs for use by one or more processors in performing the extraction methods described herein.
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 invention. 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 or modules described in the embodiments of the present application may be implemented by software or hardware. The described units or modules may also be provided in a processor, for example, each of the described units may be a software program provided in a computer or a mobile intelligent device, or may be a separately configured hardware device. Wherein the designation of a unit or module does not in some way constitute a limitation of the unit or module itself.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the present application. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (9)

1. A syntax information extraction method based on a solid intelligent contract is characterized by comprising the following steps:
calling a first index algorithm to construct a first service class corresponding to the current syntax node and simultaneously storing an index relation of the syntax information of the current syntax node in a second service class of a father node of the current node; repeatedly executing the calling step to establish a corresponding grammar service class for the child node until a leaf grammar node appears, wherein the construction parameters of the first service class comprise grammar information of the current grammar node and the second grammar service class;
calling a grammar filling algorithm to fill grammar information of the current first service class, and finishing type tracing of variables and determining scope of the variables; calling the next-layer grammar node service class to fill grammar information corresponding to the next-layer service class until all the service classes are filled;
and sequencing the inheritance sequence of the contracts to acquire inheritance line information of each contract so as to accurately realize the tracing of each expression type in the contracts.
2. The method of claim 1, wherein invoking a first indexing algorithm to construct a first service class corresponding to the current syntax node comprises:
judging whether the current grammar node has a sub grammar node:
and if so, constructing the first service class according to the current grammar node information and the second language service class.
3. The method according to claim 1 or 2, wherein the corresponding operations of invoking the first indexing algorithm and invoking the syntax filling algorithm are each performed recursively from a root node of the syntax tree.
4. The method of claim 3, wherein the simultaneously performing type tracing of variables and determining scopes of variables comprises:
judging whether the current grammar node contains a grammar node defined by variables: if yes, traversing upwards from the current grammar node to acquire the type information of the variable;
and copying and storing a first variable type table of a father syntax node service class of the current syntax node service class as a second variable type table of the current syntax node, and updating the variable definition type contained in the current syntax node according to the second variable type table.
5. The method of claim 4, wherein invoking the grammar filling algorithm to fill grammar information for the current first service class comprises at least one of: such as compiled versions, contract imports, contract definitions, enumeration definitions, structure definitions, function definitions, library definitions, modifier definitions, variable names, variable visibility, code blocks, code statements, expressions.
6. The method according to claim 4 or 5, characterized in that: the step of sequencing the inheritance sequence of the contracts to acquire inheritance line information of each contract so as to accurately realize the tracing of each expression type in the contracts comprises the following steps:
obtaining direct inheritance information of each contract according to the contract definition information filled by calling a grammar filling algorithm, namely, directly inheriting which contracts of the current contract and specifying the current contract in an inheritanceSpecifier of the contract, and finally obtaining all contract information inherited by each contract;
when the expression is traced, if the current expression node contains a next-layer grammar node, determining the sub-expression node information of the current expression node according to the determined sub-expression node information, and determining the type information of the current expression according to the operation result;
and calling an expression type tracing method of the newly-established sub-grammar nodes according to the index relationship, so that the current expression service class recursively fills the next layer of expression type information until all expressions in the contract are determined to obtain specific types.
7. The method of claim 6, wherein the C3 inheritance method followed by the solid contract multiple inheritance mechanism is applied, and the inheritance order of the contracts is ordered by using MRO algorithm to obtain inheritance line information of the contracts.
8. An apparatus, characterized in that the apparatus comprises:
one or more processors;
a memory for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method recited in any of claims 1-7.
9. A storage medium storing a computer program, characterized in that the program, when executed by a processor, implements the method according to any one of claims 1-7.
CN202010297066.7A 2020-04-15 2020-04-15 Syntax information extraction method, equipment and storage medium based on solid intelligent contract Pending CN111538504A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010297066.7A CN111538504A (en) 2020-04-15 2020-04-15 Syntax information extraction method, equipment and storage medium based on solid intelligent contract

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010297066.7A CN111538504A (en) 2020-04-15 2020-04-15 Syntax information extraction method, equipment and storage medium based on solid intelligent contract

Publications (1)

Publication Number Publication Date
CN111538504A true CN111538504A (en) 2020-08-14

Family

ID=71974978

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010297066.7A Pending CN111538504A (en) 2020-04-15 2020-04-15 Syntax information extraction method, equipment and storage medium based on solid intelligent contract

Country Status (1)

Country Link
CN (1) CN111538504A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113051624A (en) * 2021-03-19 2021-06-29 南京航空航天大学 Intelligent contract information flow integrity verification method and system based on type detection

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113051624A (en) * 2021-03-19 2021-06-29 南京航空航天大学 Intelligent contract information flow integrity verification method and system based on type detection
CN113051624B (en) * 2021-03-19 2024-05-07 南京航空航天大学 Intelligent contract information flow integrity verification method and system based on type detection

Similar Documents

Publication Publication Date Title
CN107704265B (en) Configurable rule generation method for service flow
US11561772B2 (en) Low-code development platform
Heckel et al. Graph Transformation for Software Engineers
US20230114540A1 (en) Checking source code validity at time of code update
US20200210158A1 (en) Automated or machine-enhanced source code debugging
US10452369B2 (en) Code profiling of executable library for pipeline parallelization
CN107704382A (en) Towards Python function call path generating method and system
CN112394942A (en) Distributed software development compiling method and software development platform based on cloud computing
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
US10789154B2 (en) Client server computer code mapping and visualization
Klatt et al. A graph-based analysis concept to derive a variation point design from product copies
CN116406459A (en) Code processing method, device, equipment and medium
CN110673837A (en) Code repairing method and device, electronic equipment and computer readable storage medium
US10915302B2 (en) Identification and visualization of associations among code generated from a model and sources that affect code generation
US11275567B1 (en) Making communication interfaces pluggable by using mechanisms comprising of exchange/broker for communication interfaces
CN111538504A (en) Syntax information extraction method, equipment and storage medium based on solid intelligent contract
Bertolotti et al. On the granularity of linguistic reuse
US10831473B2 (en) Locating business rules in application source code
Dudziak et al. Tool-supported discovery and refactoring of structural weaknesses in code
Bibartiu et al. Clams: a cloud application modeling solution
CN115794214A (en) Application module metadata management method, device, storage medium and device
Giachetti et al. Integration of domain-specific modelling languages and UML through UML profile extension mechanism.
Dalibor et al. Mind the gap: lessons learned from translating grammars between MontiCore and Xtext
Vasani Roslyn Cookbook
Boussabbeh et al. Formal proofs of termination detection for local computations by refinement-based compositions

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