JP2016136368A - Language conversion device - Google Patents

Language conversion device Download PDF

Info

Publication number
JP2016136368A
JP2016136368A JP2015011828A JP2015011828A JP2016136368A JP 2016136368 A JP2016136368 A JP 2016136368A JP 2015011828 A JP2015011828 A JP 2015011828A JP 2015011828 A JP2015011828 A JP 2015011828A JP 2016136368 A JP2016136368 A JP 2016136368A
Authority
JP
Japan
Prior art keywords
node
function
language
conversion
program
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
JP2015011828A
Other languages
Japanese (ja)
Other versions
JP6402639B2 (en
Inventor
村上 大介
Daisuke Murakami
大介 村上
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.)
Fuji Electric Co Ltd
Original Assignee
Fuji Electric 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 Fuji Electric Co Ltd filed Critical Fuji Electric Co Ltd
Priority to JP2015011828A priority Critical patent/JP6402639B2/en
Publication of JP2016136368A publication Critical patent/JP2016136368A/en
Application granted granted Critical
Publication of JP6402639B2 publication Critical patent/JP6402639B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

PROBLEM TO BE SOLVED: To solve problems for example, when converting a program sentence containing a selection structure containing a PROGN function, creation and allocation of a temporary variable which is substantially useless, are not performed.SOLUTION: A conversion part 14 converts a FCL program sentence which is a conversion object into a procedure type language program, based on two-dimensional structure (tree) data of a two-dimensional structure storage part 13. At the time, if there is an if sentence (step S1, YES), first a function expression of a condition clause related to the if sentence, is converted (step S2). Then, if there is PROGN in the condition clause, only one function expression is determined to an allocation object of a temporary variable, out of plural function expressions related to the PROGN (step S3), and then an optional temporary variable is allocated to the determined function expression (step S4). Then, using the allocated temporary variable, a condition branch part (then clause or the like) is created (step S5).SELECTED DRAWING: Figure 1

Description

本発明は、関数型言語で記述されたプログラムを、関数型言語処理に不向きな演算処理装置において実行可能な形に変換する言語変換装置に関する。   The present invention relates to a language conversion device that converts a program written in a functional language into a form that can be executed by an arithmetic processing device unsuitable for functional language processing.

プログラマブルコントローラ(Programmable Logic Controller;以下、単に「PLC」という場合があるものとする)は、シーケンス制御プログラムを実行し、制御対象機器を制御するものである。   A programmable controller (programmable logic controller; hereinafter simply referred to as “PLC” in some cases) executes a sequence control program and controls a device to be controlled.

このプログラマブルコントローラが実行するシーケンス制御プログラムとしては、図6に示すように、例えばPLC用言語としての表現依存部とマシン語としての機械依存部との間に中間言語としての関数型制御言語がある。尚、上記PLC用言語としては、例えは図示のように、ニーモニック記述、ラダー図、ファンクションブロック図、SFC図(Sequential Function Chart)、ディシジョンテーブル、等がある。また、上記関数型制御言語は、Functional Control Languageであり、これを略して以下「FCL」という場合もあるものとする。関数型制御言語を、関数型言語と記す場合もある。   As a sequence control program executed by the programmable controller, as shown in FIG. 6, for example, there is a functional control language as an intermediate language between an expression dependency portion as a PLC language and a machine dependency portion as a machine language. . Examples of the PLC language include a mnemonic description, a ladder diagram, a function block diagram, an SFC diagram (Sequential Function Chart), a decision table, etc., as shown in the figure. The functional control language is Functional Control Language, which may be abbreviated as “FCL” hereinafter. The functional control language is sometimes referred to as a functional language.

FCLについては特許文献1、特許文献2等で説明されているが、ここで簡単にFCLを説明する。
上記FCLは、シーケンス制御プログラムを関数型のプログラム構造で表現した言語である。
Although FCL is described in Patent Document 1, Patent Document 2, and the like, FCL will be briefly described here.
The FCL is a language expressing a sequence control program with a functional program structure.

図7は、関数型制御言語の基本構造の一例を示す図である。
FCLでは、図7に示すように、一つの機能を、引数Ar1、Ar2、Ar3、・・・を持つ関数式Fで表している。引数は例えばオペランド(変数など)等であるが、別の関数式を関数式Fの引数とすることもできる。つまり、関数式自身を別の関数式の引数とすることができる。よって、ある関数式と、この関数式の引数(この中には別の関数式も含まれる場合もある)との関係を、ツリー構造(機能構造)として二次元的に表現することができる。
FIG. 7 is a diagram illustrating an example of a basic structure of a functional control language.
In FCL, as shown in FIG. 7, one function is represented by a function formula F having arguments Ar1, Ar2, Ar3,. The argument is, for example, an operand (such as a variable), but another function expression may be used as the argument of the function expression F. That is, a function expression itself can be an argument of another function expression. Therefore, the relationship between a certain function expression and an argument of this function expression (which may include another function expression) can be expressed two-dimensionally as a tree structure (functional structure).

図8に、関数型制御言語の二次元機能構造(ツリー構造)の一例を示す。
例えば、図8の例では、関数Aが関数Bと関数Cとを引数とし、関数Bはオペランドv及びオペランドwを引数として有し、関数Cはオペランドx及び関数Dを引数として有し、関数Dはオペランドyおよびオペランドzを引数として有する。つまり、図8には、下記の式に対する2次元構造(ツリー構造)が表現されている。
(A (B v w) (C x (D y z)))
FIG. 8 shows an example of a two-dimensional functional structure (tree structure) of a functional control language.
For example, in the example of FIG. 8, function A has function B and function C as arguments, function B has operand v and operand w as arguments, function C has operand x and function D as arguments, D has operand y and operand z as arguments. That is, in FIG. 8, a two-dimensional structure (tree structure) for the following expression is expressed.
(A (B v w) (C x (D y z)))

尚、図8に一例を示すような二次元機能構造(ツリー構造)では、各関数やオペランド(変数など)をノード(図示の四角形)とし、任意のノード間の直線は該ノード間のリンクを示す。例えば、ノードAは、上記関数Aを意味し、ノードAはノードB(関数B)とノードC(関数C)とリンクしている。これは、ノードAが、ノードBとノードCの親ノードであるものとする。換言すれば、ノードAの子ノードは、ノードBとノードCであると言える。同様に、例えば、ノードBの子ノードは、ノードvとノードwであると言える。他のノードについては特に説明しないが、図示の直線で示すリンクにより、上記親子関係が示されている。   In the two-dimensional functional structure (tree structure) shown in FIG. 8 as an example, each function or operand (variable, etc.) is a node (square in the figure), and a straight line between arbitrary nodes is a link between the nodes. Show. For example, the node A means the function A, and the node A is linked to the node B (function B) and the node C (function C). This assumes that node A is the parent node of node B and node C. In other words, it can be said that the child nodes of node A are node B and node C. Similarly, for example, it can be said that the child nodes of the node B are the node v and the node w. The other nodes will not be described in particular, but the parent-child relationship is shown by the links shown by the straight lines in the figure.

上記のように、関数型制御言語は、例えば図8に示すように言語の2次元的な表現を行う事ができ、記述性の高いものとなり、以って図6に示すような、PLCプログラムの表現依存部と機械依存部をつなぐ中間言語としての役割を果たすことができる。   As described above, the functional control language can perform a two-dimensional expression of a language as shown in FIG. 8, for example, and has a high descriptive property. Therefore, a PLC program as shown in FIG. It can play a role as an intermediate language that connects the expression dependent part and the machine dependent part.

ここで、上記特許文献1、2や特許文献3には、関数型言語のプログラムの実行方式として、命令スタックとデータスタックを用いて演算を実行する方式が示されている。このような命令スタックとデータスタックを用いて演算を実行する方式の場合、当然のこととして、命令スタックとデータスタックという手段が必要となる。よって、この様な手段を持たない装置(例えば、手続き型の命令処理を実行する装置)では、プログラム実行が困難あるいはエミュレーションするために処理性能が低下するという問題がある。   Here, Patent Documents 1 and 2 and Patent Document 3 show a method of executing an operation using an instruction stack and a data stack as an execution method of a functional language program. In the case of such a method of executing an operation using an instruction stack and a data stack, naturally, means such as an instruction stack and a data stack are required. Therefore, a device that does not have such means (for example, a device that executes procedural instruction processing) has a problem in that processing performance is degraded due to difficulty in program execution or emulation.

この様な問題を解決するために、関数型言語を手続型言語に変換して、汎用の手続型言語(たとえばC言語)で実行する方式が、提案されている(特許文献4)。
あるいは、本出願人は、以前に、特許文献5に記載の発明を提案している。
In order to solve such a problem, a method of converting a functional language into a procedural language and executing it in a general-purpose procedural language (for example, C language) has been proposed (Patent Document 4).
Alternatively, the present applicant has previously proposed the invention described in Patent Document 5.

特許文献5の発明は、上記特許文献4の発明に係わり、下記の課題を解決するものである。
まず、上記関数型言語は全ての関数に値を持ち、関数の引数に関数を記述することが可能であるため、条件分岐(たとえばIF〜THEN〜ELSE〜END_IF)を行ない、その結果をさらに、条件に用いる記述を簡単に行うことが可能である。また、条件分岐がネスト(入れ子)になったプログラムは、よく知られているものである。ここで、条件分岐処理は、実行条件によって選択された一方の式(THEN部またはELSE部)だけが実行されるべきであるのに対して、従来の変換処理による変換結果では、THEN部とELSE部の両方を実行し、その結果を選択する処理になってしまい、余計な処理実行を行うという問題が発生する。
The invention of Patent Document 5 relates to the invention of Patent Document 4 and solves the following problems.
First, since the above functional language has values for all functions and functions can be described as function arguments, conditional branches (for example, IF to THEN to ELSE to END_IF) are performed, and the results are It is possible to simply describe the condition. A program in which conditional branches are nested is well known. Here, in the conditional branch process, only one expression (THEN part or ELSE part) selected according to the execution condition should be executed, whereas in the conversion result by the conventional conversion process, the THEN part and ELSE This results in a process of executing both of the sections and selecting the result, causing a problem of performing an extra process.

上記課題に対して、特許文献5の発明は、関数型制御言語プログラムを手続型言語プログラムに変換することができ、命令スタックとデータスタックを待たない手続き形の命令処理を行うことができると共に、特に条件分岐を有する関数型制御言語プログラムについて、関数型制御言語の条件分岐命令を適切な構文に変換することができ、余分な実行や一時変数を作成することもなく効率的な実行が実現できる言語変換装置を、提供するものである。   In response to the above problem, the invention of Patent Document 5 can convert a functional control language program into a procedural language program, perform procedural instruction processing without waiting for an instruction stack and a data stack, Especially for functional control language programs with conditional branches, conditional branch instructions in functional control languages can be converted into an appropriate syntax, and efficient execution can be realized without creating extra execution or temporary variables. A language conversion device is provided.

特開平1−298444号公報JP-A-1-298444 特開平2−230426号公報JP-A-2-230426 特開平1−243126号公報JP-A-1-243126 特開2012−104065号公報JP 2012-104065 A 特開2014−59848号公報JP 2014-59848 A

ここで、上記関数型制御言語(FCL)は、全ての関数に値を持ち、関数の引数にPROGN関数を記述することが可能である。よく知られているように、PROGN関数を使用すると、複数の式を評価でき、戻り値が、最後に評価した式の結果となる。これより、PROGN関数を使用すると、選択構造(例えばIF〜THEN〜ELSE〜END_IF)やループ構造(例えばWHILE〜DO〜ENDWHIL)の条件節に、実質的に複数の式を記述することが可能である。   Here, the function-type control language (FCL) has values for all functions, and can describe a PROGN function as an argument of the function. As is well known, using the PROGN function allows multiple expressions to be evaluated, and the return value is the result of the last evaluated expression. Thus, using the PROGN function, it is possible to describe substantially multiple expressions in the conditional clause of a selection structure (for example, IF to THEN to ELSE to END_IF) or a loop structure (for example, WHILE to DO to ENDWHIL). is there.

図9に、FCLでPROGN関数を使用した選択構造文の一例を示す。
図示のプログラム例では、PROGN関数によって以下の2つの式を評価することになる。
(:=(+ b a) c)
(:=(− d e) f)
FIG. 9 shows an example of a selection structure sentence using the PROGN function in FCL.
In the illustrated program example, the following two expressions are evaluated by the PROGN function.
(: = (+ B a) c)
(: = (-De) f)

そして、戻り値が、最後に評価した式、すなわち(:=(− d e) f)の結果となり、この戻り値が‘10’である場合、(:=(− c a) a)を実行するものである。   Then, if the return value is the result of the last evaluated expression, that is, (: = (− d e) f), and this return value is “10”, execute (: = (− c a) a). To do.

図10には、上記図9に示すFCLプログラム文を、例えば上記特許文献4、5等の既存技術によって手続型言語に変換した結果を示す。この変換処理や変換結果については、殆どは、後に記載する本手法による変換処理や変換結果の説明において説明するので、ここでは特に説明しないが、この例では問題となるのは図示の“INST_5:=”であり、これについて説明する。   FIG. 10 shows the result of converting the FCL program sentence shown in FIG. 9 into a procedural language using existing techniques such as Patent Documents 4 and 5 described above. Most of the conversion processing and the conversion result will be described later in the description of the conversion processing and conversion result according to the present method, and will not be described here. However, in this example, the problem is “INST — 5: This is explained below.

まず、図10に示す変換結果における“INST_5”や“INST_6”等は、変換処理の際に全ての関数(リーフ以外のノード)に対して任意に割当てられる仮変数であり、ここでは仮変数の生成ルールは「“INST_”+任意の整数」となっているものとする。尚、“仮変数”(仮変数名)は、上記特許文献4、5における“インスタンス名”に相当すると見做しても構わない。   First, “INST_5”, “INST_6”, and the like in the conversion result shown in FIG. 10 are temporary variables that are arbitrarily assigned to all functions (nodes other than leaves) during the conversion process. It is assumed that the generation rule is “INST _” + any integer. Note that “temporary variable” (temporary variable name) may be considered to correspond to “instance name” in Patent Documents 4 and 5 above.

そして、図10に示す例では、図示のように、2行目にある“INST_5”は、その後の3行目以降で何等使用されておらず、意味が無いものとなっている。つまり、“INST_5”は実質的に必要がないものとなっている。これは、上記の通り、PROGN関数では戻り値が最後に評価した式の結果となるので、条件節が複数の式からなるとき、実行条件は最後の式の実行結果で判断される為である。   In the example shown in FIG. 10, as shown in the figure, “INST — 5” in the second line is not used at all after the third line and has no meaning. That is, “INST — 5” is substantially unnecessary. This is because, as described above, in the PROGN function, the return value is the result of the last evaluated expression, so when the conditional clause is composed of a plurality of expressions, the execution condition is determined by the execution result of the last expression. .

尚、図9では、PROGN関数に係わる関数式が2つであるので、実質的に無用となる仮変数は上記“INST_5”の1つだけとなるが、例えばPROGN関数に係わる関数式が10個あったならば、実質的に無用となる仮変数は9個となり、無駄が大きいものとなる。   In FIG. 9, since there are two functional expressions related to the PROGN function, there is only one temporary variable “INST — 5” which is substantially useless. For example, there are 10 functional expressions related to the PROGN function. If there are, there are nine temporary variables that are substantially useless, and the waste is large.

尚、特許文献4、5では「関数名−インスタンス名作成部14」によって二次元機能構造(ツリー構造)におけるノードのなかでリーフ(末端ノード)以外のノード全てに対して、“インスタンス名”(仮変数)を割当てている。つまり、全ての関数(命令)に対して、“インスタンス名”(仮変数)を割当てている。   In Patent Documents 4 and 5, the “function name-instance name creation unit 14” uses the “instance name” (for all nodes other than leaves (terminal nodes) among the nodes in the two-dimensional functional structure (tree structure). (Temporary variable) is assigned. That is, “instance names” (temporary variables) are assigned to all functions (instructions).

この様に、従来の変換処理では全ての関数式の実行結果に仮変数を割り当てるため、PROGN関数がある場合には余分な仮変数を生成してしまうことになり、変換後のプログラム実行環境を圧迫してしまう問題が発生する。換言すれば、メモリの使用量が増大することになる。   In this way, in the conventional conversion process, temporary variables are assigned to the execution results of all the function expressions. Therefore, if there is a PROGN function, an extra temporary variable is generated, and the converted program execution environment is There is a problem of pressure. In other words, the amount of memory used increases.

また、上記図9、図10の例では、以下の問題も発生することになる。
まず、上記関数型制御言語(FCL)では、選択構造で条件式が不成立時の選択肢(ELSE節やOTHERW節)を省略することが可能である。
Further, in the examples of FIGS. 9 and 10, the following problems also occur.
First, in the functional control language (FCL), it is possible to omit options (ELSE clause and OTHERW clause) when the conditional expression is not satisfied in the selection structure.

すなわち、例えばif文は一般的に下記のように記述される。
if(条件式(条件節))
then節
else
else節
図9には、選択構造のELSE節がない例を示している。尚、勿論、ELSE節だけでなく上記else自体も無いが、これは言うまでもないことである。ELSE節がない場合、従来の変換処理では、何も変換されず、図10に示すように、最後の閉じ括弧“}”の後には何もない。尚、図では、何もないことを斜線で示している。何も変換されないため、当然、仮変数も割り当てられない。
That is, for example, an if statement is generally described as follows.
if (conditional expression (conditional clause))
then clause else
else clause FIG. 9 shows an example in which there is no ELSE clause of the selection structure. Of course, there is no ELSE clause as well as the above-mentioned else itself, but it goes without saying. When there is no ELSE clause, nothing is converted in the conventional conversion process, and there is nothing after the last closing bracket “}” as shown in FIG. In the figure, nothing is indicated by hatching. Of course, no temporary variable is assigned because nothing is converted.

尚、上記if文に関して、上記条件節以外の部分を、実行節と呼ぶものとする。つまり、上記の例では、実行節にはthen節やelse節等が含まれていることになる。
FCLの場合、条件不成立時の選択肢を省略したとき、条件不成立時は実行結果=0となる。
Regarding the above if statement, the part other than the conditional clause is called an execution clause. That is, in the above example, the execution clause includes the “then” clause, the “else” clause, and the like.
In the case of FCL, if the option when the condition is not satisfied is omitted, the execution result = 0 when the condition is not satisfied.

これに対して、汎用の手続型言語(たとえばC言語やPASCALなど)で図10のようにELSE節がないプログラム文を実行すると、実行結果が不定になるという問題が発生する。   On the other hand, when a program statement having no ELSE clause as shown in FIG. 10 is executed in a general-purpose procedural language (for example, C language, PASCAL, etc.), there arises a problem that the execution result becomes indefinite.

本発明の課題は、関数型言語を手続型言語に変換する言語変換装置において、PROGN関数を含む選択構造を含むプログラム文の変換の際に、実質的に無用となる仮変数の生成・割り当てが行われないようにできる言語変換装置などを提供することである。   An object of the present invention is to generate and assign temporary variables that are substantially useless when converting a program statement including a selection structure including a PROGN function in a language conversion device that converts a functional language into a procedural language. It is to provide a language conversion device that can be prevented from being performed.

本発明の言語変換装置は、関数型言語で記述されたプログラムを手続型言語に変換する言語変換装置であって、前記プログラムの変換を行う変換手段であって、該変換に伴って関数式に対しては任意の仮変数を生成して割当てる変換手段と有し、前記変換手段は、前記プログラムにおいて選択構造またはループ構造の条件節に複数の関数式が記述されている場合、最後の関数式に対してのみ前記仮変数の割当てを行うことを特徴とする。   The language conversion device according to the present invention is a language conversion device that converts a program written in a functional language into a procedural language, and is a conversion means for converting the program, which is converted into a functional expression along with the conversion. Conversion means for generating and assigning an arbitrary temporary variable, and the conversion means is the last function expression when a plurality of function expressions are described in the conditional clause of the selection structure or loop structure in the program. The temporary variable is assigned only to.

本発明の言語変換装置などによれば、関数型言語を手続型言語に変換する言語変換装置において、PROGN関数を含む選択構造を含むプログラム文の変換の際に、実質的に無用となる仮変数の生成・割り当てが行われないようにできる。あるいは、変換元のプログラム文にELSE節がない場合であっても、変換したプログラム実行結果が不定になるという問題を回避できる。   According to the language conversion device or the like of the present invention, in the language conversion device that converts a functional language into a procedural language, a temporary variable that is substantially useless when converting a program sentence including a selection structure including a PROGN function. Can be prevented from being generated or assigned. Alternatively, the problem that the converted program execution result becomes indefinite can be avoided even if the conversion source program statement has no ELSE clause.

(a)は言語変換装置の機能ブロック図、(b)はその概略フロー図である。(A) is a functional block diagram of a language converter, (b) is the schematic flowchart. 図9のプログラム例に応じた配列を示す図である。It is a figure which shows the arrangement | sequence according to the example program of FIG. 図2の配列に応じた二次元構造(ツリー)を示す図である。It is a figure which shows the two-dimensional structure (tree) according to the arrangement | sequence of FIG. 変換部の処理フローチャート図である。It is a process flowchart figure of a conversion part. 図9のプログラム例に応じた本手法による変換結果を示す図である。It is a figure which shows the conversion result by this method according to the example of a program of FIG. PLC用言語について説明する為の図である。It is a figure for demonstrating the language for PLC. 関数型制御言語の基本構造の一例を示す図である。It is a figure which shows an example of the basic structure of a functional control language. 関数型制御言語の二次元機能構造の一例を示す。An example of a two-dimensional functional structure of a functional control language is shown. PROGN関数を用いた選択構造文の一例を示す図である。It is a figure which shows an example of the selection structure sentence using a PROGN function. 図9のプログラム文を従来手法によって変換した結果を示す図である。It is a figure which shows the result of having converted the program sentence of FIG. 9 by the conventional method.

以下、図面を参照して、本発明の実施の形態について説明する。
図1(a)は、本例の言語変換装置の機能ブロック図である。
本例の言語変換装置10は、関数型言語で記述されたプログラムを、関数型言語処理に不向きな演算処理装置において実行可能な形に変換する言語変換装置であり、特に、関数型言語で記述されたプログラムを手続型言語(C言語やPASCALなど)に変換する言語変換装置である。
Embodiments of the present invention will be described below with reference to the drawings.
FIG. 1A is a functional block diagram of the language conversion apparatus of this example.
The language conversion device 10 of this example is a language conversion device that converts a program written in a functional language into a form that can be executed by an arithmetic processing device unsuitable for functional language processing. This is a language conversion device that converts the program into a procedural language (such as C language or PASCAL).

図1(a)に示す例の言語変換装置10は、関数型言語(FCL)格納部11、二次元構造(ツリー)変換部12、二次元構造格納部13、変換部14、手続型言語格納部15等を有する。   The language conversion device 10 shown in FIG. 1A includes a functional language (FCL) storage unit 11, a two-dimensional structure (tree) conversion unit 12, a two-dimensional structure storage unit 13, a conversion unit 14, and a procedural language storage. Part 15 and the like.

関数型言語(FCL)格納部11には、変換対象となるFCLプログラム文を格納する。ここでは、このプログラムの格納形式は、上記特許文献1,2,3、4,5等と同様、例えば後述する図2の例のような配列とする。つまり、プログラムの各関数(命令)や各オペランド(変数等)を、配列の各要素として格納している。尚、関数型言語(FCL)格納部11自体は、上記従来の特許文献4、5の関数型言語(FCL)格納装置と同様であって構わない。   The functional language (FCL) storage unit 11 stores an FCL program sentence to be converted. Here, the storage format of this program is, for example, an arrangement as shown in the example of FIG. That is, each function (instruction) and each operand (variable etc.) of the program are stored as each element of the array. The functional language (FCL) storage unit 11 itself may be the same as the conventional functional language (FCL) storage device disclosed in Patent Documents 4 and 5.

ここで本実施例の説明では、変換対象となるFCLプログラム文が、上記図9に示すものである場合を例にして説明するものとする。そして、図2に、図9のプログラム例に応じた配列を示す。つまり、本例の場合、関数型言語(FCL)格納部11には、図2に示す配列の形式で、変換対象となるFCLプログラム文が、格納されていることになる。   Here, in the description of the present embodiment, the case where the FCL program sentence to be converted is the one shown in FIG. 9 will be described as an example. FIG. 2 shows an arrangement corresponding to the program example of FIG. That is, in this example, the functional language (FCL) storage unit 11 stores the FCL program sentence to be converted in the array format shown in FIG.

この配列の各要素については、特許文献4、5等と同様であり、関数は開き括弧“(”と共に配列の1要素として格納され、オペランド(変数など)や関数終了子(閉じ括弧“)”)は、そのまま配列の1要素として格納される。よって、例えば、IFやPROGN等の関数(命令)は、図示のように“(IF”や“(PROGN”等の形でそれぞれ配列の1要素として格納される。   Each element of this array is the same as in Patent Documents 4, 5, etc., and the function is stored as one element of the array together with an opening parenthesis “(”, and an operand (such as a variable) or a function terminator (closing parenthesis “)”. ) Is stored as it is as one element of the array. Thus, for example, functions (instructions) such as IF and PROGN are stored as one element of the array in the form of “(IF” and “(PROGN”) as shown in the figure.

二次元構造(ツリー)変換部12は、関数型言語(FCL)格納装置11に記憶された配列の内容を、その配列の各要素を節(以下、「ノード」という)としてツリー構造化する。二次元構造(ツリー)変換部12も、特許文献4、5等に開示されている既存機能であるので、ここでは簡単に説明するならば、配列の各要素を順次取得し、該各要素に応じたノードと該ノード間のリンクから成るツリー構造を生成するものである。二次元構造(ツリー)変換部12によって、例えば図2の例の配列の場合、図3に示す二次元構造(ツリー)が生成されることになる。生成された二次元構造(ツリー)データは、二次元構造格納部13に格納される。   The two-dimensional structure (tree) conversion unit 12 converts the contents of the array stored in the functional language (FCL) storage device 11 into a tree structure with each element of the array as a clause (hereinafter referred to as “node”). Since the two-dimensional structure (tree) conversion unit 12 is also an existing function disclosed in Patent Documents 4 and 5 and the like, here, in a simple description, each element of the array is sequentially obtained, A tree structure composed of a corresponding node and a link between the nodes is generated. For example, in the case of the arrangement of FIG. 2, the two-dimensional structure (tree) shown in FIG. 3 is generated by the two-dimensional structure (tree) conversion unit 12. The generated two-dimensional structure (tree) data is stored in the two-dimensional structure storage unit 13.

尚、図3にはツリー構造について概略的に示すが、その各ノードのデータ構造は、例えば特許文献4の図3や、特許文献5の図3、図4、図14等のように“子供ノードへのポインタ”や“次のノードへのポインタ”等の他ノードへのリンクを示すポインタを有するものである。但し、この例に限らない。図3では、この様なポインタ等に基づく各ノード間の親子関係を、図示の直線で示してある。例えば、図3の左下に示す“b”ノードと“a”ノードの親ノードは、何れも、“(+”ノードである。換言すれば、“(+”ノードの子ノードは、“b”ノードと“a”ノードであると言える。これは、ノードが上記特許文献4の図3のデータ構造の場合では、“(+”ノードにおける“子供ノードへのポインタ”が“b”ノードを指しており、“b”ノードにおける“次のノードへのポインタ”が“a”ノードを指していることになる。   FIG. 3 schematically shows a tree structure. The data structure of each node is “child” as shown in FIG. 3 of Patent Document 4, FIG. 3, FIG. 14, FIG. It has pointers indicating links to other nodes such as “pointer to node” and “pointer to next node”. However, the present invention is not limited to this example. In FIG. 3, the parent-child relationship between the nodes based on such pointers and the like is shown by the illustrated straight line. For example, the parent nodes of the “b” node and the “a” node shown in the lower left of FIG. 3 are both “(+” nodes. In other words, the child node of the “(+” node is “b”. It can be said that the node is an “a” node, and in the case where the node is the data structure of FIG. 3 of the above-mentioned Patent Document 4, the “pointer to the child node” in the “(+” node) points to the “b” node. Thus, the “pointer to the next node” in the “b” node indicates the “a” node.

二次元構造(ツリー)の各ノードのデータ構造は、上記のように特許文献4、5等とほぼ同様であってよいが、本例の場合にはインスタンス名(本例では仮変数とする)は無い。また、本例では、特許文献4、5における「関数名−インスタンス名作成部」が無く、ツリー構造においてインスタンス名(仮変数名)が割当てられることはない。特許文献4の場合、「関数名−インスタンス名作成部」によって、リーフ以外の全てのノードにインスタンス名(仮変数名)を付与していた為、上記図10の例のように、不必要な仮変数INST_5”が付与されてしまっていた。   As described above, the data structure of each node of the two-dimensional structure (tree) may be almost the same as that of Patent Documents 4 and 5 and the like, but in the case of this example, the instance name (in this example, a temporary variable) There is no. In this example, there is no “function name-instance name creation unit” in Patent Documents 4 and 5, and no instance name (temporary variable name) is assigned in the tree structure. In the case of Patent Document 4, the instance name (temporary variable name) is assigned to all the nodes other than the leaf by the “function name-instance name creation unit”, so that it is unnecessary as in the example of FIG. The temporary variable INST — 5 ”has been assigned.

これに対して、本手法では、上記のようにリーフ以外の全てのノードに一律にインスタンス名(仮変数)を付与する代わりに、変換部14において後述する処理によって仮変数を付与する。これについては後述する。尚、上記リーフとは、特許文献4、5に記載のように、ツリー構造の末端部のノードすなわち子ノードを持たないノードである。   On the other hand, in this method, instead of uniformly assigning instance names (temporary variables) to all nodes other than the leaves as described above, the conversion unit 14 assigns temporary variables by the process described later. This will be described later. The leaf is a node at the end of the tree structure, that is, a node having no child nodes, as described in Patent Documents 4 and 5.

また、尚、本例においても、ある関数は、別の関数や変数を引数(子ノード)とすることができる。例えば、図3に示す例では、例えば図示の“(+”ノードの親ノードとしての“(:=”ノードは、その引数(子ノード)として、当該“(+”ノードと図示の“c”ノードを有する。尚、“:=”は代入の関数であり、“+”は加算の関数であり、cはオペランド(変数など)である。   Also in this example, a certain function can use another function or variable as an argument (child node). For example, in the example shown in FIG. 3, for example, the “(: =” node as the parent node of the illustrated “(+” node is the “(+” node ”and the illustrated“ c ”as its argument (child node). Note that “: =” is an assignment function, “+” is an addition function, and c is an operand (such as a variable).

尚、図3のような二次元構造(ツリー構造)を表現するのに、XML(Extensible Markup Language)で記述されたテキストによるデータ構造を使用することができる。XMLの場合、ツリー構造データの追加/削除/検索などの操作を容易に行なうことができる。   Note that a text data structure described in XML (Extensible Markup Language) can be used to express a two-dimensional structure (tree structure) as shown in FIG. In the case of XML, operations such as addition / deletion / retrieval of tree structure data can be easily performed.

上記変換部14の処理について、以下、説明する。
まず、図1(b)には、変換部14の概略処理フローを示す。
変換部14は、上記二次元構造格納部13に格納される二次元構造(ツリー)データに基づいて、上記変換対象となるFCLプログラム文を手続型言語のプログラムに変換する。この処理は、概略的には、図1(b)に示すように、ツリー構造に従ってFCLプログラムを順次変換するなかで、if文があった場合には(ステップS1,YES)、まず、このif文に係わる条件節の関数式の変換を行う(ステップS2)。そして、この条件節にPROGNがあった場合には、このPROGNに係わる複数の関数式のなかで1つの関数式だけを仮変数の割り当て対象に決定し(ステップS3)、決定した関数式に対して任意の仮変数を割当てる(ステップS4)。そして、この割当てた仮変数を用いて条件分岐部分(then節など)を作成する(ステップS5)。
The process of the conversion unit 14 will be described below.
First, FIG. 1B shows a schematic processing flow of the conversion unit 14.
The conversion unit 14 converts the FCL program sentence to be converted into a procedural language program based on the two-dimensional structure (tree) data stored in the two-dimensional structure storage unit 13. As shown in FIG. 1 (b), this process is roughly executed when an if statement is found in the sequential conversion of the FCL program according to the tree structure (step S1, YES). The function expression of the conditional clause related to the sentence is converted (step S2). If there is PROGN in this conditional clause, only one function expression is determined as a provisional variable assignment target among the plurality of function expressions related to PROGN (step S3), and the determined function expression is determined. An arbitrary temporary variable is assigned (step S4). Then, using this assigned temporary variable, a conditional branch part (then clause etc.) is created (step S5).

上記変換処理によって作成された手続型言語のプログラムは、手続型言語格納部15に格納される。
尚、図1(a)、(b)に示す構成、処理は、一例を示すものであり、この例に限らない。例えば、変換部14は、二次元構造格納部13ではなく関数型言語(FCL)格納部11に格納される上記配列を用いて、上記プログラム変換処理を行うようにしてもよい。
The procedural language program created by the conversion process is stored in the procedural language storage unit 15.
Note that the configurations and processes shown in FIGS. 1A and 1B are only examples, and are not limited to these examples. For example, the conversion unit 14 may perform the program conversion process using the array stored in the functional language (FCL) storage unit 11 instead of the two-dimensional structure storage unit 13.

ここで、上記ステップS3の処理は、PROGNに係わる複数の関数式の変換結果のなかで、最後の関数式のみに対して、仮変数を割当てる処理である。上記の通り、PROGN関数の戻り値は、最後に評価した式の結果となるからである。そして、if文に係わりPROGN関数がある場合には、この戻り値が条件分岐判定に用いられることになる。   Here, the process of step S3 is a process of assigning a temporary variable only to the last function expression among the conversion results of a plurality of function expressions related to PROGN. As described above, the return value of the PROGN function is the result of the last evaluated expression. When there is a PROGN function related to the if statement, this return value is used for conditional branch determination.

従来では、例えば上記「関数名−インスタンス名作成部」によって全ての関数に対して仮変数が付与されるので、PROGNに係わる複数の関数式に対しても全て仮変数が付与されることになった。これに対して、本手法では上記のように、PROGNに係わる全ての関数式の変換結果に仮変数を割り当てるのではなく、条件判定に必要な関数式にのみ仮変数を割り当てるようにすることで、余分な仮変数を作成することもなく効率的な実行が可能である。この様な仮変数の割り当て処理の具体例は、後にフローチャート図を参照して説明する。   Conventionally, temporary variables are assigned to all functions by, for example, the above-mentioned “function name-instance name creation unit”, and therefore all temporary variables are also assigned to a plurality of function expressions related to PROGN. It was. On the other hand, in this method, as described above, instead of assigning temporary variables to the conversion results of all the function expressions related to PROGN, the temporary variables are assigned only to the function expressions necessary for condition determination. Efficient execution is possible without creating extra dummy variables. A specific example of such a temporary variable assignment process will be described later with reference to a flowchart.

例えば、後述する具体例のように、本手法では上記図9のFCLプログラム文を、後述する図5の手続型言語プログラム文に変換するので、図5に示すようにPROGNに係わる複数の関数式の中で最後の関数式だけに仮変数を割り当てるので、仮変数は3個(INST6、INST7、INST8)で済み、変換後のプログラムのメモリ使用量を削減でき、メモリ使用量の圧迫を回避できるようになる。   For example, as shown in a specific example described later, in this method, the FCL program statement of FIG. 9 is converted into a procedural language program statement of FIG. 5 described later, so that a plurality of function expressions related to PROGN as shown in FIG. Since a temporary variable is assigned only to the last function expression in the list, only three temporary variables (INST6, INST7, INST8) are needed, and the memory usage of the program after conversion can be reduced and the memory usage pressure can be avoided. It becomes like this.

尚、条件節内部にさらに選択構造がある場合、つまり例えば所謂“if文の入れ子”となっている場合等には、選択した後に実行される最後の関数式の実行結果が、選択構造の実行結果として条件判定に用いられる。そのため、それぞれの選択肢ごとに、最後の式の変換結果に対してのみ仮変数に割り当てる。   If there is a further selection structure inside the conditional clause, that is, if, for example, a so-called “if statement is nested”, the execution result of the last function expression executed after selection is the execution of the selection structure. As a result, it is used for condition determination. Therefore, for each option, only the conversion result of the last expression is assigned to a temporary variable.

あるいは、変換対象となるFCLプログラム文に、条件式が不成立時の選択肢(ELSE節やOTHERW節)がない場合であっても、当該選択肢を追加して実行結果を割り当てる。本手法では、例えば図9のPLCプログラム文を手続型言語に変換する際に、図5の最後に示すelse文を自動的に追加する処理を行う。すなわち、条件式不成立時の選択肢を自動的に追加して仮変数=0とする処理を行う。これについて詳しくは後述するが、これによって、変換後のプログラムの実行結果が不定になる事態を避けられる。   Alternatively, even if there is no option (ELSE clause or OTHERW clause) when the conditional expression is not satisfied in the FCL program statement to be converted, the option is added and the execution result is assigned. In this method, for example, when the PLC program sentence of FIG. 9 is converted into a procedural language, a process of automatically adding an else sentence shown at the end of FIG. 5 is performed. That is, a process for automatically setting a provisional variable = 0 is performed by automatically adding an option when the conditional expression is not satisfied. Although this will be described in detail later, this avoids a situation in which the execution result of the converted program becomes indefinite.

上述した本手法の特徴を実現する為の具体的処理例は、図4に示し後に詳細に説明するが、以下、簡単に説明する。尚、以下の説明における“選択構造”は上述したように例えばIF〜THEN〜ELSE〜END_IF等であり、“ループ構造”は例えばWHILE〜DO〜ENDWHIL等である。そして、PROGN関数を使用すると、これらの各構造の条件節に、複数の式を記述することが可能である。   A specific processing example for realizing the above-described feature of the present technique will be described in detail later with reference to FIG. As described above, the “select structure” in the following description is, for example, IF to THEN to ELSE to END_IF, and the “loop structure” is, for example, WHILE to DO to ENDWHIL. When the PROGN function is used, a plurality of expressions can be described in the conditional clauses of these structures.

仮変数の無駄な割当てを避ける為に、例えば下記の(a)、(b)等の操作を行う。
(a)PROGN関数に係わる複数の関数式を手続型命令に変換した後、当該PROGN関数に係わる複数の関数式(変換後)のなかで最後の関数式を検索する。
In order to avoid useless allocation of temporary variables, for example, the following operations (a) and (b) are performed.
(A) After converting a plurality of function expressions related to the PROGN function into procedural instructions, the last function expression is searched among the plurality of function expressions related to the PROGN function (after conversion).

(b)最後の関数式が選択構造やループ構造でなければ、仮変数を生成して当該最後の関数式に割り当てる。例えば、PROGN関数に係わり変換した手続型言語の命令コードの末尾から遡り、最後の関数式と一致する箇所に仮変数を挿入する。   (B) If the last function expression is not a selection structure or a loop structure, a temporary variable is generated and assigned to the last function expression. For example, a temporary variable is inserted at a location that coincides with the last function expression, going back from the end of the instruction code of the procedural language converted in connection with the PROGN function.

(c)一方、最後の関数式が選択構造やループ構造の場合、それぞれの実行節で割り当てられた仮変数をそのまま使用し、新たに仮変数を生成することはしない。
上記操作により、条件節が複数の関数式からなるときは、最後の関数式に割り当てる仮変数しか生成しない。
(C) On the other hand, when the last function expression is a selection structure or a loop structure, the temporary variable assigned in each execution clause is used as it is, and a new temporary variable is not generated.
By the above operation, when the conditional clause consists of a plurality of function expressions, only the temporary variable assigned to the last function expression is generated.

(d)また、選択構造の実行節に条件不成立時の選択肢がない場合、つまり例えばThen節はあるがelse節が無い場合、条件不成立時の選択肢を追加して、仮変数に0を代入する実行節を追加する。   (D) Also, if there is no option when the condition is not satisfied in the execution clause of the selection structure, that is, for example, when there is a Then clause but there is no else clause, an option when the condition is not satisfied is added and 0 is assigned to the temporary variable. Add an execution clause.

上記操作により、条件不成立時の選択肢がない場合でも、変換結果のプログラムの実行結果が不定にならなくなる。
上記(a)〜(d)について、以下、更に説明する。
With the above operation, even if there is no option when the condition is not satisfied, the execution result of the conversion result program does not become indefinite.
The above (a) to (d) will be further described below.

まず、上記の様に、PROGN関数等によって、選択構造の条件節に複数の関数式を使用することができる。また、一般的に、条件節内部にさらに選択構造を使用することができる。選択肢それぞれに仮変数を挿入する必要があるが、条件節に使用された際に全ての選択肢を検索するのは手間が多い。本手法では、選択構造の手続型言語への変換時に、各選択肢の最後の式に常に仮変数を挿入することにする。   First, as described above, a plurality of function expressions can be used in the conditional clause of the selected structure by the PROGN function or the like. In general, further selection structures can be used inside conditional clauses. It is necessary to insert a temporary variable for each option, but it is troublesome to search all options when used in a conditional clause. In this method, a temporary variable is always inserted into the last expression of each option when the selection structure is converted to a procedural language.

選択構造では条件式が不成立時の選択肢(ELSE文やOTHERW文)がない場合がある。本手法では、選択構造の手続型言語への変換時にELSE文やOTHERW文の有無をチェックし、これらがない場合には自動的に”else”や”default:”を追加し、更に“(仮変数) := 0”を追加する。   In the selection structure, there may be no option (ELSE statement or OTHERW statement) when the conditional expression is not satisfied. This method checks the existence of ELSE and OTHERW statements when converting the selected structure to a procedural language. If there is no ELSE or OTHERW statement, it automatically adds "else" and "default:" Variable): = 0 ”is added.

図4のフローチャート図について上記図9の例に応じた上記図3のツリー構造を参照して説明する。
図4は、「ノード処理」のフローチャート図である。
4 will be described with reference to the tree structure of FIG. 3 corresponding to the example of FIG.
FIG. 4 is a flowchart of the “node processing”.

図4の処理は、基本的に、処理対象ノードを基準にして処理を実行する。処理対象ノードは、最初はツリー構造の先頭となり、図3の例では“(IF”ノードとなる。但し、図4の処理中、ステップS13、S16等の処理は、図4の処理自体(「ノード処理」のプログラム)を再帰的に呼び出す処理である。その際、基本的には処理対象ノードの子ノードを示す情報をパラメータとして渡すことで、呼び出される「ノード処理」における処理対象ノードは当該子ノードということになる。   The processing in FIG. 4 is basically executed based on the processing target node. The processing target node is initially at the head of the tree structure, and in the example of FIG. 3, is a “(IF” node. However, during the processing of FIG. 4, the processing of steps S13, S16, etc. is the processing itself of FIG. Node processing "program) is called recursively.At this time, basically, by passing information indicating the child node of the processing target node as a parameter, the processing target node in the called" node processing " It will be a child node.

図4の処理は、処理対象ノードの種別によって、概略的には4つの処理に分岐する。つまり、処理対象ノードがif文であるか(ステップS11,YES)、PROGN文であるか(ステップS31,YES)、これら以外の任意の関数であるか(ステップS41,YES)、変数(オペランド)であるか(ステップS41,NO)によって、処理が4つに分岐する。   The process of FIG. 4 roughly branches to four processes depending on the type of the processing target node. That is, whether the processing target node is an if statement (step S11, YES), a PROGN statement (step S31, YES), an arbitrary function other than these (step S41, YES), a variable (operand) (Step S41, NO), the process branches into four.

上記の通り最初は処理対象ノードが“(IF”であり、すなわちif文であるので、ステップS11の判定がYESとなり、ステップS12〜S20の処理を実行することになる。尚、この処理は、ネスト1の「ノード処理」であるものとする。そして、ネスト1の「ノード処理」から呼び出す「ノード処理」は、ネスト2の「ノード処理」であるものとする。同様にして、ネスト2の「ノード処理」から呼び出す「ノード処理」は、ネスト3の「ノード処理」であるものとする。このようにして、「ノード処理」を再帰的に呼び出すことで、ネストが1段ずつ深くなっていく。   As described above, since the processing target node is “(IF”), that is, an “if” statement, the determination in step S11 is YES, and the processing in steps S12 to S20 is executed. It is assumed that “node processing” is nest 1. “node processing” called from “node processing” of nest 1 is “node processing” of nest 2. Similarly, “Node processing” called from “node processing” is assumed to be “node processing” of nest 3. In this way, by calling “node processing” recursively, the nest is deepened by one level. Go.

尚、上記ネスト1、ネスト2等における‘1’や‘2’は、ネストの深さを示すものであり、数値が大きいほどネストが深いことになる。
また、尚、以下の説明における子ノードの取り出し(子ノードの認識)は、例えば各ノードに含まれる上述した“子供ノードへのポインタ”や“次のノードへのポインタ”を参照することで実現できる。
Note that “1” and “2” in the nest 1, nest 2, etc. indicate the depth of the nest, and the larger the numerical value, the deeper the nest.
In addition, child node extraction (child node recognition) in the following description is realized by referring to the above-mentioned “pointer to child node” and “pointer to next node” included in each node, for example. it can.

まず、if文における条件節を取り出し(ステップS12)、この条件節に係わる「ノード処理」を実行させる(ステップS13)。尚、ステップS12の処理は、例えば、“処理対象ノードである(IF”ノードの子ノードの一方を、認識するものである。よって、図3例では、“(IF”ノードの一方の子ノードである“(=”ノードが認識されて、ステップS13ではこの“(=”ノードをパラメータとして「ノード処理」を呼び出す。   First, a conditional clause in the “if” statement is extracted (step S12), and “node processing” related to this conditional clause is executed (step S13). The process in step S12 is, for example, for recognizing one of the child nodes of the “processing target node (IF” node. Therefore, in the example of FIG. “(=” Node is recognized, and in step S13, “node processing” is called using the “(=” node as a parameter.

これによって、呼び出される「ノード処理」では、“(=”ノードが処理対象ノードとなる。つまり、処理対象ノードの種別は関数ということになる。よって、当該“(=”ノードの「ノード処理」(ネスト2)においては、まず、ステップS11、S31がNOでS41がYESとなり、これより、この“(=”の子ノード(引数)を順次取り出して(ステップS42)、これら子ノード毎に「ノード処理」を呼び出す(ステップS43)処理を、全ての子ノードについて実行するまで繰り返す。   As a result, in the “node process” to be called, the “(=” node becomes the process target node. In other words, the type of the process target node is a function. Therefore, the “node process” of the “(=” node. In (Nest 2), first, Steps S11 and S31 are NO and S41 is YES. From this, child nodes (arguments) of “(=” are sequentially taken out (Step S42). The process of calling “node process” (step S43) is repeated until it is executed for all child nodes.

ここで、“(=”の子ノードの1つは、“(PROGN”ノードであるので、ステップS43においてPROGN文の「ノード処理」を実行させる場合があることになる。これは、階層的にはネスト3の処理と言える。   Here, since one of the child nodes of “(=” is a “(PROGN” node, the “node processing” of the PROGN statement may be executed in step S43. Can be said to be processing of nest 3.

よって、当該“(PROGN”ノードのノード処理(ネスト3)が開始されると、まず、ステップS11がNOでステップS31がYESになり、この“(PROGN”ノードの子ノード(引数)を順次取り出して(ステップS32)、これら子ノード毎に「ノード処理」を呼び出す(ステップS33)処理を、全ての子ノードについて実行するまで繰り返す。   Therefore, when the node processing (nesting 3) of the “(PROGN” node is started, first, step S11 is NO and step S31 is YES, and the child nodes (arguments) of this “(PROGN” node are sequentially extracted. (Step S32), the "node process" is called for each of these child nodes (step S33) until the process is executed for all the child nodes.

“(PROGN”ノードには複数の子ノードがあり、図3の例では最初の子ノードは“(:=”ノードであるので、これに応じてステップS33で呼び出される「ノード処理」では、処理対象ノードが“(:=”ノードとなり、“(:=”(代入関数)の処理となる。これは、階層的には、ネスト4の処理と言える。   The “(PROGN” node has a plurality of child nodes, and in the example of FIG. 3, the first child node is a “(: =” node. Accordingly, in “node processing” called in step S33 according to this, processing is performed. The target node becomes a “(: =” node, and the processing is “(: =” (assignment function). This can be said to be processing of nest 4 hierarchically.

“(:=”ノードの「ノード処理」(ネスト4)では、ステップS11、S31がNOとなりステップS41がYESとなる。これより、この“(:=”の子ノード(引数)を順次取り出して(ステップS42)、これら子ノード毎に「ノード処理」を呼び出す(ステップS43)処理を、全ての子ノードについて実行するまで繰り返す。   In the “node processing” (nesting 4) of the “(: =” node, Steps S11 and S31 are NO and Step S41 is YES, so that the child nodes (arguments) of this “(: =” are sequentially extracted. (Step S42) The "node process" is called for each child node (Step S43), and the process is repeated until it is executed for all the child nodes.

図3の例では“(:=”の最初の子ノードは“(+”ノードであるので、これに応じてステップS43で呼び出される「ノード処理」は、“(+”(加算関数)の処理となる。これは、階層的には、ネスト5の処理と言える。   In the example of FIG. 3, since the first child node of “(: =” is a “(+” node), the “node processing” called in step S43 according to this is the processing of “(+” (addition function). This can be said to be processing of nest 5 hierarchically.

“(+”ノードの「ノード処理」(ネスト5)では、ステップS11、S31がNOでS41がYESとなり、これより、この“(+”ノードの子ノード(引数)を順次取り出して(ステップS42)、これら子ノード毎に「ノード処理」を呼び出す(ステップS43)処理を、全ての子ノードについて実行するまで繰り返す。   In the “node processing” (nesting 5) of the “(+” node, steps S11 and S31 are NO and S41 is YES. From this, child nodes (arguments) of this “(+” node are sequentially extracted (step S42). ), Calling “node processing” for each child node (step S43) until the processing is executed for all child nodes.

図3の例では“(+”ノードの最初の子ノードは“b”ノードであるので、これに応じてステップS43で呼び出される「ノード処理」は、“b”(変数)の処理となる。これは、階層的には、ネスト6の「ノード処理」と言える。   In the example of FIG. 3, since the first child node of the “(+” node is a “b” node, the “node processing” called in step S43 according to this is the processing of “b” (variable). This can be said to be “node processing” of nest 6 hierarchically.

“b”ノードの「ノード処理」(ネスト6)では、ステップS11、S31、S41が全てNOとなり、これより、変数処理(ステップS46)を実行する。この変数処理は、単に、処理対象ノード“b”を、構文リストに出力するものである。構文リストは、変換結果の出力先ファイル等であり、本処理によって様々な出力が成されることで、最終的には例えば図5に示す変換結果を有する構文リスト生成されることになる。   In the “node processing” (nesting 6) of the “b” node, steps S11, S31, and S41 are all NO, and the variable processing (step S46) is executed. This variable processing simply outputs the processing target node “b” to the syntax list. The syntax list is a conversion result output destination file or the like, and various outputs are generated by this processing, so that a syntax list having the conversion result shown in FIG. 5 is finally generated.

尚、上記手続型言語格納部15の一例が、上記構文リストであると見做しても構わない。
ステップS46の処理を実行したら、“b”ノードの「ノード処理」(ネスト6)は終了し、これより呼出元の処理(“(+”ノードの「ノード処理」;ネスト5)に戻ることになる。これより、“(+”ノードの「ノード処理」におけるステップS43の処理が終了することになり、ステップS44で全ての子ノードについて処理実施したか否かを判定する。ここでは、“(+”ノードに関して、未処理の子ノード(“a”ノード)が残っているので、ステップS42に戻る。
Note that an example of the procedural language storage unit 15 may be regarded as the syntax list.
When the processing of step S46 is executed, the “node processing” (nesting 6) of the “b” node ends, and the processing returns to the calling source processing (“(+) node“ node processing ”; nest 5). Thus, the process of step S43 in the “node process” of the “(+” node is completed, and it is determined whether or not the process has been performed for all the child nodes in step S44. Since there is an unprocessed child node (“a” node) regarding the “+” node, the process returns to step S42.

そして、ステップS42において今度は“a”ノードを取り出し、これより、これに応じてステップS43で呼び出される「ノード処理」は、“a”(変数)の処理となる。
“a”ノードの「ノード処理」では、ステップS11、S31、S41が全てNOとなり、これより、変数処理(ステップS46)を実行する。つまり、処理対象ノード“a”を、構文リストに出力する。これより、この段階では、“b”と“a”のみが、構文リストに記述されている状態となっている。そして、呼出元の処理(“(+”ノードの「ノード処理」)に戻ると、今度はステップS44の判定はNOとなるので、ステップS45の処理を実行する。
Then, in step S42, the “a” node is extracted, and the “node processing” called in step S43 according to this is the processing of “a” (variable).
In the “node processing” of the “a” node, steps S11, S31, and S41 are all NO, and thus variable processing (step S46) is executed. That is, the processing target node “a” is output to the syntax list. Thus, at this stage, only “b” and “a” are described in the syntax list. Then, when returning to the caller process (“(+” node “node process”)), since the determination in step S44 is NO, the process in step S45 is executed.

ステップS45では、処理対象ノードの関数を構文リスト出力する。ここでは、関数“+”を構文リスト出力することになる。ここで、対象となる関数が、+(加算)、−(減算)、*(乗算)、/(除算)の四則演算である場合には、出力先は、この関数の子ノードに係わる上記構文リストへの出力結果の間とする。つまり、上記の例では“b”と“a”が出力されているので、この間に“+”を出力する。これによって、構文リストには“b+a”が記述された状態となる。   In step S45, the function of the processing target node is output as a syntax list. Here, the function “+” is output as a syntax list. Here, when the target function is the four arithmetic operations of + (addition),-(subtraction), * (multiplication), and / (division), the output destination is the above-mentioned syntax related to the child node of this function. Between the output results to the list. That is, since “b” and “a” are output in the above example, “+” is output during this time. As a result, “b + a” is described in the syntax list.

ステップS45では、更に、上記記述“b+a”に対して仮変数を割当てる処理を実行する。仮変数は、予め決められたルールに従って生成すればよく、ここでは仮変数=「“INST_”+任意の数値」を生成ルールとする。任意の数値は、重複しなければ何でもよく、ここでは‘6’であるものとし、仮変数=“INST_6”が割当てられるものとする。この割当ては、“:=”(代入)を意味し、従ってこの処理によって構文リストには下記の記述がある状態となる。すなわち、図5の構文リストにおける1行目のみが記述された状態となる。
INST_6 ;= b+a;
In step S45, a process of assigning a temporary variable to the description “b + a” is further executed. The temporary variable may be generated according to a predetermined rule. Here, the temporary variable = ““ INST _ ”+ arbitrary numerical value” is set as the generation rule. Arbitrary numerical values may be anything as long as they do not overlap. Here, it is assumed that “6” is assumed, and temporary variable = “INST — 6” is assigned. This assignment means “: =” (substitution), and thus, the processing makes the following description in the syntax list. That is, only the first line in the syntax list of FIG. 5 is described.
INST — 6; = b + a;

上記ステップS45を実行完了したら、“(+”ノードの「ノード処理」(ネスト5)が終了することになり、これによって、呼出元である上記“(:=”ノードの「ノード処理」(ネスト4)に戻ることになる。これより、“(:=”ノードの「ノード処理」(ネスト4)におけるステップS43の処理が終了することになり、続いてステップS44の処理を実行すると、“(:=”ノードには未処理の子ノード“c”があるので判定はNOとなり、ステップS42に戻る。   When the execution of the step S45 is completed, the “node processing” (nesting 5) of the “(+” node is completed, and thereby the “node processing” (nesting of the “(: =” node that is the call source). Thus, the process of step S43 in the “node processing” (nesting 4) of the “(: =” node is completed, and then the process of step S44 is executed. : = ”Since there is an unprocessed child node“ c ”in the node, the determination is no and the process returns to step S42.

そして、ステップS42において今度は子ノード“c”を取り出し、これより、これに応じてステップS43で呼び出される「ノード処理」は、“c”(変数)の処理(ネスト5)となる。   In step S42, the child node “c” is extracted, and the “node process” called in step S43 according to this is the process of “c” (variable) (nesting 5).

“c”ノードの「ノード処理」では、ステップS11、S31、S41が全てNOとなり、これより、変数処理(ステップS46)を実行する。つまり、処理対象ノード“c”を、構文リストに出力する。そして、この「ノード処理」が終了することで呼出元の“(:=”ノードの「ノード処理」に戻ると、今度はステップS44の判定はNOとなるので、ステップS45の処理を実行する。   In the “node processing” of the “c” node, steps S11, S31, and S41 are all NO, and thus variable processing (step S46) is executed. That is, the processing target node “c” is output to the syntax list. When the “node processing” is completed and the process returns to the “node processing” of the caller “(: =” node, the determination in step S44 is NO, so the processing in step S45 is executed.

ステップS45では、処理対象ノードの関数を構文リスト出力する。ここでは、関数“:=”を構文リスト出力することになる。ここで、対象となる関数が、“:=”(代入関数)である場合には、上記記述された“c”を代入先とすると共に、代入元は最新の仮変数とする。ここでは既存の最新の仮変数は上記“INST_6”であるので、構文リストには下記の記述が加わることになる。つまり、図5における2行目の記述が生成されることになる。
c:=INST_6
In step S45, the function of the processing target node is output as a syntax list. Here, the function “: =” is output as a syntax list. Here, when the target function is “: =” (assignment function), “c” described above is used as the assignment destination, and the assignment source is the latest temporary variable. Here, since the existing latest temporary variable is “INST — 6”, the following description is added to the syntax list. That is, the description on the second line in FIG. 5 is generated.
c: = INST_6

尚、対象となる関数が、“:=”(代入関数)である場合には、新たな仮変数の割り当ては行わない。この場合には、上記の通り、既存の仮変数を用いるものである。   When the target function is “: =” (assignment function), no new temporary variable is assigned. In this case, as described above, an existing temporary variable is used.

上記ステップS45を実行完了したら、“(:=”ノードの「ノード処理」(ネスト4)が終了することになり、これによって、呼出元である上記“(PROGN”ノードのノード処理(ネスト3)に戻ることになる。これより、上記ステップS33の処理が終了することになり、続いて、“(PROGN”ノードの子ノード全てについて処理実行済みか否かを判定する(ステップS34)。上記一例では、この段階では未処理の子ノードが残っているので判定はNOとなり、ステップS32に戻ることになる。   When the execution of the step S45 is completed, the “node processing” (nesting 4) of the “(: =” node is completed, and thereby the node processing of the calling source “(PROGN” node (nesting 3)) As a result, the process of step S33 ends, and subsequently, it is determined whether or not the process has been executed for all the child nodes of the “(PROGN” node (step S34). At this stage, since there are unprocessed child nodes remaining, the determination is NO, and the process returns to step S32.

そして、上記図3の例では、ステップS33で“(:=”ノードの「ノード処理」(ネスト4)が呼び出され、この「ノード処理」のステップS43で“(−”ノードの「ノード処理」(ネスト5)が呼び出され、この「ノード処理」のステップS43で“d”ノードの「ノード処理」(ネスト6)や“e”ノードの「ノード処理」(ネスト6)が、順次、呼び出されることになる。   In the example of FIG. 3, “node processing” (nesting 4) of “(: =” node is called in step S33, and “node processing” of “(−” node is called in step S43 of this “node processing”. (Nest 5) is called, and "node processing" (nesting 6) of the "d" node and "node processing" (nesting 6) of the "e" node are sequentially called in step S43 of this "node processing". It will be.

これらの処理については、上記変数“b”や“a”や“+”に関する処理と略同様であるので、特に説明しないが、これらの処理によって、「d−e」が生成され、更に仮変数INST_8が割当てられることになる。つまり、図5における3行目の記述(下記の記述)が、生成されることになる。
INST_8 := d−e;
These processes are substantially the same as the processes related to the variables “b”, “a”, and “+”, and thus will not be described in particular. However, these processes generate “d−e”, and further, a temporary variable. INST_8 will be allocated. That is, the description on the third line in FIG. 5 (the following description) is generated.
INST_8: = d-e;

更に、上記“(:=”の「ノード処理」(ネスト4)に戻ることで、そのステップS45の処理によって、上記と同様に代入元は最新の仮変数とすることで、構文リストには下記の記述が加わることになる。つまり、図5における4行目の記述の一部が生成されることになる。
f:=INST_8
Further, by returning to the “node processing” (nesting 4) of “(: =” above, the assignment source is set to the latest temporary variable in the same manner as described above by the processing of step S45, and the syntax list includes In other words, a part of the description on the fourth line in FIG.
f: = INST_8

そして、呼出元である上記“(PROGN”ノードのノード処理(ネスト3)に戻ると、図3の例の場合には今度は上記ステップS34の判定はYESとなるので、ステップS35〜S37の処理を実行する。   Then, when returning to the node processing (nesting 3) of the “(PROGN” node that is the call source, in the case of the example of FIG. 3, the determination in step S34 is now YES, so the processing in steps S35 to S37 is performed. Execute.

ステップS35〜S37の処理は、“(PROGN”ノードの全ての子ノードに関して上記のように構文リスト上に生成された記述(関数式)のなかで、最後に記述された関数式を検索して(ステップS35)、最後に記述された関数式についてのみ仮変数を割当てる(ステップS37)処理である。但し、最後に記述された関数式が、選択構造やループ構造の場合には(ステップS36,YES)、仮変数を割当てる処理(ステップS37の処理)は行わない。最後に記述された関数式が、選択構造やループ構造以外である場合に(ステップS36,NO)、仮変数を割当てる処理(ステップS37の処理)が行われる。   The processing of steps S35 to S37 is performed by searching the last described function expression among the descriptions (function expressions) generated on the syntax list as described above for all child nodes of the “(PROGN” node. (Step S35) is a process of assigning a temporary variable only to the last described function expression (Step S37), provided that the last described function expression is a selection structure or a loop structure (Step S36, (YES), the process of assigning temporary variables (the process of step S37) is not performed, and the process of assigning temporary variables (NO in step S36) when the last described function expression is other than the selected structure or the loop structure (NO in step S36). Step S37) is performed.

尚、ステップS36がYESの場合、例えば、上記選択構造やループ構造の実行節で割り当てられた仮変数をそのまま使用するものであってもよいが、この例に限らない。
上記の例では、図5における4行目の関数式についてのみ、任意の仮変数を割当てることになり、図5の例では、仮変数INST_7が割当てられることになる。これによって、図5における4行目の記述が、以下のように生成されることになる。
INST_7 := (f:=INST_8)
When step S36 is YES, for example, the temporary variable assigned in the execution clause of the selection structure or the loop structure may be used as it is, but the present invention is not limited to this example.
In the above example, an arbitrary temporary variable is assigned only to the function expression on the fourth line in FIG. 5, and in the example of FIG. 5, the temporary variable INST_7 is assigned. As a result, the description on the fourth line in FIG. 5 is generated as follows.
INST_7: = (f: = INST_8)

尚、上記ステップS35〜S37の処理を、例えばステップS35等の処理と記す場合もあるものとする。   Note that the processing in steps S35 to S37 may be referred to as processing in step S35, for example.

ここで、比較の為に、図10の従来手法の場合の変換結果も参照して説明するものとする。
従来の方法では、上述したように、“(PROGN”ノードの全ての子ノードに関して仮変数を割当てることになっていた。つまり、上記“c”ノードに対しても仮変数(ここではINST_5であったものとする)が割当てられ、この為、図10に示すように、2行目の記述は下記のようになる。
INST_5 := (c:=INST_6)
Here, for comparison, the conversion result in the case of the conventional method of FIG. 10 will be described with reference to FIG.
In the conventional method, as described above, a temporary variable is assigned to all child nodes of the “(PROGN” node. In other words, the temporary variable (here, INST_5 is also assigned to the “c” node). Therefore, as shown in FIG. 10, the description on the second line is as follows.
INST_5: = (c: = INST_6)

これに対して、本手法では、上記の通り、PROGN文に関しては上記ステップS35等の処理を行うことで、最後の関数式に対してのみ仮変数が割当てられるので、図5に示すように、「INST_5 :=」の記述は無いものとなる。   On the other hand, in this method, as described above, a temporary variable is assigned only to the last function expression by performing the process of step S35 and the like for the PROGN statement, so as shown in FIG. There is no description of “INST — 5: =”.

上述したように、従来技術では、変換結果においては全ての関数式の実行結果に仮変数を割り当て、そのために余分な仮変数が存在することになり、変換後のプログラム実行環境を圧迫(メモリの使用など)してしまう問題が発生する。これに対して、本手法では、上記の通り、変換結果において余分な仮変数が存在しないようにできる。   As described above, in the prior art, temporary variables are assigned to the execution results of all the function expressions in the conversion results, and therefore, there are extra temporary variables, and the converted program execution environment is compressed (in the memory Problem). On the other hand, according to this method, as described above, it is possible to prevent an excess temporary variable from being present in the conversion result.

図4の処理の説明を続ける。
図4の処理に関して、上述したように、“(PROGN”ノードの「ノード処理」(ネスト3)の最後の処理(ステップS35等)まで説明した。そして、この「ノード処理」が終了することで、呼出元の「ノード処理」に戻ることになる。つまり、ネスト2の“(=”の「ノード処理」に戻り、ステップS44の判定を行うと、未処理の子ノードがあるので判定はNOとなり、ステップS42に戻る。そして、ステップS43で、未処理の子ノードである“10”ノードの「ノード処理」を、実行させることになる。
The description of the processing in FIG.
As described above, the processing in FIG. 4 has been described up to the last processing (step S35, etc.) of “node processing” (nesting 3) of the “(PROGN) node. Returning to the “node processing” of the caller, that is, returning to “node processing” of “(=” of nest 2 and performing the determination in step S44, the determination is NO because there is an unprocessed child node. Then, the process returns to step S42, and "node processing" of the "10" node that is an unprocessed child node is executed in step S43.

‘10’はオペランドであるので、“10”ノードの「ノード処理」では、ステップS11、S31、S41が全てNOとなり、これより、変数処理(ステップS46)を実行する。つまり、処理対象ノードのオペランド“10”を、構文リストに出力する。そして、この「ノード処理」が終了することで呼出元の処理(“(=”の「ノード処理」;ネスト2)に戻ると、今度はステップS44の判定はNOとなるので、ステップS45の処理を実行する。   Since “10” is an operand, in the “node processing” of the “10” node, steps S11, S31, and S41 are all NO, and the variable processing (step S46) is executed. That is, the operand “10” of the processing target node is output to the syntax list. When this “node processing” is completed and the process returns to the calling source processing (“(=” “node processing”; nest 2), the determination in step S44 is NO, so the processing in step S45 is performed. Execute.

ここで、処理対象ノードの関数が、“=”(イコール関数)である場合には、上記記述された“10”と、既存の最新の仮変数とを、“=”で結んだ式を、構文リストに追加出力する。これによって、構文リストには下記の記述が加わることになる。つまり、図5における5行目の記述の一部が生成されることになる。
INST_7 = 10
Here, when the function of the processing target node is “=” (equal function), an expression obtained by connecting “10” described above and the existing latest temporary variable with “=” is as follows: Outputs to the syntax list. This adds the following to the syntax list: That is, a part of the description on the fifth line in FIG. 5 is generated.
INST_7 = 10

尚、イコール関数の場合も、上記代入関数と同様、ステップS45において新たな仮変数の割当ては行わない。   In the case of the equal function, as in the substitution function, no new temporary variable is assigned in step S45.

上記処理実行を以って“(=”ノードの「ノード処理」(ネスト2)が終了するので、呼出元の「ノード処理」に戻ることになる。つまり、“(IF”ノードの「ノード処理」(ネスト1)に戻ることになる。ここで、これまでの処理は、上記ステップS12で取り出したif文の条件部である上記“(=”に係わる処理であり、この時点でステップS13の処理が完了したことになり、続いてステップS14の処理を実行する。   By executing the above process, the “node processing” (nesting 2) of the “(=” node is completed, so that the process returns to the “node processing” of the caller. ”(Nest 1) Here, the processing so far is processing related to the above“ (= ”which is the conditional part of the if statement taken out in step S12. The process is completed, and then the process of step S14 is executed.

ステップS14の処理は、構文リストにおける現在の最後の行に対して、if文を追加する処理である。上記一例では、上記「INST_7 = 10」に対して、if文を追加することになる。これによって、図5に示す5行目の式が、ほぼ完成することになる。但し、5行目の式の最後の括弧“{”は、未だ記述されていない。この“{”は後述するステップS17の処理で記述されるものであり、これについては後述する。   The process of step S14 is a process of adding an if statement to the current last line in the syntax list. In the above example, an “if” statement is added to “INST — 7 = 10”. As a result, the expression in the fifth row shown in FIG. 5 is almost completed. However, the last parenthesis “{” in the expression on the fifth line is not yet described. This “{” is described in the process of step S17 described later, and will be described later.

上記のようにステップS14の処理によって、上記一例の場合、図5に示す5行目の式における下記の記述が、生成されることになる。
if(INST_7 = 10)
そして、今度は、if文におけるThen部を取り出して(ステップS16)、このThen部に係わる「ノード処理」を実行させる(ステップS16)。上記一例の場合、“if”ノードのもう一方の子ノードである“(:=”ノードに係わるノード処理を実行させることになる。
As described above, in the case of the above example, the following description in the expression on the fifth line shown in FIG. 5 is generated by the process of step S14.
if (INST_7 = 10)
Then, the Then part in the if sentence is extracted (step S16), and the “node processing” related to the Then part is executed (step S16). In the above example, the node processing related to the “(: =” node, which is the other child node of the “if” node, is executed.

この“(:=”ノードの「ノード処理」(ネスト2)では、まず、ステップS11、S31がNOでステップS41がYESとなり、これより、この“(:=”ノードの子ノード(引数)を順次取り出して(ステップS42)、これら子ノード毎に「ノード処理」を呼び出す(ステップS43)処理を、全ての子ノードについて実行するまで繰り返す。この処理については、図5の1行目、2行目の式を作成した際の処理と、略同様であり、ここでは説明を省略するものとする。この処理結果として、図5における6行目、7行目の下記の式が、生成されることになる。
INST_10 ;= c−a;
INST_9 := (a:=INST_10)
In the “node processing” (nesting 2) of the “(: =” node, first, Steps S11 and S31 are NO, and Step S41 is YES. From this, the child node (argument) of this “(: =” node is changed. The process is sequentially taken out (step S42), and the "node process" is called for each child node (step S43) until the process is executed for all the child nodes. The processing is substantially the same as the processing when the eye formula is created, and the description is omitted here.As a result of this processing, the following formulas in the sixth and seventh lines in FIG. It will be.
INST — 10; = c−a;
INST_9: = (a: = INST_10)

そして、“if”ノードの「ノード処理」(ネスト1)に戻り、ステップS17の処理を実行する。ステップS17の処理は、構文リストにおける上記Then部に係わる変換結果を、括弧“{}”で挟む記述を、構文リストに追加する。上記一例の場合、上記図5における6行目、7行目の式を挟むように、開き括弧“{”と閉じ括弧“}”を、追加記述する。   Then, the processing returns to the “node processing” (nesting 1) of the “if” node, and the processing in step S17 is executed. In the process of step S17, a description in which the conversion result related to the above-mentioned Then part in the syntax list is sandwiched between parentheses “{}” is added to the syntax list. In the case of the above example, an opening parenthesis “{” and a closing parenthesis “}” are additionally described so as to sandwich the expressions on the sixth and seventh lines in FIG.

以上の処理によって、図5の1行目〜8行目の変換結果が、得られることになる。
続いて、変換対象にelse部があるか否かを判定する(ステップS18)。そして、else部がある場合には(ステップS18,YES)、その変換処理を実行する(ステップS19)。これは、既存の処理であるので、ここでは特に説明しないものとする。
With the above processing, the conversion results of the first to eighth lines in FIG. 5 are obtained.
Subsequently, it is determined whether or not there is an else portion as a conversion target (step S18). If there is an else portion (step S18, YES), the conversion process is executed (step S19). Since this is an existing process, it is not specifically described here.

一方、例えば図9の例のようにelse部がない場合には(ステップS18、NO)、従来では何も行わなかったが、本例ではステップS20の処理を実行する。尚、従来では何も処理しないので、例えば図9の例に対しては、図10に示すように、上記8行目までの変換結果のみであり、9行目以降は存在しない。一方、本手法では、ステップS20の処理によって、図5に示す9行目〜11行目の記述が、生成されることになる。   On the other hand, for example, when there is no else part as in the example of FIG. 9 (step S18, NO), nothing is performed conventionally, but in this example, the process of step S20 is executed. Since nothing is processed in the prior art, for example, for the example of FIG. 9, as shown in FIG. 10, only the conversion result up to the eighth line is present, and the ninth and subsequent lines do not exist. On the other hand, in the present technique, the descriptions of the ninth to eleventh lines shown in FIG. 5 are generated by the process of step S20.

ステップS20の処理は、下記の3行分の1文を、構文リストの最後に追加記述する処理である。
else {
最新の(最後の)仮変数 := 0;
The process of step S20 is a process in which one sentence for the following three lines is additionally described at the end of the syntax list.
else {
The latest (last) temporary variable: = 0;
}

上記一例の場合、最新の仮変数は、図5の7行目の式を生成する際に割当てられていたINST_9である。よって、上記一例の場合、図5に示す9行目〜11行目の記述が、追加されることになる。
else {
INST_9 := 0;
In the case of the above example, the latest temporary variable is INST_9 that was assigned when the expression on the seventh line in FIG. 5 was generated. Therefore, in the case of the above example, the descriptions of the ninth to eleventh lines shown in FIG. 5 are added.
else {
INST_9: = 0;
}

従来の場合、図10に示すように変換結果にelse文が無いので、実行結果が不定になるという問題が発生する。これに対して、本手法では、上記の通り、変換元にelse文が無い場合であっても、変換結果には強制的にelse文が追加されているので、実行結果が不定になることはない。尚、上記‘0’は一例であり、この例に限らず、任意の数値を用いればよい。つまり、強制的に所定の数値を割当てれば、実行結果が不定となることはない。   In the conventional case, as shown in FIG. 10, since there is no else statement in the conversion result, there arises a problem that the execution result becomes indefinite. In contrast, in this method, as described above, even if there is no else statement at the conversion source, the else statement is forcibly added to the conversion result. Absent. Note that “0” is an example, and the present invention is not limited to this example, and any numerical value may be used. That is, if a predetermined numerical value is forcibly assigned, the execution result will not be indefinite.

換言すれば、本手法では、FCLプログラムにおいて選択構造で条件式が不成立時の選択肢が省略されていた場合、変換結果プログラムに条件不成立時の選択肢を追加すると共に、最新の(最後の)仮変数に対して0を代入する実行節を、変換結果プログラムに追加する。   In other words, in this method, when the option when the conditional expression is not satisfied is omitted in the selection structure in the FCL program, the option when the condition is not satisfied is added to the conversion result program, and the latest (last) temporary variable is added. An execution clause that assigns 0 to is added to the conversion result program.

尚、図3には示されていないが、例えば図3の例において更に別の“if”ノード(不図示)が存在する場合、この“if”ノードに関しても上記ステップS12〜S20の処理が行われることになる。   Although not shown in FIG. 3, for example, when another “if” node (not shown) exists in the example of FIG. 3, the processes of steps S <b> 12 to S <b> 20 are also performed for this “if” node. It will be.

また、図3に示すPROGN関数に係わる複数の関数式の1つとして、if文がある場合もあり得る。この場合には、上記の通り、新たな仮変数は生成しない。
以上説明したように、本例の言語変換装置10によれば、関数型言語を手続型言語に変換する言語変換装置において、PROGN関数を含む選択構造を含むプログラム文の変換の際に、実質的に無用となる仮変数の生成・割り当てが行われないようにできる。あるいは、変換元のプログラム文にELSE節がない場合であっても、変換したプログラム実行結果が不定になるという問題を回避できる。
In addition, there may be an if statement as one of a plurality of function expressions related to the PROGN function shown in FIG. In this case, as described above, a new temporary variable is not generated.
As described above, according to the language conversion apparatus 10 of the present example, in the language conversion apparatus that converts a functional language into a procedural language, the program sentence including the selection structure including the PROGN function is substantially converted. It is possible to prevent generation and assignment of temporary variables that are useless. Alternatively, the problem that the converted program execution result becomes indefinite can be avoided even if the conversion source program statement has no ELSE clause.

10 言語変換装置
11 関数型言語(FCL)格納部
12 二次元構造(ツリー)変換部
13 二次元構造格納部
14 変換部
15 手続型言語格納部

DESCRIPTION OF SYMBOLS 10 Language converter 11 Functional language (FCL) storage part 12 Two-dimensional structure (tree) conversion part 13 Two-dimensional structure storage part 14 Conversion part 15 Procedural language storage part

Claims (5)

関数型言語で記述されたプログラムを手続型言語に変換する言語変換装置であって、
前記プログラムの変換を行う変換手段であって、該変換に伴って関数式に対しては任意の仮変数を生成して割当てる変換手段と有し、
前記変換手段は、前記プログラムにおいて選択構造またはループ構造の条件節に複数の関数式が記述されている場合、最後の関数式に対してのみ前記仮変数の割当てを行うことを特徴とする言語変換装置。
A language conversion device for converting a program written in a functional language into a procedural language,
Conversion means for performing conversion of the program, and having conversion means for generating and assigning an arbitrary temporary variable to the function expression accompanying the conversion,
The language conversion is characterized in that the conversion means assigns the temporary variable only to the last function expression when a plurality of function expressions are described in the conditional clause of the selection structure or the loop structure in the program. apparatus.
前記プログラムにおいては、PROGN関数によって、前記選択構造またはループ構造の条件節に複数の式が記述されることを特徴とする請求項1記載の言語変換装置。   The language conversion apparatus according to claim 1, wherein in the program, a plurality of expressions are described in a conditional clause of the selection structure or loop structure by a PROGN function. 前記変換手段は、前記プログラムにおいて前記PROGN関数があった場合、該PROGN関数に係わる全ての関数式について、仮変数の割当てを行うことなく前記手続型言語に変換した後に、最後の関数式に対してのみ前記仮変数の割当てを行うことを特徴とする請求項2記載の言語変換装置。   When the program has the PROGN function, the conversion means converts all function expressions related to the PROGN function into the procedural language without assigning temporary variables, and then converts the function expression to the last function expression. 3. The language conversion apparatus according to claim 2, wherein the temporary variable is assigned only to the user. 前記変換手段は、前記プログラムにおいて選択構造で条件式が不成立時の選択肢が省略されていた場合、条件不成立時の選択肢を追加すると共に、最新の仮変数に対して0を代入する実行節を、変換結果プログラムに追加することを特徴とする請求項1記載の言語変換装置。   The conversion means adds an option when the conditional expression is not satisfied in the selection structure in the program when the conditional expression is not satisfied, and adds an execution clause for substituting 0 for the latest temporary variable, The language conversion apparatus according to claim 1, wherein the language conversion apparatus is added to the conversion result program. 前記関数型言語で記述されたプログラムにおける関数又はオペランドの各要素の配列を記憶した関数型言語記憶手段と、
前記配列の各要素を順次取得し、該各要素に応じたノードと該ノード間のリンクから成るツリー構造を生成するツリー構造作成手段とを更に有し、
前記変換手段は、該ツリー構造に基づいて、前記プログラムの変換を行うことを特徴とする請求項1〜4の何れかに記載の言語変換装置。

A functional language storage means for storing an array of elements of functions or operands in a program described in the functional language;
Tree structure creating means for sequentially obtaining each element of the array and generating a tree structure composed of nodes corresponding to the elements and links between the nodes;
The language conversion apparatus according to claim 1, wherein the conversion unit converts the program based on the tree structure.

JP2015011828A 2015-01-23 2015-01-23 Language converter Active JP6402639B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2015011828A JP6402639B2 (en) 2015-01-23 2015-01-23 Language converter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2015011828A JP6402639B2 (en) 2015-01-23 2015-01-23 Language converter

Publications (2)

Publication Number Publication Date
JP2016136368A true JP2016136368A (en) 2016-07-28
JP6402639B2 JP6402639B2 (en) 2018-10-10

Family

ID=56512636

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2015011828A Active JP6402639B2 (en) 2015-01-23 2015-01-23 Language converter

Country Status (1)

Country Link
JP (1) JP6402639B2 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02105224A (en) * 1988-10-13 1990-04-17 Nec Corp Data allocation system in compiler
JP2002157128A (en) * 2000-11-20 2002-05-31 Hitachi Ltd Method for allocating stack area to compiler and compiler
JP2014059848A (en) * 2012-09-19 2014-04-03 Fuji Electric Co Ltd Language conversion device, and program

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH02105224A (en) * 1988-10-13 1990-04-17 Nec Corp Data allocation system in compiler
JP2002157128A (en) * 2000-11-20 2002-05-31 Hitachi Ltd Method for allocating stack area to compiler and compiler
JP2014059848A (en) * 2012-09-19 2014-04-03 Fuji Electric Co Ltd Language conversion device, and program

Also Published As

Publication number Publication date
JP6402639B2 (en) 2018-10-10

Similar Documents

Publication Publication Date Title
CN108920133B (en) Cross-language programming method and device, electronic equipment and storage medium
CN106648662B (en) Report generation device and method based on project cost calculation description language BCL
Cánovas Izquierdo et al. Extracting models from source code in software modernization
CN110149800B (en) Apparatus for processing abstract syntax tree associated with source code of source program
WO2009098739A1 (en) Program optimization device and program optimization method
JP5147240B2 (en) Method and system for reversible design tree transformation
CN112346730B (en) Intermediate representation generation method, computer equipment and storage medium
Grønmo et al. Comparison of three model transformation languages
JP2009181446A (en) Program generating device and block diagram generating apparatus
KR100688444B1 (en) Program automatic converting method and program automatic converting device
JP6402639B2 (en) Language converter
JP2006163686A (en) Compiling method, compiling program, compiling device and recording medium for compile
JP5541102B2 (en) Language conversion device and language conversion program
JP2009163662A (en) Information processor, control method of information processor, and control program of information processor
JP2009048259A (en) Program conversion method and program for conversion
JP5041990B2 (en) Software component extraction support device
JP5275087B2 (en) Program generating apparatus and block diagram generating apparatus
JP2010049439A (en) System construction method using software model and modeling device
Åkesson et al. Jatte: A tunable tree editor for integrated DSLs
JP6175306B2 (en) Control program dividing apparatus, control program dividing method and recording medium therefor
JP7059757B2 (en) API processing method, terminal, API processing program
JP5966801B2 (en) Language converter, program
Kolek et al. Two-dimensional Extensibility of SSQSA Framework.
JP4698943B2 (en) Program production method, program production apparatus, program automatic conversion method, and program
Chise et al. Towards early performance assessment based on UML MARTE models for distributed systems

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20171214

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20180725

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20180814

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20180827

R150 Certificate of patent or registration of utility model

Ref document number: 6402639

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250