CN102929680A - Method, device and system for converting a testing and test control notation version 3 (TTCN-3) script into a Java source code - Google Patents

Method, device and system for converting a testing and test control notation version 3 (TTCN-3) script into a Java source code Download PDF

Info

Publication number
CN102929680A
CN102929680A CN201210400741XA CN201210400741A CN102929680A CN 102929680 A CN102929680 A CN 102929680A CN 201210400741X A CN201210400741X A CN 201210400741XA CN 201210400741 A CN201210400741 A CN 201210400741A CN 102929680 A CN102929680 A CN 102929680A
Authority
CN
China
Prior art keywords
ttcn
script
source code
java source
module
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
CN201210400741XA
Other languages
Chinese (zh)
Other versions
CN102929680B (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.)
ISOFT INFRASTRUCTURE SOFTWARE CO Ltd
Original Assignee
ISOFT INFRASTRUCTURE SOFTWARE 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 ISOFT INFRASTRUCTURE SOFTWARE CO Ltd filed Critical ISOFT INFRASTRUCTURE SOFTWARE CO Ltd
Priority to CN201210400741.XA priority Critical patent/CN102929680B/en
Publication of CN102929680A publication Critical patent/CN102929680A/en
Application granted granted Critical
Publication of CN102929680B publication Critical patent/CN102929680B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method, a device and a system for converting a testing and test control notation version 3 (TTCN-3) script into a Java source code so as to compile the TTCN-3 script. According to the method, a translator of the TTCN-3 script is constructed, analyzes and verifies a test object file, and then translates the TTCN-3 script into a Java file according to predefined translation rules. A Java runtime support library is constructed according to the translation rules of the translator, supports the foundation classes quoted in a translation scheme, and completes the execution of the code generated by translation and the recording of the execution results. The complete Java source code in accordance with a TTCN-3 semanteme can be acquired through the integration of the code translated by the translator and the code of the runtime support library. By the method, the process of the design of an interlanguage by a compiler and the optimization of the object code is eliminated; and moreover, the method is simple and convenient to implement, and allows self-customization of the grammar range of translation.

Description

A kind ofly the TTCN-3 script is converted to the method for Java source code, device and system
Technical field
The present invention relates to computer script compiling field, be specifically related to a kind of method and apparatus that the TTCN-3 script is converted to the Java source code.
Background technology
TTCN-3 (Testing and Test Control Notation version 3, test and test control representation-3) is a kind of mutatis mutandis exploitation programming language of test of International standardization, is exclusively used in various tests.Typical application is system testing, interactivity test, protocol test, operational trials, service testing, module testing etc.For example, can move with Internet protocol by TTCN-3 and test, CORBA (Common Object Request Broker Architecture based on platform, Common Object Request Broker Architecture) test, API (Applicat ion programming interface application programming interface,) test and compliance test etc. that be used for to describe the basic software module of AUTOSAR (automobile open system framework, Automotive OpenSystems Architecture) standard.
Move the TTCN-3 test script, need corresponding TTCN-3 compiler.Usually, the compiler of programming language is that language directly is translated as executable code on target machine executable code or the target virtual machine.But the implementation method that the TTCN-3 compiler mainly adopts but is that the TTCN-3 language is converted into the higher level lanquage (such as Java, C++ etc.) that a certain class can compile, and then utilizes third party's compiler to obtain executable file.Although certain compile efficiency that this mode is sacrificed utilizes already present higher level lanquage, can generate and the work of rear end code optimization by simplified code, greatly reduce the difficulty of compiler development.
Known compiler all is commercial compiler at present, fetch long price, although powerful, in actual conditions, do not need compiler to support complete TTCN-3 grammer.For example in the subsidiary test script of AUTOSAR V4.0, just do not use message based communication mode.Therefore, in the situation of syntactic element set relative decrease, according to can according to being compiled the employed TTCN-3 grammer of script, oneself making up a cover transcoding scheme.Because syntactic element only is a subset of complete TTCN-3 language, difficulty and the complexity of oneself's design also can correspondingly reduce, and the translation function that realizes based on the method has higher cost performance.
Summary of the invention
The purpose of this invention is to provide a kind of method, Apparatus and system that the TTCN-3 script is converted to the Java source code file, by the present invention, can guarantee to change the semanteme regulation that the post code semanteme meets standard TTCN-3 fully, further the Java source code after the conversion can directly be compiled as bytecode by the Java compiler.
The invention discloses the method that the TTCN-3 script is converted to the Java source code, comprising:
Make up the translater of TTCN-3 script;
Described translater is translated described TTCN-3 script according to predefined translation rule, convert the Java source code to;
In conjunction with described translation rule, make up the required support storehouse of operation Java source code; The foundation class that described support storehouse refers in realizing translating;
Dispose the execution entrance of Java source code, obtain the executable file of Java source code.
Preferably, described TTCN-3 script is translated according to predefined translation rule, converts the Java source code to and comprises the TTCN-3 script is carried out lexical analysis and grammatical analysis that described lexical analysis and grammatical analysis further may further comprise the steps:
The mistake of morphology and grammer is analyzed morphology and syntactic structure in verification and the described TTCN-3 script of correction, the generative grammar tree;
Syntax tree is scanned, carry out semantic analysis;
Scanning generates corresponding Java source code through the syntax tree of semantic analysis.
Preferably, described translater further comprises step: the symbol in the record TTCN-3 script file code provides retrieval, the introducing operation of symbol table.
In addition, described semantic analysis comprises carries out semantic test to the code in the TTCN-3 script, the symbol in the code in the related described TTCN-3 script, and storage generates the needed information of Java source code, prepares for generating the Java source code.
The TTCN-3 script file is carried out lexical analysis with translater and grammatical analysis is by means of JavaCC and JJTree instrument, realizes that by writing the file that meets the BNF normal form described BNF normal form can be cut out according to demand.
Whether wherein, semantic analysis is carried out in a certain order: for the modules A of input TTCN-3 script file, at first judge A analyzed mistake; If then finish the semantic analysis to A, then check if not each the possible introducing B that exists among the A; If the analyzed mistake of B then is incorporated into all among B symbols in the symbol table of front module; If the not analyzed mistake of B is then carried out semantic analysis to B first, again all among B symbols are incorporated in the symbol table of front module; Each the possible introducing B that exists in to A detect complete after, A is being carried out semantic analysis, and sign A was for analyzing, end is to the semantic analysis of A.
The invention also discloses and a kind of the TTCN-3 script is converted to the device of Java source code, it is characterized in that, comprising:
Translater makes up module, makes up the translater of TTCN-3 script;
Translater, described translater is translated described TTCN-3 script according to predefined translation rule, convert the Java source code to;
Support the storehouse to make up module, in conjunction with described translation rule, make up the required support storehouse of operation Java source code;
Support the storehouse, the foundation class that described support storehouse refers in realizing translating;
Dispose collector, dispose the execution entrance of Java source code, obtain the executable file of Java source code.
Translater further comprises the analysis module that the TTCN-3 script is carried out lexical analysis and grammatical analysis, and described analysis module comprises:
Morphology syntax parsing module, the mistake of morphology and grammer is analyzed morphology and syntactic structure in verification and the described TTCN-3 script of correction, the generative grammar tree;
Semantic module scans syntax tree, carries out semantic analysis;
Code generation module, scanning generates corresponding Java source code through the syntax tree of semantic analysis.
Described translater further comprises the symbol table module, and the symbol in the record TTCN-3 script file code provides retrieval, the introducing operation of symbol table.
In addition, described semantic module further comprises carries out semantic test to the code in the TTCN-3 script, symbol in the code in the related described TTCN-3 script, storage generates the needed information of Java source code, the module of preparing for generating the Java source code.
Wherein, the TTCN-3 script file is carried out lexical analysis with translater and grammatical analysis is by means of JavaCC and JJTree instrument, realizes that by writing the file that meets the BNF normal form described BNF normal form can be cut out according to demand.
Whether preferably, described semantic analysis is carried out in order: for the modules A of input TTCN-3 script file, at first judge A analyzed mistake; If then finish the semantic analysis to A, then check if not each the possible introducing B that exists among the A; If the analyzed mistake of B then is incorporated into all among B symbols in the symbol table of front module; If the not analyzed mistake of B is then carried out semantic analysis to B first, again all among B symbols are incorporated in the symbol table of front module; Each the possible introducing B that exists in to A detect complete after, A is being carried out semantic analysis, and sign A was for analyzing, end is to the semantic analysis of A.
The invention also discloses another TTCN-3 script be converted to the scheme of Java source code, comprise step:
Make up the translater of TTCN-3 script;
Described translater comprises that described translater finishes TTCN-3 script file code to the conversion of syntax tree data structure; Symbol table in the record TTCN-3 script file code provides retrieval, the introducing operation of symbol table; The scanning syntax tree carries out semantic test, associated nodes and corresponding symbol; Finish the module syntax tree to the conversion of Java source code;
Make up the required support storehouse of operation Java source code; The foundation class that described support storehouse refers in realizing translating;
Dispose collector, dispose the execution entrance of Java source code, obtain the executable file of Java source code.
And disclose and a kind of the TTCN-3 script is converted to the system of Java source code, described system comprises:
Translater makes up module, makes up the translater of TTCN-3 script;
Translater;
Support the storehouse to make up module, make up the required support storehouse of operation Java source code;
Support the storehouse, the foundation class that described support storehouse refers in realizing translating;
Dispose the execution entrance of Java source code, obtain the executable file of Java source code.
Described translater further comprises:
Morphology syntax parsing module, morphology syntax parsing module is finished TTCN-3 script file code to the conversion of syntax tree data structure;
The symbol table module, the symbol table in the record TTCN-3 script file code provides retrieval, the introducing operation of symbol table;
Semantic module, the scanning syntax tree carries out semantic test, associated nodes and corresponding symbol;
Code generation module is finished the module syntax tree to the conversion of Java source code.
Can find out that the scheme flow process that the present invention provides is less, give the Java compiler processes with the intermediate code optimizing process of conventional compiler device.Simultaneously, by Java language once the compiling everywhere the operation characteristic, this method can be so that the TTCN-3 script moves under different operating system.In addition, because TTCN-3 is higher level lanquage to Java itself, therefore, it is also comparatively easy to expand new TTCN-3 grammer.When implementing, only need to make translater increase new grammer support, and in Java support storehouse, add the java class of new definition.
Description of drawings
Fig. 1 is total execution flow process of the present invention.
Fig. 2 is the node class figure that uses among the present invention.
Fig. 3 is symbol table snapshot structure among the present invention.
Fig. 4 is symbol table class figure among the present invention.
Fig. 5 is that process flow diagram is sequentially determined in semantic analysis among the present invention.
Fig. 6 is that entity elements is supported class figure among the present invention.
The class figure of the type/data that relate among Fig. 7 the present invention (A).
The class figure of the type/data that relate among Fig. 8 the present invention (B)
Embodiment
The present invention is described in further detail below in conjunction with the drawings and specific embodiments:
Fig. 1 has provided the total execution flow process that TTCN-3 script file (* .ttcn) is converted to the Java source code file of setting forth of the present invention.This process at first needs to make up the translater of a TTCN-3 script file, and this translater can be converted to the TTCN-3 script file Java source code file.
Then make up the required support storehouse of operation Java source code, the foundation class that described support storehouse refers in realizing translating compiles the Java source code that translation generates by the Java compiler, carries out the Java source code that described translation generates.
Wherein, translater is to carry out the TTCN-3 script file to the significant element of Java source code file conversion; For specifically, this translater need to comprise following function:
(1) all TTCN-3 script files is carried out lexical analysis, grammatical analysis.The Main Function of this process is some fundamental errors of getting rid of in the script file, such as conventional mistake check and correction such as misspellings, when detecting mistake, in time send error reporting in the mode of notice, make things convenient for the commissioning staff to make amendment, and or automatically revise for frequent fault; This process is finally understood the generative grammar tree.
(2) syntax tree is scanned, carry out semantic analysis.Semantic analysis process mainly is that code is carried out semantic test.In addition, the symbol of this process in also can association code, the needed information of storage generating code is for code generation process is prepared.
(3) scanning generates corresponding Java source code through the syntax tree of semantic analysis.In the specific implementation, a TTCN-3 file can be exchanged into a Java source file, and a TTCN-3 module can correspond to a java class and get on, and so just is easy to set up the corresponding relation between file and even statement.
Make up the support storehouse of Java, these Java source code file have guaranteed that the Java source code after the translation can correctly be compiled.
Make up the code after translating and support the storehouse, and dispose the execution entrance of whole Java source code, can obtain complete moved Java source code.
From a structural point, this translater has comprised with lower module:
Morphology syntax parsing module: finish TTCN-3 script file code to the conversion of syntax tree data structure;
The symbol table module: the symbol table in the record TTCN-3 script file code provides retrieval, the introducing operation of symbol table;
Semantic module: analysis module scanning syntax tree, carry out semantic test, associated nodes and corresponding symbol;
Code generation module: finish the module syntax tree to the conversion of Java source code.
Structure morphology syntax parsing module
Translater at first carries out lexical analysis and grammatical analysis to the TTCN-3 script file, by means of JavaCC and JJTree instrument, only need to write the normal form file that meets the instrument regulation, can generate corresponding morphology and the Java source code of syntax parsing.Wherein, JavaCC (Java CompilerCompiler) is a grammatical analysis maker of developing with Java.Concrete BNF normal form can be carried out certain cutting according to own demand, for the syntactic element that does not relate in those TTCN-3 script files, then it can be deleted.After normal form had been write the normal form file, instrument will generate for the nonterminal symbol in the BNF normal form corresponding node class and morphology syntax parsing device.The normal form of the TTCN-3 of normative reference, its node class formation is seen accompanying drawing 2.
In accompanying drawing 2, the Node interface is that all node classes all need the interface realized, and it provides the access method to child nodes and father node.JjtGetChil dNum () method is obtained the number of child nodes, and jjtGetChild () method can be obtained the child nodes of appointment, and jjtAccept () method is so that the Accessor Classes can access this node.
The SimpleNode class has realized Node interface enterLocation, and it is the base class of other all nodes.This method has been added getStartPosition () method in the SimpleNode class, with the position of record node in source code.Dump () method then gets on nodal information with the printing device that the mode recurrence of text outputs to appointment.
StrcutFieldDef class and RecordDef class have just been inherited the SimpleNode class, and they are exactly the node class that is generated by corresponding BNF normal form.After semantic analysis was finished, each TTCN-3 code file will be converted into one by the synthetic syntax tree of node class example set.
Behind the VISITOR option of having opened the JJTree instrument, also can generate the ParserVisitor interface, this interface is that the syntax tree visitor need to realize interface, each node class is to a visit () method in should interface.If need the access syntax tree, will realistic existing this interface.Specifically, in ensuing semantic module and code generation module, just need all the visit () methods in this interface of realization, to access all syntax tree nodes.
All node class names with and extend information as shown in table 1:
The tabulation of table 1 node class
Figure BSA00000791912900081
Figure BSA00000791912900091
Figure BSA00000791912900101
Figure BSA00000791912900111
Figure BSA00000791912900121
Figure BSA00000791912900131
Figure BSA00000791912900141
Structure symbol table module
According to the TTCN-3 grammatical norm, static state during the semiotic function territory of TTCN-3 language, namely TTCN-3 script file code book body structure has just determined the action scope of symbol in the code.Each action scope unit comprises mutually, is downtree shape structure, and all sub-action scopes are all as seen to it for all symbols of father's action scope unit the inside.Because the semantic analysis stage need to be carried out a large amount of symbolic look-up accessing operations, therefore, symbol table needs also to guarantee that except guaranteeing the efficient search capacity symbol that finds comes from correct action scope.
In the specific implementation, this programme will be by a chain stack, the name space of maintain symbol.At a time its snapshot as shown in Figure 3, when entering a new function (as) will set up a new action scope object when entering a new semiotic function territory, and is set to current action scope.Withdrawing from before prescope or newly-built action scope, the symbol of all new addings will be organized with the form of doubly linked list, if and the new symbolic name that adds is when existing hash-collision (or of the same name), the new symbol that adds will cover former symbol.Do like this can guarantee when Hash lookup, the symbol of the always innermost layer action scope that finds.During implementation, for improving development efficiency, the Hash table that can use Java self to provide is supported class.
Class figure when Fig. 4 provides the symbol table implementation, the symbol table module is externally mutual by the single routine class of SymbolTbl.Symbol object internal maintenance a plurality of Scope objects, they are organized with the form of storehouse.Semantic module is added on the new Scope object and storehouse by newScope () method, and is set to current action scope.After this, new symbol all passes through enter () method and adds this action scope, and lookup () method is used for all symbols in the retrieval name space.When semantic module was called leave () method, when the prescope object will be released, and all symbols in its inside also discharged thereupon.
The constructing semantic analysis module
Semantic module is mainly carried out semantic test to syntax tree, needs in the checking process to come recording indexes current sign information with symbol table.Semantic module needs to realize the ParserVisitor interface as the visitor.To each node class, just need to realize with it visit () method of correspondence.
The semantic analysis order of determination module
Exist symbol to introduce (by import key word sign) mechanism in TTCN-3, this makes when front module (module) can quote symbol definition under other modules.For example defined TypeA among the ModuleA, ModuleB has introduced ModuleA, and has defined the example InsA of TypeA.In order to verify the correctness in definition of I nsA, just need to check according to the definition of TypeA.In order to guarantee that this inspection can carry out smoothly, a kind of simple method is that the module that guarantees all references has all been finished semantic analysis.That is to say the first ModuleA of scanning, and then scanning ModuleB, just can correctly introduce the symbol table of ModuleA, and the situation that symbol definition can not find can not occur.In the specific implementation, in order to address this problem, can come the determination module scanning sequency with topological sorting.Whether Fig. 5 has provided a kind of feasible algorithm flow: for input TTCNModuleA, at first judge A analyzed mistake; If then finish the semantic analysis to A, then check if not each the possible introducing B that exists among the A; If the analyzed mistake of B then is incorporated into all among B symbols in the symbol table of front module; If the not analyzed mistake of B is then carried out semantic analysis to B first, again all among B symbols are incorporated in the symbol table of front module; Each the possible introducing B that exists in to A detect complete after, A is being carried out semantic analysis, and sign A was for analyzing, end is to the semantic analysis of A.
The delay of module internal symbol is related
Similar Java language, in a module, TTCN-3 allows to quote first the type of rear statement, and for example: following definition is legal.
Figure BSA00000791912900151
This backward mode of quoting can run into and can't find in symbol table by TypeA when having caused depth-first fashion scanning syntax tree.For fear of this situation, this method has been declared IInstance interface (with reference to figure 3), and this node has been inherited the ISymbolized interface, for mainly be the node of above-mentioned containing type definition.When scanning undefined symbol for the first time, this method first step only checks the uniqueness of this symbolic name, then puts it into one and does not finish in the formation.Scanning behind the syntax tree of front module, again this IInstance example of not finishing the formation the inside is being carried out the second step association process.
Structure code translation module
Code generation module is responsible for generating a Java source code file for each syntax tree after semantic analysis finishes.Be similar to semantic analysis, the code translation module need to realize the ParserVisitor interface.The meeting of Java source code and the support storehouse that generate by translation module combine, and form final compiling result.The translation of code is according to following rule:
Type definition: for the type definition node, generate a new class after the translation, such has been inherited and has supported class corresponding in the storehouse.This category node comprises: TTCN3Module, ModuleControlPart, SubTypeDef, RecordDef, RecordOfDef, EnumDef, SignatureDef, ComponentDef, PortDef, TestCaseDef, AltstepDef (as shown in table 1).The class name that generates is identical with type name in the TTCN-3 code.Because each TTCN-3 module is comprised of the above-mentioned type definition, the code after the translation is combined into by these classes.Comprise the node of executable statement node for child node, comprise TestCaseDef, AltstepDef, FunctionDefPart, ModuleControlPart, they all comprise executable code, therefore, the class after the translation also has corresponding executing method run ().
Built-in method: for the built-in method of TTCN-3, comprise: create method, start method, stop method, execute method, connect method, map method, log method, obtain the MTC assembly method, obtain System assembly method and some built-in functions (such as ispresent () function), this method can realize in advance in the T3RTSystem in operation support storehouse class that this class is a routine class of overall addressable list.If comprise the call statement of these methods in the TTCN-3 code, translater is translated as this statement the Java statement that calls method of the same name in the T3RTSystem class.
Variable constant definition: in statement block, often can comprise the local variable definition.When entering action scope, if run into local variable statement statement, translater can be an addVariable () call statement with this definition translation.In this way, this local variable will join in the action scope at its place when code finally moves.In order to safeguard action scope, in each statement block ending, translater also will generate for each local variable the call statement of delVariable () method, before adds this action scope ground local variable to empty.For the constant definition in the statement block, translater adopts identical strategy.The organizational form of the local variable of concrete action scope is responsible for by the operation support storehouse, and translater is not responsible for this.
Data value: for the definition of constant value, comprise shaping value, floating point values, Boolean and decision content, this method will realize corresponding with it class in advance in the operation support storehouse, be respectively: IntegerType, FloatType, BooleanType, VerdictType, these classes all are the bonding examples, obtain such instance objects by getInstance ().When running into a constant value, translater will be translated into form and be<Class-Name〉statement of .getInstance () .newInstance (<InitValue 〉), wherein<and Class-Name〉be corresponding class name,<InitValue〉be initial value.
Control statement: control statement mainly comprises conditional statement (by if key word sign), loop statement (by for, while key word sign), and after running into these statements, translater can be translated among the Java fully corresponding with it control statement.Also have some key words, such as the break key word, the return key word also is translated into corresponding Java key word.
Optional step statement: for optional step statement block, translater is translated into do-while loop statement among the Java with it, and whether circulation finishes by checking that snapshot state judges.Each conditional statement in the optional step statement block is translated into the if statement in the Java language.The interpretative system that repeat key word in the optional step statement is corresponding is throw exception, and this can guarantee once to jump out multilayer circulation.The structure in optional step is as shown in the table.
The optional step translation of table 2 table of comparisons
Figure BSA00000791912900171
Figure BSA00000791912900181
The port method call: when running into call, getcall, reply, during the getreply method call, translater is translated into the method call of corresponding Java, these methods all in advance in the class in operation support storehouse structure good.
The operation support storehouse
Code after the translation will combine compiling with the operation support storehouse, the foundation class that refers in the operation support storehouse realization translation scheme, and finish the execution of the code that translation is generated and the work such as record of execution result.
For entity elements such as the module in the TTCN-3 language (by module key word sign), control (by control key word sign), test case (by testcase key word sign), function (by function key word sign), optional steps (by altstep key word sign), a base class of finishing this element basic function is realized for each element in the operation support storehouse.And to the process of the translation process of the concrete element individuality concrete subclass that to be exactly one of structure expand base class.As shown in Figure 6, there is following entity elements to support class in the operation support storehouse.
The AbstractModule class is the base class of all block elements translation results among the TTCN-3, has realized the management to elements such as the constant that defines in the module, control, behavior (being test case, function and optional step), function signature (by signature key word sign);
The AbstractControl class is the base class of control element translation result among the TTCN-3, has realized the functions such as control and measuring use-case execution;
The AbstractTestcase class is the base class of control element translation result among the TTCN-3, has realized the management to test case execution result and test suite (component);
The AbstractFunction class is the base class of functional element translation result among the TTCN-3, has realized the management to the variable in the function, constant and rreturn value;
The AbstractAltstep class is the base class of optional step element translation result among the TTCN-3, has realized the management to the variable in the optional step, constant;
Control, test case, function, optional step all are the bodies carried out among the TTCN-3, and all subclasses of expanding them all must realize run () method according to operational semantics.
In the TTCN-3 language, defined some basic data types, in addition, the user can be according to actual needs to basic data type expanded, constraint or instantiation, define the user data type.All data types are divided into several large classes (comprising shaping, floating type, Boolean type, decision content type, character string type, recordable type, tabulation type etc.).Each data type no matter be fundamental type or user defined type, all belongs to certain large class uniquely.In the operation support storehouse, set up a base class for the large class of each data type, they are respectively IntegerType, FloatType, BooleanType, VerdictType, CharstringType, RecordType, RecordOfType.Each base class is expanded the class from TypeImpl, and the TypeImpl class has realized the Type interface.All user defined types all are translated into the subclass to the base class of large class under it, realize expansion or constraint to base class.
In TTCN-3, all data values all belong to a specific data type, referring to Fig. 7 and Fig. 8, in translation scheme corresponding to an object of expanding the ValueImpl class.The ValueImpl class has realized the Value interface, has comprised concrete data message.The ValueImpl class also has a member territory of realizing the Type interface, and this member is object corresponding to data type under the ValueImpl class.Call the getType () method of Value interface and will return this member.Correspondingly, individual newInstance () method is arranged in the Type interface, call the data value object that the method will create the data type of a correspondence, be i.e. an example of realizing the Value interface.And belong to a large class realization all subclasses of Type interface, even the concrete data type of its representative is different, by call realization that its newInstance () method creates the example of Value interface all be the object of same class.Such as, the IntegerValueImpl class has been expanded the ValueImpl class and has been realized the IntegerValue interface, representative belongs to the data value of the data type of the large class of shaping, calls the getType () method of IntegerValueImpl class, will return the object of an IntegerType class; And call the newInstance () method of IntegerType and subclass thereof, will return the object of an IntegerValueImpl class.Corresponding in addition FloatValueImpl, BooleanValueImpl, VerdictValueImpl, CharstringValueImpl, the classes such as RecordValueImpl, RecordOfImpl.
Service data type and data value are come according to the pattern of abstract factory in the operation support storehouse, set up a data value and must use the newInstance () method of Type example corresponding to its affiliated data type to create, guaranteed type matching and compatible feasibility.
Assembly (by component key word sign) is the core among the TTCN-3, has represented the entity of carrying out the TTCN-3 semanteme.All test cases, function, optional step all carry out in specific assembly, and each assembly is exactly the clue of a semantic execution.Mode by message or the invocation of procedure between the assembly realizes communication.The operation support storehouse represents an assembly with the Component class, and the Component class is expanded from the ValueImpl class, and namely Component is a special data value.In the translation scheme, the definition of each assembly is translated into a subclass of ComponentType class, and the operation that creates assembly then realizes by the newInstance () method of calling corresponding ComponentType object.The Component class is being managed port, variable, constant and the timer that defines in assembly.
The operation support storehouse adopts the mode of multithreading to support the parallel work-flow of a plurality of assemblies in the testing engineering, the territory of containing a Thread type in the Component class, be used for the semantic operation that executive module need to carry out, specify and carry out the semantic operation that to carry out by calling execute () method.The Component class is also being safeguarded a communication queue, under two principles of first in first out and Data Matching, and the communication between the supporting assembly.The operation support Cooley safeguards that with the thread synchronization mechanism of Java language inter-module shares data's consistency.
The T3RTSystem class adopts single routine pattern to realize, is responsible for the execution of the whole testing engineering of control, and collects the execution result of all test cases, safeguards execution journal information and carries out error handling processing.By the configuration of property file, the measurand adapter (SUT Adapter) that uses in can the nominative testing system, the execution starting point of coder/decoder (Coder/Decoder) and generating code.Other classes are carried out when mutual in code that translation generates and operation support storehouse, and the T3RTSystem class also plays the intermediate axle beam action, thereby as much as possible to the specific implementation in the hiding operation support storehouse of generating code.
Need to prove, the contents such as the information interaction between said apparatus and intrasystem each unit, implementation since with the inventive method embodiment based on same design, particular content can referring to the narration among the inventive method embodiment, repeat no more herein.
Used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.

Claims (16)

1. one kind is converted to the method for Java source code with the TTCN-3 script, it is characterized in that, comprising:
Make up the translater of described TTCN-3 script;
Described translater is translated described TTCN-3 script according to predefined translation rule, change described one-tenth Java source code;
In conjunction with described translation rule, make up the required support storehouse of the described Java source code of operation; The foundation class that described support storehouse refers in realizing translating;
Dispose the execution entrance of described Java source code, obtain the executable file of described Java source code.
2. method according to claim 1, described translater is translated described TTCN-3 script according to predefined translation rule, convert described Java source code to and comprise described TTCN-3 script is carried out lexical analysis and grammatical analysis that described lexical analysis and grammatical analysis further may further comprise the steps:
The mistake of morphology and grammer is analyzed morphology and syntactic structure in verification and the described TTCN-3 script of correction, the generative grammar tree;
Described syntax tree is scanned, carry out semantic analysis;
Scanning generates corresponding described Java source code through the described syntax tree of described semantic analysis.
3. method according to claim 2, described translater further comprises step: record the symbol in the document code of described TTCN-3 script, provide symbol table retrieval, introduce operation.
4. method according to claim 3, described semantic analysis need to be carried out the symbolic look-up accessing operation, comes from correct action scope for guaranteeing the symbol that finds; When entering a new semiotic function territory, set up a new action scope object, and be set to current action scope; Before withdrawing from described current action scope or described new action scope, the symbol of all new addings will be organized with the form of doubly linked list, if and there is hash-collision in the new symbolic name that adds or when of the same name, the new symbol that adds will cover former symbol.
5. method according to claim 2, described semantic analysis comprises carries out semantic test to the code in the described TTCN-3 script, symbol in the code in the related described TTCN-3 script, storage generates the needed information of Java source code, prepares for generating described Java source code.
6. according to claim 3 or 4 described methods, described TTCN-3 script is carried out described lexical analysis with translater and grammatical analysis is by means of JavaCC and JJTree instrument, realize that by writing the file that meets the BNF normal form described BNF normal form can be cut out according to demand.
7. method according to claim 5, whether described semantic analysis is carried out in order: for the modules A of the described TTCN-3 script of input, at first judge A analyzed mistake; If then finish the semantic analysis to A, then check if not each the possible introducing B that exists among the A; If the analyzed mistake of B then is incorporated into all among B symbols in the symbol table of front module; If the not analyzed mistake of B is then carried out semantic analysis to B first, again all among B symbols are incorporated in the symbol table of front module; Each the possible introducing B that exists in to A detect complete after, A is being carried out semantic analysis, and sign A was for analyzing, end is to the semantic analysis of A.
8. one kind is converted to the device of Java source code with the TTCN-3 script, it is characterized in that, comprising:
Translater makes up module, makes up the translater of TTCN-3 script;
Translater, described translater is translated described TTCN-3 script according to predefined translation rule, convert the Java source code to;
Support the storehouse to make up module, in conjunction with described translation rule, make up the required support storehouse of operation Java source code;
Support the storehouse, the foundation class that described support storehouse refers in realizing translating;
Dispose collector, dispose the execution entrance of Java source code, obtain the executable file of Java source code.
9. device according to claim 8, described translater further comprises the analysis module that the TTCN-3 script is carried out lexical analysis and grammatical analysis, the described analysis module that carries out lexical analysis and grammatical analysis comprises:
Morphology syntax parsing module, the mistake of morphology and grammer is analyzed morphology and syntactic structure in verification and the described TTCN-3 script of correction, the generative grammar tree;
Semantic module scans described syntax tree, carries out semantic analysis;
Code generation module, scanning generates corresponding Java source code through the syntax tree of semantic analysis.
10. device according to claim 9, described translater further comprises the symbol table module, the symbol in the document code of record TTCN-3 script, provide symbol table retrieval, introduce operation.
11. method according to claim 10, described semantic analysis need to be carried out the symbolic look-up accessing operation, comes from correct action scope for guaranteeing the symbol that finds; When entering a new semiotic function territory, set up a new action scope object, and be set to current action scope; Before withdrawing from described current action scope or described new action scope, the symbol of all new addings will be organized with the form of doubly linked list, if and there is hash-collision in the new symbolic name that adds or when of the same name, the new symbol that adds will cover former symbol.
12. method according to claim 9, described semantic module further comprises carries out semantic test to the code in the TTCN-3 script, symbol in the code in the related described TTCN-3 script, storage generates the needed information of Java source code, the module of preparing for generating the Java source code.
13. according to claim 10 or 11 described devices, described TTCN-3 script is carried out lexical analysis with translater and grammatical analysis is by means of JavaCC and JJTree instrument, realize that by writing the file that meets the BNF normal form described BNF normal form can be cut out according to demand.
Whether 14. device according to claim 13, described semantic analysis is carried out in order: for the modules A of the described TTCN-3 script of input, at first judge A analyzed mistake; If then finish the semantic analysis to A, then check if not each the possible introducing B that exists among the A; If the analyzed mistake of B then is incorporated into all among B symbols in the symbol table of front module; If the not analyzed mistake of B is then carried out semantic analysis to B first, again all among B symbols are incorporated in the symbol table of front module; Each the possible introducing B that exists in to A detect complete after, A is being carried out semantic analysis, and sign A was for analyzing, end is to the semantic analysis of A.
15. one kind is converted to the method for Java source code with the TTCN-3 script, it is characterized in that, comprising:
Make up the translater of described TTCN-3 script;
Described translater comprises that described translater finishes the document code of described TTCN-3 script to the conversion of syntax tree data structure; Record the symbol table in the document code of described TTCN-3 script, provide described symbol table retrieval, introduce operation; The scanning syntax tree carries out semantic test, associated nodes and corresponding symbol; Finish the module syntax tree to the conversion of Java source code;
Make up the required support storehouse of operation Java source code; The foundation class that described support storehouse refers in realizing translating;
Dispose collector, dispose the execution entrance of Java source code, obtain the executable file of Java source code.
16. one kind is converted to the system of Java source code with the TTCN-3 script, it is characterized in that, comprising:
Translater makes up module, makes up the translater of described TTCN-3 script;
Translater;
Support the storehouse to make up module, make up the required support storehouse of the described Java source code of operation;
Support the storehouse, the foundation class that described support storehouse refers in realizing translating;
Dispose the execution entrance of Java source code, obtain the executable file of Java source code.
Described translater comprises:
Morphology syntax parsing module, described morphology syntax parsing module is finished the document code of described TTCN-3 script to the conversion of syntax tree data structure;
The symbol table module records the symbol table in the document code of described TTCN-3 script, provide symbol table retrieval, introduce operation;
Semantic module, the scanning syntax tree carries out semantic test, associated nodes and corresponding symbol;
Code generation module is finished the module syntax tree to the conversion of Java source code.
CN201210400741.XA 2012-10-19 2012-10-19 TTCN-3 script is converted to a method for Java source code, device and system Active CN102929680B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210400741.XA CN102929680B (en) 2012-10-19 2012-10-19 TTCN-3 script is converted to a method for Java source code, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210400741.XA CN102929680B (en) 2012-10-19 2012-10-19 TTCN-3 script is converted to a method for Java source code, device and system

Publications (2)

Publication Number Publication Date
CN102929680A true CN102929680A (en) 2013-02-13
CN102929680B CN102929680B (en) 2016-03-02

Family

ID=47644490

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210400741.XA Active CN102929680B (en) 2012-10-19 2012-10-19 TTCN-3 script is converted to a method for Java source code, device and system

Country Status (1)

Country Link
CN (1) CN102929680B (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546342A (en) * 2013-10-18 2014-01-29 工业和信息化部电信传输研究所 Terminal consistency testing method and API (application program interface) interface general adapter for terminal consistency testing method
CN103984539A (en) * 2014-04-14 2014-08-13 美的集团股份有限公司 Operation method and operation system for household appliance
CN105159680A (en) * 2015-09-16 2015-12-16 北京航空航天大学 Automatic generation method for Java object information analysis program
CN105786465A (en) * 2014-12-23 2016-07-20 远光软件股份有限公司 Scripting language execution method and device
CN107656726A (en) * 2017-10-10 2018-02-02 北京元比特科技有限责任公司 A kind of internet information and Techno-sharing platform and method
CN108153522A (en) * 2017-12-25 2018-06-12 南京大学 Based on model conversion by the method for midcore generation Spark and Hadoop program codes
EP3608785A1 (en) 2018-08-09 2020-02-12 PiRo Systems Engineering GmbH Keyword-driven requirements
CN110874213A (en) * 2019-11-12 2020-03-10 广州银汉科技有限公司 Runtime type extension and reflection method of static strong type language
CN111176657A (en) * 2019-12-12 2020-05-19 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for realizing C language codec based on TTCN-3 test platform
CN111694738A (en) * 2020-06-04 2020-09-22 贵州易鲸捷信息技术有限公司 Method for generating SQL test script
CN112269566A (en) * 2020-11-03 2021-01-26 支付宝(杭州)信息技术有限公司 Script generation processing method, device, equipment and system
EP3851976A1 (en) 2020-01-16 2021-07-21 Peter Nicke Ontology-driven database
CN113157257A (en) * 2021-04-12 2021-07-23 山东省城市商业银行合作联盟有限公司 Quick development device for bank system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6298389B1 (en) * 1997-06-20 2001-10-02 Compaq Computers, Inc. Method for input and output of structures for the Java language
CN1786925A (en) * 2005-03-08 2006-06-14 中国科学院软件研究所 TTCN-3 testing system basedon C++ mapping and its testing method
CN101408849A (en) * 2008-12-01 2009-04-15 中国科学技术大学 Method and system for compiling and executing TTCN-3 language

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6298389B1 (en) * 1997-06-20 2001-10-02 Compaq Computers, Inc. Method for input and output of structures for the Java language
CN1786925A (en) * 2005-03-08 2006-06-14 中国科学院软件研究所 TTCN-3 testing system basedon C++ mapping and its testing method
CN101408849A (en) * 2008-12-01 2009-04-15 中国科学技术大学 Method and system for compiling and executing TTCN-3 language

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
蒋凡 等: "TTCN-3语言类型系统到C++语言的翻译方案", 《计算机工程与应用》, vol. 45, no. 30, 31 December 2009 (2009-12-31) *

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546342A (en) * 2013-10-18 2014-01-29 工业和信息化部电信传输研究所 Terminal consistency testing method and API (application program interface) interface general adapter for terminal consistency testing method
CN103546342B (en) * 2013-10-18 2016-10-05 工业和信息化部电信传输研究所 A kind of terminal consistency test method and the api interface universal adapter for the method
CN103984539A (en) * 2014-04-14 2014-08-13 美的集团股份有限公司 Operation method and operation system for household appliance
CN105786465A (en) * 2014-12-23 2016-07-20 远光软件股份有限公司 Scripting language execution method and device
CN105159680A (en) * 2015-09-16 2015-12-16 北京航空航天大学 Automatic generation method for Java object information analysis program
CN105159680B (en) * 2015-09-16 2018-12-28 北京航空航天大学 The automatic generation method of Java object information analysis program
CN107656726A (en) * 2017-10-10 2018-02-02 北京元比特科技有限责任公司 A kind of internet information and Techno-sharing platform and method
CN108153522A (en) * 2017-12-25 2018-06-12 南京大学 Based on model conversion by the method for midcore generation Spark and Hadoop program codes
EP3608785A1 (en) 2018-08-09 2020-02-12 PiRo Systems Engineering GmbH Keyword-driven requirements
CN110874213A (en) * 2019-11-12 2020-03-10 广州银汉科技有限公司 Runtime type extension and reflection method of static strong type language
CN110874213B (en) * 2019-11-12 2021-02-12 广州银汉科技有限公司 Runtime type extension and reflection method of static strong type language
CN111176657A (en) * 2019-12-12 2020-05-19 上海微波技术研究所(中国电子科技集团公司第五十研究所) Method and system for realizing C language codec based on TTCN-3 test platform
CN111176657B (en) * 2019-12-12 2023-04-28 上海微波技术研究所(中国电子科技集团公司第五十研究所) C language codec implementation method and system based on TTCN-3 test platform
EP3851976A1 (en) 2020-01-16 2021-07-21 Peter Nicke Ontology-driven database
CN111694738A (en) * 2020-06-04 2020-09-22 贵州易鲸捷信息技术有限公司 Method for generating SQL test script
CN112269566A (en) * 2020-11-03 2021-01-26 支付宝(杭州)信息技术有限公司 Script generation processing method, device, equipment and system
CN113157257A (en) * 2021-04-12 2021-07-23 山东省城市商业银行合作联盟有限公司 Quick development device for bank system
CN113157257B (en) * 2021-04-12 2024-03-29 山东省城市商业银行合作联盟有限公司 Rapid development device for banking system

Also Published As

Publication number Publication date
CN102929680B (en) 2016-03-02

Similar Documents

Publication Publication Date Title
CN102929680B (en) TTCN-3 script is converted to a method for Java source code, device and system
US10698682B1 (en) Computerized software development environment with a software database containing atomic expressions
Gargantini et al. A metamodel-based language and a simulation engine for abstract state machines.
Kolovos et al. Detecting and repairing inconsistencies across heterogeneous models
US20070169027A1 (en) Methods and systems for complete static analysis of software for building a system
Verbeek et al. Verifying workflows with cancellation regions and or-joins: An approach based on relaxed soundness and invariants
US20090100405A1 (en) Synchronizing an abstract model and source code
Janota et al. Reasoning about feature models in higher-order logic
US20070079299A1 (en) Method, apparatus and program storage device for representing eclipse modeling framework (EMF) ecore models in textual form
CN101515232A (en) Software continuous integration system and method
Arcaini et al. AsmetaSMV: a way to link high-level ASM models to low-level NuSMV specifications
Kling et al. MoScript: A DSL for querying and manipulating model repositories
US11294665B1 (en) Computerized software version control with a software database and a human database
Greiner et al. Bidirectional transformations with QVT-R: a case study in round-trip engineering UML class models and Java source code
US20100088274A1 (en) System and method for synchronizing a repository with a declarative defintion
CN101980546B (en) Intelligent network platform, service execution method and method for analyzing service abnormality
Hussmann et al. Modular architecture for a toolset supporting OCL
Reimann et al. Role-based generic model refactoring
Schieferdecker et al. A meta-model for TTCN-3
Pons et al. Traceability across refinement steps in UML modeling
Sanchez-Cid et al. Serenity pattern-based software development life-cycle
Darvas et al. Faithful mapping of model classes to mathematical structures
Karol Well-formed and scalable invasive software composition
Kiniry et al. Ensuring consistency between designs, documentation, formal specifications, and implementations
Bauml et al. Reconstruction of type information from java bytecode for component compatibility

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
CB03 Change of inventor or designer information

Inventor after: Luo Qingsong

Inventor after: Wang Wei

Inventor after: Yang Xijun

Inventor before: Zhou Yi

Inventor before: Zou Zhibin

Inventor before: Li Lulu

Inventor before: Ran Zheng

COR Change of bibliographic data
C14 Grant of patent or utility model
GR01 Patent grant
CB03 Change of inventor or designer information

Inventor after: Luo Qingsong

Inventor after: Wang Wei

Inventor after: Yang Xijun

Inventor before: Luo Qingsong

Inventor before: Wang Wei

Inventor before: Yang Xijun

COR Change of bibliographic data