CN102929680B - TTCN-3 script is converted to a method for Java source code, device and system - Google Patents

TTCN-3 script is converted to a method for Java source code, device and system Download PDF

Info

Publication number
CN102929680B
CN102929680B CN201210400741.XA CN201210400741A CN102929680B CN 102929680 B CN102929680 B CN 102929680B CN 201210400741 A CN201210400741 A CN 201210400741A CN 102929680 B CN102929680 B CN 102929680B
Authority
CN
China
Prior art keywords
ttcn
script
source code
code
java source
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.)
Active
Application number
CN201210400741.XA
Other languages
Chinese (zh)
Other versions
CN102929680A (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

Abstract

The invention discloses a kind of method, the Apparatus and system that TTCN-3 script are converted to Java source code, to carry out the compiling being directed to TTCN-3 script.First, build the translater of TTCN-3 script, TTCN-3 script, after carrying out analysis verification to test target file, is translated into Java file according to predefined translation rule by this translater.The translation rule of combining translation device, build Java operation support storehouse, this Support Library realizes the foundation class referred in translation scheme, and completes the execution of code and the work such as the record of execution result that generate translation.By the code after the translation of combining translation device and operation support bank code, the complete Java source code meeting TTCN-3 semanteme can be obtained.The method eliminates the process of compiler intermediate language and object code optimization, implements simple and convenient, oneself can customize the grammer scope translated.

Description

TTCN-3 script is converted to a 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 TTCN-3 script being converted to Java source code.
Background technology
TTCN-3 (TestingandTestControlNotationversion3, test and testing and control representation-3), is a kind of mutatis mutandis exploitation programming language of test of International standardization, is exclusively used in various test.Typical application is system testing, interactivity test, protocol test, operational trials, service testing, module testing etc.Such as, can be undertaken moving by TTCN-3 and test with Internet protocol, based on the CORBA (CommonObjectRequestBrokerArchitecture of platform, Common Object Request Broker Architecture) test, API (Applicationprogramminginterface application programming interface,) test and the compliance test etc. for the basic software module that describes AUTOSAR (automobile open system framework, AutomotiveOpenSystemsArchitecture) standard.
Run TTCN-3 test script, need corresponding TTCN-3 compiler.Usually, the compiler of programming language is the executable code be directly translated as by language on target machine executable code or target virtual machine.But the implementation method that TTCN-3 compiler mainly adopts but is TTCN-3 language is converted into the higher level lanquage (as Java, C++ etc.) that a certain class can compile, and then third party's compiler is utilized to obtain executable file.Although certain compile efficiency that this mode is sacrificed, utilize already present higher level lanquage, can generate and back-end code Optimization Work by simplified code, greatly reduce the difficulty of compiler development.
Compiler known is at present all business compiler, fetch long price, although powerful, in a practical situation, does not need compiler to support complete TTCN-3 grammer.Such as in the test script that AUTOSARV4.0 is subsidiary, just do not use message based communication mode.Therefore, when syntactic element set relative decrease, according to according to the TTCN-3 grammer being compiled script and using, oneself building a set of transcoding scheme.Due to the subset that syntactic element is only complete TTCN-3 language, the difficulty of self-mutilation behavior and complexity also can correspondingly reduce, and the translation function realized based on the method has higher cost performance.
Summary of the invention
The object of this invention is to provide a kind of method, Apparatus and system TTCN-3 script being converted to Java source code file, pass through the present invention, can ensure to change the semantic semanteme regulation meeting standard TTCN-3 completely of post code, the Java source code further after conversion directly can be compiled as bytecode by Java compiler.
The invention discloses method TTCN-3 script being converted to Java source code, comprising:
Build the translater of TTCN-3 script;
Described TTCN-3 script is translated according to predefined translation rule by described translater, converts Java source code to;
In conjunction with described translation rule, build the Support Library run needed for Java source code; Described Support Library realizes the foundation class referred in translation;
The execution entrance of configuration Java source code, obtains the executable file of Java source code.
Preferably, described TTCN-3 script is translated according to predefined translation rule, converts Java source code to and comprises and carry out lexical analysis and grammatical analysis to TTCN-3 script, described lexical analysis and grammatical analysis further comprising the steps:
The mistake of morphology and grammer in TTCN-3 script described in School Affairs correction, analyzes morphology and syntactic structure, and generative grammar is set;
Syntax tree is scanned, carries out semantic analysis;
Be scanned across the syntax tree of semantic analysis, generate corresponding Java source code.
Preferably, described translater comprises step further: the symbol in record TTCN-3 script file code, provides the retrieval of symbol table, introduces operation.
In addition, described semantic analysis comprises carries out semantic test to the code in TTCN-3 script, associates the symbol in the code in described TTCN-3 script, stores the information generated required for Java source code, prepares for generating Java source code.
Translater carries out lexical analysis to TTCN-3 script file and grammatical analysis is by means of JavaCC and JJTree instrument, and realize by writing the file meeting BNF normal form, described BNF normal form can be cut out according to demand.
Whether wherein, semantic analysis performs in a certain order: for the modules A of input TTCN-3 script file, first judge A analyzed mistake; If then terminate the semantic analysis to A, then check each the possible introducing B existed in A if not; If the analyzed mistake of B, then all symbols all in B are incorporated in the symbol table of current block; If the not analyzed mistake of B, then first carry out semantic analysis to B, then be incorporated in the symbol table of current block by all symbols all in B; Each the possible introducing B existed in A is carrying out semantic analysis to A, and is identifying A for analyzing, terminating the semantic analysis to A after detecting.
The invention also discloses a kind of device TTCN-3 script being converted to Java source code, it is characterized in that, comprising:
Translater builds module, builds the translater of TTCN-3 script;
Translater, described TTCN-3 script is translated according to predefined translation rule by described translater, converts Java source code to;
Support Library builds module, in conjunction with described translation rule, builds the Support Library run needed for Java source code;
Support Library, described Support Library realizes the foundation class referred in translation;
Configuration collector, the execution entrance of configuration Java source code, obtains the executable file of Java source code.
Translater comprises analysis module TTCN-3 script being carried out to lexical analysis and grammatical analysis further, and described analysis module comprises:
Morphology syntax parsing module, the mistake of morphology and grammer in TTCN-3 script described in School Affairs correction, analyzes morphology and syntactic structure, and generative grammar is set;
Semantic module, scans syntax tree, carries out semantic analysis;
Code generation module, is scanned across the syntax tree of semantic analysis, generates corresponding Java source code.
Described translater comprises symbol table module further, and the symbol in record TTCN-3 script file code, provides the retrieval of symbol table, introduces operation.
In addition, described semantic module comprises further carries out semantic test to the code in TTCN-3 script, associate the symbol in the code in described TTCN-3 script, store the information generated required for Java source code, for generating the module that Java source code is prepared.
Wherein, translater carries out lexical analysis to TTCN-3 script file and grammatical analysis is by means of JavaCC and JJTree instrument, and realize by writing the file meeting BNF normal form, described BNF normal form can be cut out according to demand.
Whether preferably, described semantic analysis performs in order: for the modules A of input TTCN-3 script file, first judge A analyzed mistake; If then terminate the semantic analysis to A, then check each the possible introducing B existed in A if not; If the analyzed mistake of B, then all symbols all in B are incorporated in the symbol table of current block; If the not analyzed mistake of B, then first carry out semantic analysis to B, then be incorporated in the symbol table of current block by all symbols all in B; Each the possible introducing B existed in A is carrying out semantic analysis to A, and is identifying A for analyzing, terminating the semantic analysis to A after detecting.
The invention also discloses the scheme that TTCN-3 script is converted to Java source code by another, comprise step:
Build the translater of TTCN-3 script;
Described translater comprises described translater and completes the conversion of TTCN-3 script file code to syntax tree data structure; Symbol table in record TTCN-3 script file code, provides the retrieval of symbol table, introduces operation; Scanning syntax tree, carries out semantic test, associated nodes and corresponding symbol; Complete the conversion of module syntax tree to Java source code;
Build the Support Library run needed for Java source code; Described Support Library realizes the foundation class referred in translation;
Configuration collector, the execution entrance of configuration Java source code, obtains the executable file of Java source code.
And disclose a kind of system TTCN-3 script being converted to Java source code, described system comprises:
Translater builds module, builds the translater of TTCN-3 script;
Translater;
Support Library builds module, builds the Support Library run needed for Java source code;
Support Library, described Support Library realizes the foundation class referred in translation;
The execution entrance of configuration Java source code, obtains the executable file of Java source code.
Described translater comprises further:
Morphology syntax parsing module, morphology syntax parsing module, completes the conversion of TTCN-3 script file code to syntax tree data structure;
Symbol table module, the symbol table in record TTCN-3 script file code, provides the retrieval of symbol table, introduces operation;
Semantic module, scanning syntax tree, carries out semantic test, associated nodes and corresponding symbol;
Code generation module, completes the conversion of module syntax tree to Java source code.
Can find out, the protocol procedures that the present invention provides is less, gives Java compiler process by the intermediate code optimizing process of conventional compiler device.Meanwhile, once compile by Java language the characteristic run everywhere, this method can make TTCN-3 script run under different operating system.In addition, because TTCN-3 to Java itself is higher level lanquage, therefore, new TTCN-3 grammer is expanded also comparatively easy.When implementing, only need to make translater increase new grammer support, and in Java Support Library, add the java class of new definition.
Accompanying drawing explanation
Fig. 1 is total execution flow process of the present invention.
Fig. 2 is the node class figure used in the present invention.
Fig. 3 is symbol table snapshot structure in the present invention.
Fig. 4 is symbol table class figure in the present invention.
Fig. 5 is that in the present invention, semantic analysis order determines process flow diagram.
Fig. 6 is that in the present invention, entity elements supports class figure.
The class figure (A) of the type/data related in Fig. 7 the present invention.
The class figure (B) of the type/data related in Fig. 8 the present invention
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in further detail:
Fig. 1 gives of the present invention set forth total execution flow process TTCN-3 script file (* .ttcn) being converted to Java source code file.First this process needs the translater of a structure TTCN-3 script file, and TTCN-3 script file can be converted to a Java source code file by this translater.
Then build the Support Library run needed for Java source code, described Support Library realizes the foundation class referred in translation, is compiled the Java source code that translation generates by Java compiler, performs the Java source code that described translation generates.
Wherein, translater performs the significant element of TTCN-3 script file to Java source code file transform; For specifically, this translater needs to comprise following function:
(1) lexical analysis is carried out, grammatical analysis to all TTCN-3 script files.The Main Function of this process gets rid of some fundamental errors in script file, the mistake check and correction that such as misspelling etc. are conventional, when errors are detected, sends error reporting in time in an informed way, facilitate commissioning staff to modify, and or carry out auto modification for frequent fault; This process finally understands generative grammar tree.
(2) syntax tree is scanned, carry out semantic analysis.Semantic analysis process mainly carries out semantic test to code.In addition, this process also can symbol in association code, stores the information required for generating code, for code generation process is prepared.
(3) be scanned across the syntax tree of semantic analysis, generate corresponding Java source code.In the specific implementation, a TTCN-3 file can be exchanged into a Java source file, and a TTCN-3 module can be mapped to a java class and gets on, and is so just easy to set up the corresponding relation between file and even statement.
Build the Support Library of Java, the Java source code after these Java source code files ensure that translation can correctly be compiled.
Code after combination translation and Support Library, and configure the execution entrance of whole Java source code, can the complete Java source code run be obtained.
From a structural point, this translater contains with lower module:
Morphology syntax parsing module: complete the conversion of TTCN-3 script file code to syntax tree data structure;
Symbol table module: the symbol table in record TTCN-3 script file code, provides the retrieval of symbol table, introduces operation;
Semantic module: analysis module scanning syntax tree, carries out semantic test, associated nodes and corresponding symbol;
Code generation module: complete the conversion of module syntax tree to Java source code.
structure morphology syntax parsing module
First translater carries out lexical analysis and grammatical analysis to TTCN-3 script file, by means of JavaCC and JJTree instrument, only needs to write the normal form file meeting instrument and specify, can generate corresponding morphology and the Java source code of syntax parsing.Wherein, JavaCC (JavaCompilerCompiler) is a grammatical analysis maker with Java exploitation.Concrete BNF normal form can carry out certain cutting according to oneself demand, for the syntactic element do not related in those TTCN-3 script files, then can be deleted.After normal form has write normal form file, instrument will generate corresponding node class and morphology syntax parsing device for the nonterminal symbol in BNF normal form.The normal form of the TTCN-3 of normative reference, its node class formation is shown in accompanying drawing 2.
In fig 2, Node interface is the interface that all node classes all need to realize, and it provides the access method to child nodes and father node.JjtGetChildNum () method obtains the number of child nodes, and jjtGetChild () method can obtain the child nodes of specifying, and jjtAccept () method makes Accessor Classes can access this node.
SimpleNode class achieves Node interface enterLocation, and it is the base class of other all nodes.This method with the addition of getStartPosition () method in SimpleNode class, to record the position of node in source code.Nodal information is then outputted to the printing device of specifying with the mode recurrence of text and gets on by dump () method.
StrcutFieldDef class and RecordDef class just inherit SimpleNode class, and they are exactly the node class generated by corresponding BNF normal form.After semantic analysis completes, each TTCN-3 code file will be converted into a syntax tree synthesized by node class example set.
After opening the VISITOR option of JJTree instrument, also can generate ParserVisitor interface, this interface is that syntax tree visitor needs to realize interface, and each node class is to should visit () method in interface.If need to access syntax tree, will realistic this interface existing.Specifically, in ensuing semantic module and code generation module, just need all the visit () methods realized in this interface, to access all syntax tree nodes.
All node class names and its extend information as shown in table 1:
The list of table 1 node class
structure symbol table module
According to TTCN-3 grammatical norm, static state during the semiotic function territory of TTCN-3 language, namely TTCN-3 script file code book body structure just determines the action scope of symbol in code.Each action scope unit comprises mutually, and in falling tree structure, all symbols inside father's action scope unit are all visible to its all sub-action scope.Because the semantic analysis stage needs to carry out a large amount of symbolic look-up accessing operations, therefore, symbol table, except ensureing efficient search capacity, also needs the symbol ensureing to find to come from correct action scope.
In the specific implementation, this programme will by a chain stack, the name space of maintain symbol.At a time its snapshot as shown in Figure 3, and when entering a new semiotic function territory, (as when entering a new function) will set up a new action scope object, and is set to current action scope.Exiting before prescope or newly-built action scope, all symbols newly added will be organized with the form of doubly linked list, and if when the symbolic name newly added exists hash-collision (or of the same name), the symbol newly added will cover former symbol.Do like this and can ensure when Hash lookup, the symbol of the always innermost layer action scope found.During concrete enforcement, for improving development efficiency, the Hash table that Java self can be used to provide supports class.
Fig. 4 provides class figure when symbol table is specifically implemented, and symbol table module is externally mutual by the mono-routine class of SymbolTbl.The multiple Scope object of Symbol object internal maintenance, they are organized with the form of storehouse.Semantic module is added on a new Scope object and storehouse by newScope () method, and is set to current action scope.After this, new symbol all adds this action scope by enter () method, and lookup () method is for retrieving all symbols in name space.When semantic module calls leave () method, when prescope object will be released, and symbols all inside it also discharges thereupon.
constructing semantic analysis module
Semantic module mainly carries out semantic test to syntax tree, needs to use symbol table to carry out recording indexes current sign information in checking process.Semantic module, as visitor, needs to realize ParserVisitor interface.To each node class, just need to realize corresponding with it visit () method.
the semantic analysis order of determination module
In TTCN-3, there is symbol introduce (by import keyword identification) mechanism, the symbol definition under this makes current block (module) can quote other modules.Such as, define TypeA in ModuleA, ModuleB introduces ModuleA, and defines the example InsA of TypeA.In order to verify the correctness in definition of InsA, check according to the definition of TypeA with regard to needing.In order to ensure that this inspection can be carried out smoothly, a kind of simple method ensures that the module of all references all completes semantic analysis.That is the ModuleA first scanned, and then scan ModuleB, just correctly can 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, topological sorting can be used to carry out determination module scanning sequency.Whether Fig. 5 gives a kind of feasible algorithm flow: for input TTCNModuleA, first judge A analyzed mistake; If then terminate the semantic analysis to A, then check each the possible introducing B existed in A if not; If the analyzed mistake of B, then all symbols all in B are incorporated in the symbol table of current block; If the not analyzed mistake of B, then first carry out semantic analysis to B, then be incorporated in the symbol table of current block by all symbols all in B; Each the possible introducing B existed in A is carrying out semantic analysis to A, and is identifying A for analyzing, terminating the semantic analysis to A after detecting.
the delay association of module internal symbol
Similar Java language, in a module, TTCN-3 allows the type first quoting rear statement, such as: following definition is legal.
This backward mode quoted can run into and cannot find in symbol table by TypeA when result in depth-first fashion scanning syntax tree.In order to avoid this situation, this method has declared IInstance interface (with reference to figure 3), and this node inherits ISymbolized interface, for the node of mainly above-mentioned containing type definition.When first time scans undefined symbol, this method first step only checks the uniqueness of this symbolic name, then puts it into one and does not complete in queue.After having scanned the syntax tree of current block, then second step association process is carried out to the IInstance example that this does not complete inside queue.
structure code translation module
Code generation module is responsible for generating a Java source code file for each syntax tree after semantic analysis terminates.Be similar to semantic analysis, code translation module needs to realize ParserVisitor interface.The Java source code meeting generated by translation module and Support Library are combined, and form final compiling result.The translation of code is according to following rule:
Type definition: for type definition node, generates a new class after translation, and such inherits class corresponding in Support Library.This category node comprises: TTCN3Module, ModuleControlPart, SubTypeDef, RecordDef, RecordOfDef, EnumDef, SignatureDef, ComponentDef, PortDef, TestCaseDef, AltstepDef (as shown in table 1).The class name generated is identical with type name in TTCN-3 code.Form because each TTCN-3 module is defined by the above-mentioned type, so the code after translation is combined into by these classes.Child node is comprised to the node of executable statement node, comprise TestCaseDef, AltstepDef, FunctionDefPart, ModuleControlPart, they all comprise executable code, therefore, the class after 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, acquisition MTC assembly method, acquisition System assembly method and some built-in functions (as ispresent () function), this method can realize in advance in the T3RTSystem class in operation support storehouse, and this class is a routine class of overall addressable list.If comprise the call statement of these methods in TTCN-3 code, this statement translation is the Java statement calling method of the same name in T3RTSystem class by translater.
Variable constant definition: in statement block, often can comprise local variable definition.When entering action scope, if run into local variable statement statement, this definition translation can be addVariable () call statement by translater.In this way, this local variable will join when code finally runs in the action scope at its place.In order to safeguard action scope, end up at each statement block, translater will be also the call statement that each local variable generates delVariable () method, previously adds this action scope ground local variable to empty.For the constant definition in statement block, translater adopts identical strategy.The organizational form of the local variable of concrete action scope is responsible for by 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 class corresponding with it in advance in operation support storehouse, respectively: IntegerType, FloatType, BooleanType, VerdictType, these classes are all bonding examples, are obtained such instance objects by getInstance ().When running into a constant value, translater will translate into the statement that form is <Class-Name>.getInstance () .newInstance (<InitValue>), wherein <Class-Name> is corresponding class name, and <InitValue> is initial value.
Control statement: control statement mainly comprises conditional statement (by if keyword identification), loop statement (by for, while keyword identification), after running into these statements, translater can be translated into control statement completely corresponding with it in Java.Also have some key words, as break key word, return key word, is also translated into corresponding Java key word.
Optional step statement: for optional step statement block, translater is translated into the do-while loop statement in Java, and whether circulation terminates by checking that snapshot state judges.Each conditional statement in optional step statement block is translated into the if statement in Java language.The interpretative system that repeat key word in optional step statement is corresponding is throw exception, and this can ensure once to jump out multilayer circulation.The structure of optional step is as shown in the table.
The table 2 optional step translation table of comparisons
Port method call: when running into call, during getcall, reply, getreply method call, translater is translated into the method call of corresponding Java, and it is good that these methods construct all in advance in the class in operation support storehouse.
operation support storehouse
Code after translation will combine compiling with operation support storehouse, and operation support storehouse realizes the foundation class referred in translation scheme, and complete the execution of code and the work such as the record of execution result that generate translation.
For the module (by module keyword identification) in TTCN-3 language, control the entity elements such as (by control keyword identification), test case (by testcase keyword identification), function (by function keyword identification), optional step (by altstep keyword identification), operation support storehouse is the base class that each element realizes that completes this element basic function.And be exactly the process of structure one to the concrete subclass that base class is expanded to the translation process of concrete element individuality.As shown in Figure 6, following entity elements is had to support class in operation support storehouse.
AbstractModule class is the base class of all block elements translation results in TTCN-3, achieves the management to elements such as the constant defined in module, control, behavior (i.e. test case, function and optional step), function signature (by signature keyword identification);
AbstractControl class is the base class of control element translation result in TTCN-3, achieves the functions such as control and measuring use-case execution;
AbstractTestcase class is the base class of control element translation result in TTCN-3, achieves the management to test case execution result and test suite (component);
AbstractFunction class is the base class of functional element translation result in TTCN-3, achieves the management to the variable in function, constant and rreturn value;
AbstractAltstep class is the base class of optional step element translation result in TTCN-3, achieves the management to the variable in optional step, constant;
Control, test case, function, optional step are all the executable in TTCN-3, and their subclass of all expansions all must realize run () method according to operational semantics.
In TTCN-3 language, define some basic data types, in addition, user can be expanded basic data type according to actual needs, retrain or instantiation, define 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, list type etc.).No matter each data type, be fundamental type or user defined type, belong to certain large class all uniquely.In operation support storehouse, for the large class of each data type establishes a base class, they are IntegerType, FloatType, BooleanType, VerdictType, CharstringType, RecordType, RecordOfType respectively.Each base class is expanded from TypeImpl class, and TypeImpl class achieves Type interface.All user defined types are all translated into the subclass of the base class to class large belonging to it, realize the expansion to base class or constraint.
In TTCN-3, all data values all belong to a specific data type, see Fig. 7 and Fig. 8, correspond to the object that extends ValueImpl class in translation scheme.ValueImpl class achieves Value interface, contains concrete data message.ValueImpl class also has a member territory achieving Type interface, the object that the data type of this member belonging to ValueImpl class is corresponding.The getType () method calling Value interface will return this member.Correspondingly, have individual newInstance () method in Type interface, call the method by the data value object of data type corresponding for establishment one, namely one achieves the example of Value interface.And belong to all subclasses achieving Type interface of a large class, even if the concrete data type representated by it is different, the example achieving Value interface created by calling its newInstance () method is all the object of same class.Such as, IntegerValueImpl class extends ValueImpl class and achieves 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 the object of an IntegerValueImpl class be returned.Corresponding also have the classes such as FloatValueImpl, BooleanValueImpl, VerdictValueImpl, CharstringValueImpl, RecordValueImpl, RecordOfImpl.
Service data type and data value are come according to the pattern of abstract factory in operation support storehouse, the newInstance () method setting up the Type example that a data value must use data type belonging to it corresponding creates, and ensure that type matching and compatible feasibility.
Assembly (by component keyword identification) is the core in TTCN-3, represents the entity performing TTCN-3 semanteme.All test cases, function, optional step all perform in specific assembly, and each assembly is exactly the clue of a semantic execution.Communication is realized by the mode of message or the invocation of procedure between assembly.Operation support storehouse Component class represents an assembly, and the expansion of Component class is from ValueImpl class, and namely Component is a special data value.In translation scheme, the definition of each assembly is translated into a subclass of ComponentType class, and the operation creating assembly is then realized by the newInstance () method calling corresponding ComponentType object.Component class manages the port, variable, constant and the timer that define in assembly.
Operation support storehouse adopts the mode of multithreading to support the parallel work-flow of multiple assembly in testing engineering, territory containing a Thread type in Component class, be used for the semantic operation that executive module needs to perform, by calling execute () method and specifies and performing the semantic operation that needs carry out.Component class also maintains a communication queue, under two principles of first in first out and Data Matching, and the communication between supporting assembly.The thread synchronization mechanism of operation support Cooley Java language safeguards the consistance of assembly data sharing.
T3RTSystem class adopts singleton pattern to realize, and is responsible for the execution controlling whole testing engineering, and collects the execution result of all test cases, safeguard execution journal information and carry out error handling processing.By the configuration of property file, the measurand adapter (SUTAdapter) that can use in nominative testing system, the execution starting point of coder/decoder (Coder/Decoder) and generating code.When in the code translating generation and operation support storehouse, other classes are carried out mutual, T3RTSystem class also plays intermediate axle beam action, thus generating code is hidden to the specific implementation in operation support storehouse as much as possible.
It should be noted that, the content such as information interaction, implementation between said apparatus and intrasystem each unit, due to the inventive method embodiment based on same design, particular content can see in the inventive method embodiment describe, repeat no more herein.
Apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping; Meanwhile, 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 (8)

1. TTCN-3 script is converted to a method for Java source code, it is characterized in that, comprising:
Build the translater of described TTCN-3 script;
Described TTCN-3 script is translated according to predefined translation rule by described translater, converts described Java source code to;
In conjunction with described translation rule, build the Support Library run needed for described Java source code; Described Support Library realizes the foundation class referred in translation;
Configure the execution entrance of described Java source code, obtain the executable file of described Java source code, described TTCN-3 script is translated according to predefined translation rule by described translater, convert described Java source code to comprise and carry out lexical analysis and grammatical analysis to described TTCN-3 script, described lexical analysis and grammatical analysis further comprising the steps:
The mistake of morphology and grammer in TTCN-3 script described in School Affairs correction, analyzes morphology and syntactic structure, and generative grammar is set;
Described syntax tree is scanned, carries out semantic analysis; Be scanned across the described syntax tree of described semantic analysis, generate corresponding described Java source code, described translater performs following steps: record the symbol in the document code of described TTCN-3 script, the retrieval of symbol table is provided, introduces operation, described semantic analysis needs to carry out symbolic look-up accessing operation, for ensureing that the symbol found comes from correct action scope; Set up a new action scope object when entering a new semiotic function territory, and be set to current action scope; Before exiting described current action scope or newly-built action scope, all symbols newly added will be organized with the form of doubly linked list, and if the symbolic name newly added there is hash-collision compared with former symbolic name or of the same name time, the symbol newly added will cover former symbol.
2. method according to claim 1, described semantic analysis comprises carries out semantic test to the code in described TTCN-3 script, associate the symbol in the code in described TTCN-3 script, storing the information generated required for Java source code, preparing for generating described Java source code.
3. method according to claim 1, translater carries out described lexical analysis to described TTCN-3 script and grammatical analysis is by means of JavaCC and JJTree instrument, realize by writing the file meeting BNB normal form, described BNB normal form can be cut out according to demand.
4. method according to claim 3, whether described semantic analysis performs in order: for the modules A of the described TTCN-3 script of input, first judge A analyzed mistake; If then terminate the semantic analysis to A, then check each the possible introducing B existed in A if not; If the analyzed mistake of B, then all symbols all in B are incorporated in the symbol table of current block; If the not analyzed mistake of B, then first carry out semantic analysis to B, then be incorporated in the symbol table of current block by all symbols all in B; After each the possible introducing B existed in A detects, then semantic analysis is carried out to A, and identify A for analyzing, terminate the semantic analysis to A.
5. TTCN-3 script is converted to a device for Java source code, it is characterized in that, comprising: translater builds module, Support Library builds module and configuration collector;
Described translater builds module, and build the translater of TTCN-3 script, described TTCN-3 script is translated according to predefined translation rule by described translater, converts Java source code to;
Support Library builds module, in conjunction with described translation rule, builds the Support Library run needed for Java source code, and described Support Library realizes the foundation class referred in translation;
Configuration collector, the execution entrance of configuration Java source code, obtains the executable file of Java source code;
Described translater comprises analysis module further, and described analysis module carries out lexical analysis and grammatical analysis to TTCN-3 script, and described analysis module comprises morphology syntax parsing module, semantic module and code generation module;
Described morphology syntax parsing module, the mistake of morphology and grammer in TTCN-3 script described in School Affairs correction, analyzes morphology and syntactic structure, and generative grammar is set;
Described semantic module, scans described syntax tree, carries out semantic analysis;
Described code generation module, be scanned across the syntax tree of semantic analysis, generate corresponding Java source code, described translater comprises symbol table module further, symbol in the document code of record TTCN-3 script, there is provided the retrieval of symbol table, introduce operation, described semantic analysis needs to carry out symbolic look-up accessing operation, for ensureing that the symbol found comes from correct action scope; Set up a new action scope object when entering a new semiotic function territory, and be set to current action scope; Before exiting described current action scope or newly-built action scope, all symbols newly added will be organized with the form of doubly linked list, and if the symbolic name newly added there is hash-collision compared with former symbolic name or of the same name time, the symbol newly added will cover former symbol.
6. device according to claim 5, described semantic module comprises further carries out semantic test to the code in TTCN-3 script, associate the symbol in the code in described TTCN-3 script, store the information generated required for Java source code, for generating the module that Java source code is prepared.
7. the device according to claim 5 or 6, translater carries out lexical analysis to described TTCN-3 script and grammatical analysis is by means of JavaCC and JJTree instrument, realize by writing the file meeting BNB normal form, described BNB normal form can be cut out according to demand.
8. device according to claim 7, whether described semantic analysis performs in order: for the modules A of the described TTCN-3 script of input, first judge A analyzed mistake; If then terminate the semantic analysis to A, then check each the possible introducing B existed in A if not; If the analyzed mistake of B, then all symbols all in B are incorporated in the symbol table of current block; If the not analyzed mistake of B, then first carry out semantic analysis to B, then be incorporated in the symbol table of current block by all symbols all in B; After each the possible introducing B existed in A detects, then semantic analysis is carried out to A, and identify A for analyzing, terminate the semantic analysis to A.
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 CN102929680A (en) 2013-02-13
CN102929680B true 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)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103546342B (en) * 2013-10-18 2016-10-05 工业和信息化部电信传输研究所 A kind of terminal consistency test method and the api interface universal adapter for the method
CN103984539B (en) * 2014-04-14 2018-04-27 美的集团股份有限公司 A kind of home appliance operation method and system
CN105786465A (en) * 2014-12-23 2016-07-20 远光软件股份有限公司 Scripting language execution method and device
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
CN108153522B (en) * 2017-12-25 2020-05-05 南京大学 Method for generating Spark and Hadoop program codes by midcore based on model conversion
EP3608785A1 (en) 2018-08-09 2020-02-12 PiRo Systems Engineering GmbH Keyword-driven requirements
CN110874213B (en) * 2019-11-12 2021-02-12 广州银汉科技有限公司 Runtime type extension and reflection method of static strong type language
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
CN111694738B (en) * 2020-06-04 2023-07-18 贵州易鲸捷信息技术有限公司 Method for generating SQL test script
CN112269566B (en) * 2020-11-03 2022-09-02 支付宝(杭州)信息技术有限公司 Script generation processing method, device, equipment and system
CN113157257B (en) * 2021-04-12 2024-03-29 山东省城市商业银行合作联盟有限公司 Rapid development device for banking 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++语言的翻译方案;蒋凡 等;《计算机工程与应用》;20091231;第45卷(第30期);第65-68、72页 *

Also Published As

Publication number Publication date
CN102929680A (en) 2013-02-13

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
US7823120B2 (en) Device, system and method for accelerated modeling
Czarnecki et al. Staged configuration using feature models
US7743368B2 (en) Method and apparatus for providing class hierarchy information for function devirtualization
US20070079299A1 (en) Method, apparatus and program storage device for representing eclipse modeling framework (EMF) ecore models in textual form
Engelen et al. Integrating textual and graphical modelling languages
Verbeek et al. Verifying workflows with cancellation regions and or-joins: An approach based on relaxed soundness and invariants
CN103164249A (en) Extension mechanism for scripting language compiler
Janota et al. Reasoning about feature models in higher-order logic
US9292586B2 (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
CN110795091B (en) Modularized route decoupling method, storage medium, electronic equipment and system
US20080127128A1 (en) Type Validation for Applications Incorporating A Weakly-Typed Language
CN101952805B (en) Efficiently correlating nominally incompatible types
US9703576B2 (en) Aspect scoping in a modularity runtime
Abi-Antoun et al. Improving system dependability by enforcing architectural intent
Boronat et al. An algebraic baseline for automatic transformations in mda
Bajovs et al. Code generation from UML model: State of the art and practical implications
Karol Well-formed and scalable invasive software composition
Kiniry et al. Ensuring consistency between designs, documentation, formal specifications, and implementations
Bencomo et al. Genie: a domain-specific modeling tool for the generation of adaptive and reflective middleware families
Owolabi et al. Development of an industry foundation classes assembly viewer
Zapata et al. A rule-based system for assessing consistency between UML models
Bürger Towards attribute grammars for metamodel semantics

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