CN104657267A - Elastic source code syntax tree resolving system and method - Google Patents
Elastic source code syntax tree resolving system and method Download PDFInfo
- Publication number
- CN104657267A CN104657267A CN201510070573.6A CN201510070573A CN104657267A CN 104657267 A CN104657267 A CN 104657267A CN 201510070573 A CN201510070573 A CN 201510070573A CN 104657267 A CN104657267 A CN 104657267A
- Authority
- CN
- China
- Prior art keywords
- source code
- compiler
- module
- syntax tree
- resolving
- 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
Links
Landscapes
- Devices For Executing Special Programs (AREA)
Abstract
The invention discloses an elastic source code syntax tree resolving system and method. The elastic source code syntax tree resolving system comprises a source code preprocessing module, a compiler resolving module, a compiler resolving result analysis module and a secondary manual resolving module, wherein the source code preprocessing module is used for performing preprocessing on a source code according to the input of a user; the compiler resolving module is used for analyzing the preprocessed source code through a compiler to generate an analysis result supported by the compiler; the compiler resolving result analysis module is used for analyzing the result resolved by the compiler in order to determine a part which is finely expressed in the source code, a part which cannot be identified by the complier, and a part which is incompletely resolved; the secondary manual resolving module is used for resolving and correcting the part which is incompletely identified by the compiler and manually resolving the part which cannot be resolved by the compiler. By adopting the elastic source code syntax tree resolving system and method, the source code resolving demands of different fineness degrees are met, and the fine granularity of the resolving result is adjusted automatically.
Description
Technical field
The present invention relates to a kind of computer testing technology, in particular, relate to a kind of resilient source code resolution system and method.
Background technology
In IT field tests, white-box testing is a very important method of testing, it can provide writing of test case, the judge of test completeness can be carried out, under such demand, occurred the testing tool of a lot of robotization, and the importance that these instruments can complete robotization is the syntax tree analysis realizing source code.
Also have a lot of field to need to work based on the syntax tree analysis by source code, just can carry out follow-up process process, such as, by source code product process figure, or it is reverse to carry out project by source code.
At present, the scheme that industry has a lot of source code to resolve, some is manual mode, and some is resolved by regular expression, and some is resolved by the analysis result of compiler.These schemes respectively have excellent lacking.Such as, although workload is concrete flexibly for manual mode, fairly simple syntax rule can only be applicable to.Regular expression has the advantage be concise in expression, but very difficult for some mistake.Be that analysis result is very accurate, also very abundant by the advantage that the mode of compiler is maximum, but require to arrange relatively many also, be not suitable for lightweight application.
Summary of the invention
The present invention is directed to the technical matters existed in above-mentioned prior art, a kind of flexible source code syntax tree analytic system and method are provided, the source code meeting different fine degree resolves demand, it can enrich degree according to what provide information when calling, automatically fine granulation adjustment is carried out to analysis result, adopt fine granularity to express for part that can be meticulous, adopt coarseness to express for the insufficient part of information.
For achieving the above object, the technical solution adopted in the present invention is as follows:
A kind of flexible source code syntax tree resolution system, comprise source code pretreatment module, compiler parsing module, compiler analysis result analysis module, the manual parsing module of secondary, described source code pretreatment module, the input according to user carries out pre-service to source code; Described compiler parsing module, is analyzed through pretreated source code by compiler, generates the analysis result that compiler is supported; Described compiler analysis result analysis module, is analyzed by the result of resolving compiler, determines in source code by the part of meticulous expression, the part that can not be compiled device identification and resolved incomplete part; The manual parsing module of described secondary, carries out analytic modification to the incomplete part of compiler identification, manually resolves the part that compiler can not be resolved.
Described compiler analysis result analysis module comprises the tokenize module of source code and resolves interpretation of result contrast module.
A kind of flexible source code syntax tree analytic method, adopts above-mentioned system, comprises step as follows:
The first step, carries out pre-service by source code pretreatment module to source code;
Second step, is resolved source code by compiler parsing module;
3rd step, carries out analyzing and positioning by compiler analysis result analysis module to analysis result;
4th step, carries out complete parsing by the manual parsing module of secondary by source code.
Described second step to the method that source code is resolved is: carry out flow process change to compiler, allows it analyze through pretreated source code, generates the source code syntax tree structure information of Unified Form.
Described 3rd step to the method that analysis result carries out analyzing and positioning is: according to the syntax gauge of source code, source code is carried out tokenize, then by contrasting with the syntax tree structural information generated, finding out the code section not wherein being compiled device and identifying, marking.
The method that source code carries out complete parsing is by described 4th step: according to the syntax gauge of source code, first undertaken tokenize by source code, and other is resolved then to carry out statement level according to character information, the analysis result that regeneration compiler is supported.
The beneficial effect of technical solution of the present invention is as follows:
Some scene needs to recognize very details to the structure of source code, some scene does not need too details to source code structure, such as by the application of source code product process figure, other resolves just passable only to need statement level, and it is a fragment code that this kind of application often inputs, and input own just determines the syntax tree structure elucidation can not accomplishing very details.The present invention because there is extraordinary elasticity on analysis result, and can be applied in the good scene of parsing detail, such as source code pitching pile etc., in the projects such as also can be applied to similar source code is converted in the application of process flow diagram, source code reverse-engineering.
Accompanying drawing explanation
By reading the detailed description done non-limiting example with reference to the following drawings, other features, objects and advantages of the present invention will become more obvious:
Fig. 1 is the block diagram of system of one embodiment of the invention;
Fig. 2 is method flow diagram of the present invention.
Embodiment
Below in conjunction with specific embodiment, the present invention is described in detail.Following examples will contribute to those skilled in the art and understand the present invention further, but not limit the present invention in any form.It should be pointed out that to those skilled in the art, without departing from the inventive concept of the premise, some distortion and improvement can also be made.These all belong to protection scope of the present invention.
Shown in Fig. 1, system provided by the present invention, comprises source code pre-service, compiler parsing, the analysis of compiler analysis result, secondary manually resolves four modules.
Source code pretreatment module, it carries out pre-service according to the input of user to source code, processes grand etc. in source code.By compilation of source code device, pre-service order is performed to source code, such as GCC – E test.cpp.
Compiler parsing module, make use of existing ripe compiler GCC, Clang, carries out flow process change, allow it analyze through pretreated source code to compiler, generates the source code syntax tree information of Unified Form.
Compiler analysis result analysis module, divide in order to two parts, one is the tokenize module of source code, another is analysis result analysis contrast module, first by tokenize, analyze the result that compiler is resolved, determining can by the part of meticulous expression in source code, the part of device identification can not be compiled, and resolved incomplete part.
The manual parsing module of secondary, it carries out analytic modification to the imperfect part of compiler identification, manually resolves the part that compiler can not be resolved.
Shown in Fig. 2, the present invention relates to have flexible source code analysis method step as follows:
First pre-service is carried out to source code;
Then by compiler or resolver, source code is resolved;
Then analyzing and positioning is being carried out to analysis result;
Resolve finally by secondary supplement and source code is carried out complete parsing.
In order to above-mentioned steps and effect can be better described, below illustrate, this embodiment has following source code:
If there is no header file information at present, one section of code TestSt st so; All in fact can not be compiled with next If statement, if and only need this time other analytical information of statement level also not need header file information at all, present system is exactly for such situation process process, in the incomplete situation of information, can the syntax tree information of generated statement rank, result is as follows:
Or the code of top, but user requires to know what is the definition prototype of called function in all codes? so just need very complete information, and in this case, present system is also have good elasticity, once the information of user's input is more, if formulated the path of header file this time, so analysis result is as follows:
Contrast can be found out, two result itself is all information completely, and just second has the appearance of more detailed information.
Above specific embodiments of the invention are described.It is to be appreciated that the present invention is not limited to above-mentioned particular implementation, those skilled in the art can make various distortion or amendment within the scope of the claims, and this does not affect flesh and blood of the present invention.
Claims (6)
1. a flexible source code syntax tree resolution system, it is characterized in that, comprise source code pretreatment module, compiler parsing module, compiler analysis result analysis module, the manual parsing module of secondary, described source code pretreatment module, the input according to user carries out pre-service to source code; Described compiler parsing module, is analyzed through pretreated source code by compiler, generates the analysis result that compiler is supported; Described compiler analysis result analysis module, is analyzed by the result of resolving compiler, determines in source code by the part of meticulous expression, the part that can not be compiled device identification and resolved incomplete part; The manual parsing module of described secondary, carries out analytic modification to the incomplete part of compiler identification, manually resolves the part that compiler can not be resolved.
2. flexible source code syntax tree resolution system according to claim 1, is characterized in that, described compiler analysis result analysis module comprises the tokenize module of source code and resolves interpretation of result contrast module.
3. a flexible source code syntax tree analytic method, is characterized in that, adopt system as claimed in claim 1 or 2, comprise step as follows:
The first step, carries out pre-service by source code pretreatment module to source code;
Second step, is resolved source code by compiler parsing module;
3rd step, carries out analyzing and positioning by compiler analysis result analysis module to analysis result;
4th step, carries out complete parsing by the manual parsing module of secondary by source code.
4. flexible source code syntax tree analytic method according to claim 3, it is characterized in that, described second step to the method that source code is resolved is: carry out flow process change to compiler, allow it analyze through pretreated source code, generate the source code syntax tree structure information of Unified Form.
5. flexible source code syntax tree analytic method according to claim 4, it is characterized in that, described 3rd step to the method that analysis result carries out analyzing and positioning is: according to the syntax gauge of source code, source code is carried out tokenize, then by contrasting with the syntax tree structural information generated, find out the code section not wherein being compiled device and identifying, mark.
6. flexible source code syntax tree analytic method according to claim 5, it is characterized in that, the method that source code carries out complete parsing is by described 4th step: according to the syntax gauge of source code, first source code is carried out tokenize, then other is resolved to carry out statement level according to character information, the analysis result that regeneration compiler is supported.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510070573.6A CN104657267A (en) | 2015-02-10 | 2015-02-10 | Elastic source code syntax tree resolving system and method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510070573.6A CN104657267A (en) | 2015-02-10 | 2015-02-10 | Elastic source code syntax tree resolving system and method |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104657267A true CN104657267A (en) | 2015-05-27 |
Family
ID=53248434
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510070573.6A Pending CN104657267A (en) | 2015-02-10 | 2015-02-10 | Elastic source code syntax tree resolving system and method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104657267A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
CN110532782A (en) * | 2019-07-30 | 2019-12-03 | 平安科技(深圳)有限公司 | A kind of detection method of task execution program, device and storage medium |
CN110990263A (en) * | 2019-11-09 | 2020-04-10 | 上海集成电路研发中心有限公司 | Automatic generator and generation method for test case set |
CN117171053A (en) * | 2023-11-01 | 2023-12-05 | 睿思芯科(深圳)技术有限公司 | Test method, system and related equipment for vectorized programming |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6321376B1 (en) * | 1997-10-27 | 2001-11-20 | Ftl Systems, Inc. | Apparatus and method for semi-automated generation and application of language conformity tests |
CN101937388A (en) * | 2009-12-17 | 2011-01-05 | 北京测腾信息技术有限公司 | High-extensibility and high-maintainability source code defect detection method and device |
CN102279800A (en) * | 2011-08-31 | 2011-12-14 | 中国信息安全测评中心 | Source code static defect analyzer and method for processing path-sensitive symbol definition |
CN103927473A (en) * | 2013-01-16 | 2014-07-16 | 广东电网公司信息中心 | Method, device and system for detecting source code safety of mobile intelligent terminal |
-
2015
- 2015-02-10 CN CN201510070573.6A patent/CN104657267A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6321376B1 (en) * | 1997-10-27 | 2001-11-20 | Ftl Systems, Inc. | Apparatus and method for semi-automated generation and application of language conformity tests |
CN101937388A (en) * | 2009-12-17 | 2011-01-05 | 北京测腾信息技术有限公司 | High-extensibility and high-maintainability source code defect detection method and device |
CN102279800A (en) * | 2011-08-31 | 2011-12-14 | 中国信息安全测评中心 | Source code static defect analyzer and method for processing path-sensitive symbol definition |
CN103927473A (en) * | 2013-01-16 | 2014-07-16 | 广东电网公司信息中心 | Method, device and system for detecting source code safety of mobile intelligent terminal |
Non-Patent Citations (1)
Title |
---|
KEVIN LYNX: ""使用Clang实现C语言编程规范检查"", 《HTTP://CODEMACRO.COM/2013/02/12/USING-CLANG/》 * |
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
CN110532782A (en) * | 2019-07-30 | 2019-12-03 | 平安科技(深圳)有限公司 | A kind of detection method of task execution program, device and storage medium |
WO2021017278A1 (en) * | 2019-07-30 | 2021-02-04 | 平安科技(深圳)有限公司 | Task execution program detection method and apparatus, and computer device and storage medium |
CN110990263A (en) * | 2019-11-09 | 2020-04-10 | 上海集成电路研发中心有限公司 | Automatic generator and generation method for test case set |
CN110990263B (en) * | 2019-11-09 | 2024-03-15 | 上海集成电路研发中心有限公司 | Automatic generator and generation method of test case set |
CN117171053A (en) * | 2023-11-01 | 2023-12-05 | 睿思芯科(深圳)技术有限公司 | Test method, system and related equipment for vectorized programming |
CN117171053B (en) * | 2023-11-01 | 2024-02-20 | 睿思芯科(深圳)技术有限公司 | Test method, system and related equipment for vectorized programming |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103294598B (en) | A kind of source code inspection method and device | |
US10133657B2 (en) | Textual similarity based software program repair | |
CN103425572B (en) | Code analysis methods and code analysis system | |
US20130179863A1 (en) | Bug variant detection using program analysis and pattern identification | |
KR20190026641A (en) | Method of character recognition of claims document, apparatus, server and storage medium | |
CN104102574B (en) | Applied program testing method and device | |
EP2698710A3 (en) | Systems and methods for information flow analysis | |
CN108804304B (en) | Test case generation method and device, storage medium and electronic equipment | |
CN104657267A (en) | Elastic source code syntax tree resolving system and method | |
Yulianto et al. | Automatic grader for programming assignment using source code analyzer | |
Krüger et al. | Effects of explicit feature traceability on program comprehension | |
WO2016164680A3 (en) | Automated model development process | |
DE602005015600D1 (en) | DEVICE, SYSTEM AND METHOD FOR TESTING A DEVICE WITH RESTRICTED RESOURCES | |
EP3547145A3 (en) | Systems and methods for reducing storage required for code coverage results | |
US10761961B2 (en) | Identification of software program fault locations | |
CN103294596A (en) | Early warning method for contract-type software fault based on program invariants | |
CN102306098A (en) | Implicit taint propagation system and scheme thereof | |
MX2023010157A (en) | Generation and execution of processing workflows for correcting data quality issues in data sets. | |
CN102043720A (en) | Method and device for generating test data automatically by utilizing structured query language (SQL) sentences | |
CN102087629A (en) | Agent embedded software-based invariant test method and tool | |
CN116560631B (en) | Method and device for generating machine learning model code | |
CN107066302B (en) | Defect inspection method, device and service terminal | |
US20140089738A1 (en) | System and method for identifying source of run-time execution failure | |
CN103577318A (en) | Code detection method and device | |
CN104536880A (en) | GUI program testing case augmentation method based on symbolic execution |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 201203 Shanghai City, Pudong New Area Chinese (Shanghai) free trade zone 498 GuoShouJing Road No. 14 building block 22301-985 Applicant after: Shanghai chuangkin Mdt InfoTech Ltd Address before: 201203 Shanghai Guo Shou Jing Road, Zhangjiang High Tech Park of Pudong New Area No. 498 Pudong Software Park building 14, block 22301-985 Applicant before: Upper SeaBird scape computer system company limited |
|
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20150527 |