CN111124422A - EOS intelligent contract language conversion method based on abstract syntax tree - Google Patents

EOS intelligent contract language conversion method based on abstract syntax tree Download PDF

Info

Publication number
CN111124422A
CN111124422A CN201911357483.XA CN201911357483A CN111124422A CN 111124422 A CN111124422 A CN 111124422A CN 201911357483 A CN201911357483 A CN 201911357483A CN 111124422 A CN111124422 A CN 111124422A
Authority
CN
China
Prior art keywords
translation
abstract syntax
sugar
layer
syntax tree
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.)
Granted
Application number
CN201911357483.XA
Other languages
Chinese (zh)
Other versions
CN111124422B (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.)
Chengdu Mutual Credit Online Technology Co Ltd
University of Electronic Science and Technology of China
Original Assignee
Chengdu Mutual Credit Online Technology Co Ltd
University of Electronic Science and Technology of China
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 Chengdu Mutual Credit Online Technology Co Ltd, University of Electronic Science and Technology of China filed Critical Chengdu Mutual Credit Online Technology Co Ltd
Priority to CN201911357483.XA priority Critical patent/CN111124422B/en
Publication of CN111124422A publication Critical patent/CN111124422A/en
Application granted granted Critical
Publication of CN111124422B publication Critical patent/CN111124422B/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

Abstract

The invention relates to an EOS intelligent contract language conversion method based on an abstract syntax tree, which is characterized in that each node of the abstract syntax tree is stored through a child brother representation method (a binary chain table tree), EOS intelligent contract source codes can be converted into a functional equivalent formal verification language aiming at a self-defined grammar structure, and translation actions are realized together by adding a symbol table, so that a customizable translation process is realized. The EOS intelligent contract code translated by the translation method has the characteristics of clear structure, reproducibility, strong capacity expansion and strong adaptability, and solves the problem that the source code of the EOS intelligent contract cannot be verified by a formal verification method. The invention has strong expandability and very good practical application performance, and provides effective ideas and technologies for intelligent contract translation of the block chain.

Description

EOS intelligent contract language conversion method based on abstract syntax tree
Technical Field
The invention belongs to the field of computer language coding and translation, and particularly relates to an EOS intelligent contract language conversion method based on an abstract syntax tree.
Background
With the continuous development of block chain technology, many security problems in the field are gradually highlighted. Intelligent contracts are key technologies for implementing blockchain applications. Since smart contracts are distributed in software, defects in the function or logic of the code can cause serious consequences. In the afternoon of 17 th, 6.2016, the intelligent contract of the tedao running on the ether house public chain is attacked, and the public money built by the contract is continuously diverted to its sub-contract by the recursive invocation of a function, which relates to more than thirty million ether coins in total. In 7/8 afternoon in 2018, the dimension reduction security laboratory monitors that high-risk transaction exists in an Ether house intelligent contract AMR. And analyzing the code by a team, and finding that the existing integer overflow vulnerability is utilized maliciously by people, so that AMR is increased greatly. Just by the end of 2018, the vulnerability of hackers to take advantage of intelligent contracts has caused losses of over 6.3 billion dollar size. Therefore, the safety and the reliability of the intelligent contract are ensured, and the method has important significance for the safety of the blockchain and the transaction performed on the blockchain.
In recent years, a high-order logic theorem proving (HOLTP), which is one of the most strict technologies for verifying the reliability and security of a program to construct a trusted software system, is used for security verification of an ethernet intelligent contract, and compared with a traditional security test, the technology can realize a complete verification process without a security case, and greatly improve the efficiency in security verification.
However, the security verification method of HOLTP has the problem of low efficiency in manually translating contract codes into formal verification languages in the application process, and particularly, the problem is increasingly obvious when an intelligent contract source program is written by complex high-level languages such as C + + and the like an EOS intelligent contract.
Formal verification tools for Etherhouse smart contracts written by solid have begun to be used in the industry in recent years to prove that it is feasible and valuable to implement an automated translator to implement the conversion of contract languages to other programming languages, but there is no relevant work to translate EOS smart contracts to formal verification languages. When the EOS intelligent contracts are formalized, reasonable parsing and translation of C + + specific syntactic characteristics need to be realized, wherein a customized EOS intelligent contract translation scheme based on an abstract syntax tree does not have a mature solution in the industry at present.
Disclosure of Invention
The invention provides an EOS intelligent contract language conversion method based on an abstract syntax tree, aiming at the problem that the prior art does not translate an EOS intelligent contract into formal verification language.
The specific implementation content of the invention is as follows:
an EOS intelligent contract language conversion method based on abstract syntax trees comprises the following steps:
s1, performing lexical unit division on an EOS intelligent contract source program;
s2, constructing an abstract syntax tree for realizing code structure reproduction by adopting a child brother representation method;
s3, designing a sugar conversion translation method for the conversion translation of a specific morpheme type;
and S4, constructing a traversal function for traversing the abstract syntax tree by combining a supersar conversion translation method.
In order to better implement the present invention, further, when constructing an abstract syntax tree for implementing code structure reproduction, a structure τ of leaf nodes of the abstract syntax tree needs to be constructed first; the structure τ specifically includes the following attributes:
(1) construction of tau representing line number informationlineτ representing the name of a grammarnameτ representing semantic valuecontent
(2) Structure of the organizationBuilding τ representing type of variable nodetagτ representing type of expression nodetypeτ representing the value of the shaping constant nodeivalueτ representing the value of a floating-point constant nodefvalueτ representing a marker for translation of sugar conversionsugar(ii) a Wherein, the value of τ istag、τtype、τivalue、τfvalueThe type of token is distinguished when the abstract syntax tree grammar is constructed; the above-mentioned tausugarThe system is used for providing an entry for the sugar conversion translation;
(3) constructing translation traversal stop tag τs_topAnd changing the semantic value stop tag τs_change
(4) Constructing τ representing left child in child sibling representationlτ representing the right child in the child's brother representationr
In order to better implement the present invention, further, after constructing the structure τ of leaf nodes of the abstract syntax tree, the syntax organization of the EOS contract is generated into the abstract syntax tree with a reproducible code structure through child sibling representation, and the specific steps include:
the method comprises the following steps: defining a program entry of an abstract syntax tree;
step two: a plurality of grammar nodes are expressed as reduction functions through grammar induction, all the reduction functions are written out, and each reduction function represents a grammar form;
step three: integrating a plurality of unambiguous reduction functions to obtain rule functions, writing all the rule functions, wherein each rule function represents a class of grammar form;
step four: dividing a plurality of rule functions into five different levels, the five different levels comprising: the system comprises a definition layer, a type layer, a declaration layer, a statement layer and an expression layer;
the definition layer comprises grammars of various definition sentences;
the type layer comprises a grammar of a basic type, a grammar of a structure body and a grammar of a template type;
the declaration layer comprises declaration grammars of functions and parameters and grammars of a parameter list;
the statement layer comprises all statement grammars;
the expression layer includes expression grammars in all statements.
In order to better implement the present invention, further, the step s3. designing the sugar conversion translation method specifically includes the following steps:
s3.1, carrying out sugar conversion translation layering;
s3.2, compiling a symbol table for supporting the supersar conversion translation; the symbol table comprises a variable symbol table, a function symbol table and a scope symbol table;
s3.3, finding a target grammar corresponding to a specific morpheme type needing sugar conversion in the grammar structure of the abstract syntax tree;
s3.4, finding an entry of the sugar conversion translation in a target grammar corresponding to the specific morpheme type, and writing an entry function of the sugar conversion translation; and writing the interface function of the sugar conversion translation into the corresponding sugar conversion translation layer.
In order to better implement the present invention, further, step s3.1 specifically means: and (3) layering the sugar conversion translation, and dividing the sugar conversion translation into four layers: a sugar type layer, a sugar statement layer, a sugar expression layer and a sugar self-defined function layer; the super type layer corresponds to the type layer, the super statement layer corresponds to the statement layer, the super expression layer corresponds to the expression layer, and the super custom function layer corresponds to the definition layer and the declaration layer.
In order to better implement the present invention, further, in step s3.4, the interface function is written into the corresponding sugar conversion translation hierarchy, and an entry function that needs to satisfy the sugar conversion translation for any abstract syntax tree is found in the sugar conversion translation method, so as to obtain the corresponding sugar conversion translation interface function.
In order to better implement the present invention, further, the step s4 specifically includes: writing a conventional translation set to process translation operation without using a supersar conversion translation, and writing a translation function of the supersar conversion translation; the interface function of each sugar conversion translation corresponds to the translation function of one sugar conversion translation, and the translation function of the sugar conversion translation corresponding to the interface function of each sugar conversion translation can call a conventional translation set and can call the interface functions of other sugar conversion translations to realize nested translation actions.
To better implement the present invention, further, during the translation traversal in step s4, the left child is traversed, and the translation traversal stop mark τ is markeds_topThe right child is traversed if the identification continues to traverse the right child.
In order to better implement the present invention, further, the specific lexical unit division method includes the following steps:
s1.1, defining a regular expression R for morpheme identification; the morphemes comprise specific morpheme types and basic morpheme types which only need regular matching in morpheme matching;
s1.2, for a specific morpheme type, defining a mode-action matching structure in a lexical analyzer for morpheme matching and grammar analysis;
s1.3, defining character strings S correspondingly matched with regular expressions R, and formulating a matching rule based on the regular expressions R and the corresponding character strings S, wherein the matching rule ensures that each regular expression R can be matched with one character string S or a set of a plurality of character strings S of the same type; defining a regular expression that can only be matched to one string S as RnThe character string corresponding to the regular expression Rn is Sn, and the regular expression capable of matching with a plurality of character strings S is defined as
Figure BDA0002336334340000043
The matching rules are written based on the following matching sequence:
(1) matching sequence rules: defining a complete set of morpheme matching patterns as URIf the character string SnNot only can be expressed regularly
Figure BDA0002336334340000041
Matched to, can also be regular expression RnIf matched, the word elementWhen matching is carried out, the regular expression Rn is listed in the regular expression
Figure BDA0002336334340000042
And previously, matching Sn according to a regular expression Rn.
(2) Matching order modification rules: after the source code library of the EOS intelligent contract source program is updated, the newly encapsulated morpheme S is addedpDeleting old morpheme Sq
To better implement the invention, further, it is also based on a formal proof interpreter; formally validating the translated code using a formal verification interpreter.
Compared with the prior art, the invention has the following advantages and beneficial effects:
(1) the problem that the formal verification method cannot verify the EOS intelligent contract source program is solved;
(2) the customizable translation process of an EOS intelligent contract source program is realized;
(3) the translated EOS intelligent contract source program code has clear and reproducible structure, strong capacity expansion and strong adaptability.
Drawings
FIG. 1 is a schematic flow diagram of the present invention;
FIG. 2 is a schematic diagram illustrating a process of constructing an abstract syntax tree according to the present invention;
FIG. 3 is a flowchart of the sugar transformation translation method of the present invention.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it should be understood that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments, and therefore should not be considered as a limitation to the scope of protection. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
Example 1:
an EOS intelligent contract language conversion method based on abstract syntax tree is shown in fig. 1, fig. 2 and fig. 3, and includes the following steps:
s1, performing lexical unit division on an EOS intelligent contract source program; the specific lexical unit division method comprises the following steps of:
s1.1, defining a regular expression R for morpheme identification; the morphemes comprise specific morpheme types and basic morpheme types which only need regular matching in morpheme matching;
s1.2, for a specific morpheme type, defining a mode-action matching structure in a lexical analyzer for morpheme matching and grammar analysis;
s1.3, defining a character string S correspondingly matched with the regular expression R, and defining the following matching rules based on the regular expression R and the corresponding character string S:
Figure BDA0002336334340000051
wherein
Figure BDA0002336334340000052
Being a common regular expression able to match multiple strings S, RnA regular expression that can only be matched to one string, where n is 1,2,3 …;
s2, constructing an abstract syntax tree for realizing code structure reproduction by adopting a child brother representation method; when constructing an abstract syntax tree for realizing code structure reproduction, firstly, a structure body tau of leaf nodes of the abstract syntax tree needs to be constructed; the structure τ specifically includes the following attributes:
(1) construction of tau representing line number informationlineτ representing the name of a grammarnameτ representing semantic valuecontent
(2) Constructing τ representing type of variable nodetagτ representing type of expression nodetypeτ representing the value of the shaping constant nodeivalueτ representing the value of a floating-point constant nodefvalueτ representing a marker for translation of sugar conversionsugar(ii) a Wherein, the value of τ istag、τtype、τivalue、τfvalueThe type of token is distinguished when the abstract syntax tree grammar is constructed; the above-mentioned tausugarThe system is used for providing an entry for the sugar conversion translation;
(3) constructing translation traversal stop tag τs_topAnd changing the semantic value stop tag τs_change
(4) Constructing τ representing left child in child sibling representationlτ representing the right child in the child's brother representationr
After a structure body tau of leaf nodes of the abstract syntax tree is constructed, a syntax organization of an EOS contract is generated into the abstract syntax tree with a reproducible code structure through a child brother representation method, and the concrete steps comprise:
the method comprises the following steps: defining a program entry of an abstract syntax tree;
step two: a plurality of grammar nodes are expressed as reduction functions through grammar induction, all the reduction functions are written out, and each reduction function represents a grammar form;
step three: integrating a plurality of unambiguous reduction functions to obtain rule functions, writing all the rule functions, wherein each rule function represents a class of grammar form;
step four: dividing a plurality of rule functions into five different levels, the five different levels comprising: the system comprises a definition layer, a type layer, a declaration layer, a statement layer and an expression layer;
the definition layer comprises grammars of various definition sentences;
the type layer comprises a grammar of a basic type, a grammar of a structure body and a grammar of a template type;
the declaration layer comprises declaration grammars of functions and parameters and grammars of a parameter list;
the statement layer comprises all statement grammars;
the expression layer comprises expression grammars in all sentences;
s3, designing a sugar conversion translation method for the conversion translation of a specific morpheme type; the method specifically comprises the following steps:
s3.1, carrying out sugar conversion translation layering: the sugar conversion translation is divided into four levels: a sugar type layer, a sugar statement layer, a sugar expression layer and a sugar self-defined function layer; the super type layer corresponds to the type layer, the super statement layer corresponds to the statement layer, the super expression layer corresponds to the expression layer, and the super custom function layer corresponds to the definition layer and the declaration layer;
s3.2, compiling a symbol table for supporting the supersar conversion translation; the symbol table comprises a variable symbol table, a function symbol table and a scope symbol table;
s3.3, finding a target grammar corresponding to a specific morpheme type needing sugar conversion in the grammar structure of the abstract syntax tree;
s3.4, finding an entry of the sugar conversion translation in a target grammar corresponding to the specific morpheme type, and writing an entry function of the sugar conversion translation; and writing the interface function of the sugar conversion translation into the corresponding sugar conversion translation layer, wherein the following definitions are required to be satisfied:
Figure BDA0002336334340000061
wherein β is an entry function of the sugar conversion translation, f (tau) is a reduction function in the abstract syntax tree, L is a hierarchy of the abstract syntax tree, and L isSLayering in the sugar conversion method;
s4, constructing a traversal function for traversing the abstract syntax tree: writing a conventional translation set to process translation operation without using a supersar conversion translation, and writing a translation function of the supersar conversion translation; the interface function of each sugar conversion translation corresponds to the translation function of one sugar conversion translation, and the translation function of the sugar conversion translation corresponding to the interface function of each sugar conversion translation can call a conventional translation set and can call the interface functions of other sugar conversion translations to realize nested translation actions.
The working principle is as follows: the invention discloses an EOS intelligent contract language conversion method based on an abstract syntax tree, which is characterized in that each node of the abstract syntax tree is stored by utilizing a binary linked list (brother child representation method), an EOS intelligent contract source program can be converted into a functionally equivalent formal verification language aiming at a self-defined grammar structure, and a symbol table is added to jointly realize translation action so as to realize a customizable translation process. The EOS intelligent contract code translated by the translation method has the characteristics of clear structure, reproducibility, strong capacity expansion and strong adaptability, and solves the problem that the source code of the EOS intelligent contract cannot be verified by a formal verification method; when a regular expression R for morpheme identification is defined, common types such as type, digit, id and the like are defined, and for the types which can be identified only by the regular expression in morpheme matching, the types are directly matched in an abstract syntax tree in a fixed format; and for the specific morpheme in the morpheme matching, performing morpheme matching and grammar analysis by defining a mode-action; because lex always selects the first listed pattern when matching prefix and multiple matching patterns longest, in order to flexibly define specific morphemes in an EOS intelligent contract without conflicting with conventional morphemes, based on the existing regular expressions R and the character strings S matching therewith correspondingly, the following algorithm rules are defined to ensure that each regular expression R can match one character string S or a set of multiple character strings S of the same type:
Figure BDA0002336334340000071
wherein
Figure BDA0002336334340000072
Being a common regular expression able to match multiple strings S, RnA regular expression that can only be matched to one string, where n is 1,2,3 …; after the lexical unit division of the EOS intelligent contract voice is carried out, a structural body tau of a unique leaf node of an abstract syntax tree is constructed to realize the construction of the abstract syntax tree with a code structure reappearance; wherein said τ istag、τtype、τivalue、τfvalueFor constructing abstract syntax treeLegally distinguishing the type of token; the above-mentioned tausugarThe system is used for providing an entry for the sugar conversion translation; translation traversal stop tag τs_topAnd changing the semantic value stop tag τs_changeThe system is used for indicating whether the right child needs to be traversed continuously or not and whether the semantic value of the right child needs to be changed continuously or not in the translation process, so that the translation accuracy and efficiency are improved; after the abstract syntax tree is constructed, designing a sugar conversion method, and dividing the sugar into four layers for corresponding to the abstract syntax tree layers and facilitating the flexible use of the sugar conversion method: type layer: the conversion of the basic type is realized in the main traversal, and the layer is mainly the translation of a structural body; statement layer: covering translations of statement level grammars in all abstract syntax trees; expression layer: covering translations of expression level grammars in all abstract syntax trees; self-defining function layer: providing a flexible translation interface, wherein the layer mainly supports the upper three layers of translation; when writing the interface function of the sugar conversion into the corresponding hierarchy, the writing of the sugar conversion entry follows the following definition:
Figure BDA0002336334340000073
i.e., β, at L, for any abstract syntax tree presentSThere is a corresponding sugar translation interface function.
Example 2:
on the basis of the above embodiment 1, in order to better implement the present invention, further, the matching rule is written based on the following matching sequence:
(1) matching sequence rules: defining a complete set of morpheme matching patterns as URIf the character string SnNot only can be expressed regularly
Figure BDA0002336334340000081
Matched to, can also be regular expression RnIf the word is matched, listing the regular expression Rn in the regular expression when the morpheme is matched
Figure BDA0002336334340000082
Before, Sn is matched according to a regular expression Rn; the specific matching sequence satisfies the following algorithm:
Figure BDA0002336334340000083
(2) matching order modification rules: after the source code library of the EOS intelligent contract source program is updated, the newly encapsulated morpheme S is addedpDeleting old morpheme SqThe matching sequence modification satisfies the following algorithm:
Figure BDA0002336334340000084
the working principle is as follows: when the longest matching prefix is matched with a plurality of patterns, Lex always selects the pattern listed first, and can flexibly define the morpheme specific to the EOS intelligent contract through the formulation of the matching rule and the formulation of the matching sequence, and ensure that each regular expression can be matched with one character string or a plurality of sets of character strings of the same type and simultaneously does not conflict with the conventional morpheme.
Other parts of this embodiment are the same as those of embodiment 1, and thus are not described again.
Example 3:
the present invention is based on any of the above embodiments 1-2, and further, is based on a formal proof interpreter; formally validating the translated code using a formal verification interpreter.
The working principle is as follows: through the formal verification interpreter, whether the implementation scheme of the program really realizes the functions described by the program design can be completely verified or verified mathematically, so that the scheme of the invention is more reasonable and rigorous, and the safety and reliability of translation are further ensured.
Other parts of this embodiment are the same as any of embodiments 1-2 described above, and thus are not described again.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and all simple modifications and equivalent variations of the above embodiments according to the technical spirit of the present invention are included in the scope of the present invention.

Claims (10)

1. An EOS intelligent contract language conversion method based on an abstract syntax tree is characterized by comprising the following steps:
s1, performing lexical unit division on an EOS intelligent contract source program;
s2, constructing an abstract syntax tree for realizing code structure reproduction by adopting a child brother representation method;
s3, designing a sugar conversion translation method for the conversion translation of a specific morpheme type;
and S4, constructing a traversal function by combining a supersar conversion translation method for translating and traversing the abstract syntax tree.
2. The method for EOS intelligent contract language conversion based on the abstract syntax tree as claimed in claim 1, wherein when constructing the abstract syntax tree for realizing the code structure reproduction, firstly, a structure body τ of leaf nodes of the abstract syntax tree is required to be constructed; the structure τ specifically includes the following attributes:
(1) construction of tau representing line number informationlineτ representing the name of a grammarnameτ representing semantic valuecontent
(2) Constructing τ representing type of variable nodetagτ representing type of expression nodetypeτ representing the value of the shaping constant nodeivalueτ representing the value of a floating-point constant nodefvalueτ representing a marker for translation of sugar conversionsugar(ii) a Wherein, the value of τ istag、τtype、τivalue、τfvalueThe type of token is distinguished when the abstract syntax tree grammar is constructed; the above-mentioned tausugarThe system is used for providing an entry for the sugar conversion translation;
(3) constructing translation traversal stop tag τs_topAnd changing the semantic value stop tag τs_change
(4) Construction ofτ representing the left child in child brother representationlτ representing the right child in the child's brother representationr
3. An EOS intelligent contract language conversion method based on abstract syntax tree as claimed in claim 2, wherein after constructing the structure τ of leaf node of abstract syntax tree, the syntax organization of EOS contract is generated into abstract syntax tree with reproducible code structure by child sibling representation, the concrete steps include:
the method comprises the following steps: defining a program entry of an abstract syntax tree;
step two: a plurality of grammar nodes are expressed as reduction functions through grammar induction, all the reduction functions are written out, and each reduction function represents a grammar form;
step three: integrating a plurality of unambiguous reduction functions to obtain rule functions, writing all the rule functions, wherein each rule function represents a class of grammar form;
step four: dividing a plurality of rule functions into five different levels, the five different levels comprising: the system comprises a definition layer, a type layer, a declaration layer, a statement layer and an expression layer;
the definition layer comprises grammars of various definition sentences;
the type layer comprises a grammar of a basic type, a grammar of a structure body and a grammar of a template type;
the declaration layer comprises declaration grammars of functions and parameters and grammars of a parameter list;
the statement layer comprises all statement grammars;
the expression layer includes expression grammars in all statements.
4. The method for EOS intelligent contract language conversion based on the abstract syntax tree as claimed in claim 3, wherein the step S3. designing the sugar conversion translation method specifically comprises the following steps:
s3.1, carrying out sugar conversion translation layering;
s3.2, compiling a symbol table for supporting the supersar conversion translation; the symbol table comprises a variable symbol table, a function symbol table and a scope symbol table;
s3.3, finding a target grammar corresponding to a specific morpheme type needing sugar conversion in the grammar structure of the abstract syntax tree;
s3.4, finding an entry of the sugar conversion translation in a target grammar corresponding to the specific morpheme type, and writing an entry function of the sugar conversion translation; and writing the interface function of the sugar conversion translation into the corresponding sugar conversion translation layer.
5. An EOS smart contract language conversion method based on abstract syntax trees as claimed in claim 4, characterized in that said step s3.1 refers in particular to: and (3) layering the sugar conversion translation, and dividing the sugar conversion translation into four layers: a sugar type layer, a sugar statement layer, a sugar expression layer and a sugar self-defined function layer; the super type layer corresponds to the type layer, the super statement layer corresponds to the statement layer, the super expression layer corresponds to the expression layer, and the super custom function layer corresponds to the definition layer and the declaration layer.
6. The method according to claim 5, wherein in step s3.4, the interface function is written into the corresponding sugar conversion translation hierarchy, and the entry function that needs to satisfy the sugar conversion translation for any abstract syntax tree is found in the sugar conversion translation method, so as to obtain the corresponding sugar conversion translation interface function.
7. The method for EOS intelligent contract language conversion based on abstract syntax tree as claimed in claim 6, wherein the step s4. refers to: writing a conventional translation set to process translation operation without using a supersar conversion translation, and writing a translation function of the supersar conversion translation; the interface function of each sugar conversion translation corresponds to the translation function of one sugar conversion translation, and the translation function of the sugar conversion translation corresponding to the interface function of each sugar conversion translation can call a conventional translation set and can call the interface functions of other sugar conversion translations to realize nested translation actions.
8. The method as claimed in claim 7, wherein during the translation traversal in step s4, the left child is traversed, and the translation traversal stop mark τ is markeds_topThe right child is traversed if the identification continues to traverse the right child.
9. The method for intelligent contract language conversion for EOS based on abstract syntax tree as claimed in claim 1, wherein said lexical unit division method comprises the steps of:
s1.1, defining a regular expression R for morpheme identification; the morphemes comprise specific morpheme types and basic morpheme types which only need regular matching in morpheme matching;
s1.2, for a specific morpheme type, defining a mode-action matching structure in a lexical analyzer for morpheme matching and grammar analysis;
s1.3, defining character strings S correspondingly matched with regular expressions R, and formulating a matching rule based on the regular expressions R and the corresponding character strings S, wherein the matching rule ensures that each regular expression R can be matched with one character string S or a set of a plurality of character strings S of the same type; defining a regular expression that can only be matched to one string S as RnThe character string corresponding to the regular expression Rn is Sn, and the regular expression capable of matching with a plurality of character strings S is defined as
Figure FDA0002336334330000033
The matching rules are written based on the following matching sequence:
(1) matching sequence rules: defining a complete set of morpheme matching patterns as URIf the character string SnNot only can be expressed regularly
Figure FDA0002336334330000031
Matched to, can also be regular expression RnIf the word is matched, listing the regular expression Rn in the regular expression when the morpheme is matched
Figure FDA0002336334330000032
And previously, matching Sn according to a regular expression Rn.
(2) Matching order modification rules: after the source code library of the EOS intelligent contract source program is updated, the newly encapsulated morpheme S is addedpDeleting old morpheme Sq
10. An EOS smart contract language conversion method based on abstract syntax trees as claimed in any of claims 1-9, further based on formal proof interpreter; formally validating the translated code using a formal verification interpreter.
CN201911357483.XA 2019-12-25 2019-12-25 EOS intelligent contract language conversion method based on abstract syntax tree Active CN111124422B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911357483.XA CN111124422B (en) 2019-12-25 2019-12-25 EOS intelligent contract language conversion method based on abstract syntax tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911357483.XA CN111124422B (en) 2019-12-25 2019-12-25 EOS intelligent contract language conversion method based on abstract syntax tree

Publications (2)

Publication Number Publication Date
CN111124422A true CN111124422A (en) 2020-05-08
CN111124422B CN111124422B (en) 2023-03-10

Family

ID=70502241

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911357483.XA Active CN111124422B (en) 2019-12-25 2019-12-25 EOS intelligent contract language conversion method based on abstract syntax tree

Country Status (1)

Country Link
CN (1) CN111124422B (en)

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
CN116149671A (en) * 2023-04-23 2023-05-23 中国科学院软件研究所 Method and device for translating intelligent contract language and electronic equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1265209A (en) * 1997-07-22 2000-08-30 微软公司 System for processing textual inputs natural language processing techniques
US20110179347A1 (en) * 2009-09-30 2011-07-21 Iain Andrew Russell Proctor High performance php
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
CN108459860A (en) * 2018-03-28 2018-08-28 成都链安科技有限公司 Block chain intelligence forms of contract chemical examination card code converter and conversion method
CN108985073A (en) * 2018-07-18 2018-12-11 成都链安科技有限公司 A kind of supermatic intelligent forms of contract chemical examination card system and method
CN109375899A (en) * 2018-09-25 2019-02-22 杭州趣链科技有限公司 A kind of method of formal verification Solidity intelligence contract
WO2019155462A1 (en) * 2018-02-08 2019-08-15 Valid Network Ltd Code conversion method and system
CN110532176A (en) * 2019-07-31 2019-12-03 平安科技(深圳)有限公司 A kind of formalization verification method, electronic device and the storage medium of intelligence contract

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1265209A (en) * 1997-07-22 2000-08-30 微软公司 System for processing textual inputs natural language processing techniques
US20110179347A1 (en) * 2009-09-30 2011-07-21 Iain Andrew Russell Proctor High performance php
CN104503816A (en) * 2014-12-30 2015-04-08 西安电子科技大学 System for automatically converting hardware language VHDL (Vhsic Hardware Description Language) into MSVL (Modeling, Simulation and Verification Language)
WO2019155462A1 (en) * 2018-02-08 2019-08-15 Valid Network Ltd Code conversion method and system
CN108459860A (en) * 2018-03-28 2018-08-28 成都链安科技有限公司 Block chain intelligence forms of contract chemical examination card code converter and conversion method
CN108985073A (en) * 2018-07-18 2018-12-11 成都链安科技有限公司 A kind of supermatic intelligent forms of contract chemical examination card system and method
CN109375899A (en) * 2018-09-25 2019-02-22 杭州趣链科技有限公司 A kind of method of formal verification Solidity intelligence contract
CN110532176A (en) * 2019-07-31 2019-12-03 平安科技(深圳)有限公司 A kind of formalization verification method, electronic device and the storage medium of intelligence contract

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
FELLEISEN M 等: "A programmable programming language", 《COMMUNICATIONS OF THE ACM》 *
刘文伟 等: "一个重建GCC抽象语法树的方法", 《计算机工程与应用》 *

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
CN116149671A (en) * 2023-04-23 2023-05-23 中国科学院软件研究所 Method and device for translating intelligent contract language and electronic equipment

Also Published As

Publication number Publication date
CN111124422B (en) 2023-03-10

Similar Documents

Publication Publication Date Title
CN110187885B (en) Intermediate code generation method and device for quantum program compiling
CN103631632B (en) Implantation method and source-to-source compiler
Mogensen Introduction to compiler design
CN102955697B (en) Based on the component base construction method of AOP
CN111124422B (en) EOS intelligent contract language conversion method based on abstract syntax tree
CN107924326A (en) The moving method of updated type is covered
CN109857458B (en) ANTLR-based AltaRica3.0 flattening transformation method
Cano-Benito et al. Toward the ontological modeling of smart contracts: a solidity use case
Gopinath et al. Input algebras
Bille et al. Faster regular expression matching
US20080141230A1 (en) Scope-Constrained Specification Of Features In A Programming Language
KR20180135528A (en) Method of creating the balanced parse tree having optimized height
Jia et al. A derivative-based parser generator for visibly Pushdown grammars
WO2023123111A1 (en) Compiling method and compiling apparatus
JP5600301B2 (en) System representation and handling technology
Wang et al. Learning program representations with a tree-structured transformer
Loverdos et al. Steps in scala: an introduction to object-functional programming
CN113849781A (en) Go language source code obfuscation method, system, terminal and storage medium
Yan et al. Tffv: Translator from EOS smart contracts to formal verification language
Jia et al. A Derivative-based Parser Generator for Visibly Pushdown Grammars
CN113157257B (en) Rapid development device for banking system
Urban POSIX Lexing with Derivatives of Regular Expressions
CN113238759B (en) Interpretation system and method of Python-like programming language XD-M
Anureev Introduction to the Atoment language
Pimparkhede Computer programming with C++

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