JP5541102B2 - Language conversion device and language conversion program - Google Patents

Language conversion device and language conversion program Download PDF

Info

Publication number
JP5541102B2
JP5541102B2 JP2010254254A JP2010254254A JP5541102B2 JP 5541102 B2 JP5541102 B2 JP 5541102B2 JP 2010254254 A JP2010254254 A JP 2010254254A JP 2010254254 A JP2010254254 A JP 2010254254A JP 5541102 B2 JP5541102 B2 JP 5541102B2
Authority
JP
Japan
Prior art keywords
node
function
language
newly created
tree structure
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
JP2010254254A
Other languages
Japanese (ja)
Other versions
JP2012104065A (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.)
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 JP2010254254A priority Critical patent/JP5541102B2/en
Publication of JP2012104065A publication Critical patent/JP2012104065A/en
Application granted granted Critical
Publication of JP5541102B2 publication Critical patent/JP5541102B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

本発明は、関数型言語で記述されたプログラムを関数型言語処理に不向きな演算処理装置において実行可能な形に変換する言語変換装置および言語変換プログラムに関する。   The present invention relates to a language conversion device and a language conversion program for converting 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」という)は、シーケンス制御プログラムを実行し、制御対象機器を制御するものである。このプログラマブルコントローラが実行するシーケンス制御プログラムとしては、図7に示すように、例えばPC用言語としての表現依存部(ニーモニック記述、ラダー図、ファンクションブロック図、SFC図(Sequential Function Chart)、ディシジョンテーブル、等)とマシン語としての機械依存部との間に中間言語としての関数型制御言語(Functional Control Language、以下「FCL」という)がある。   A programmable controller (hereinafter simply referred to as “PLC”) executes a sequence control program and controls a device to be controlled. As a sequence control program executed by the programmable controller, as shown in FIG. 7, for example, an expression dependent part (mnemonic description, ladder diagram, function block diagram, SFC diagram (Sequential Function Chart), decision table, Etc.) and a machine dependent part as a machine language, there is a functional control language (hereinafter referred to as “FCL”) as an intermediate language.

このFCLは、シーケンス制御プログラムを関数型のプログラム構造で表現した言語である。FCLでは、図8に示すように、一つの機能を引数Ar1、Ar2、Ar3、・・・を持つ関数式Fで表している。また、別の関数式を関数式Fの引数とすることができる。よって、ある関数式と、そのある関数式の引数(この中には関数式も含まれる)との関係をツリー構造(機能構造)として二次元的に表現することができる。   The FCL is a language that expresses a sequence control program with a functional program structure. In the FCL, as shown in FIG. 8, one function is represented by a function formula F having arguments Ar1, Ar2, Ar3,. Another function expression can be used as an argument of the function expression F. Therefore, the relationship between a certain function expression and an argument (including the function expression) of the certain function expression can be expressed two-dimensionally as a tree structure (functional structure).

例えば、図9では、関数Aが関数Bと関数Cを引数とし、関数Bは引数vおよびwを有し、関数Cは引数xおよび関数Dを引数として有し、関数Dは引数yおよびzを有すること、すなわち、下記の式に対する2次元構造が表現されている。
(A (B v w) (C x (D y z)))
例えば、特許文献1および2には、関数型言語の実行方式として、命令スタックとデータスタックを用いて演算を実行する方式が示されている。
For example, in FIG. 9, function A has function B and function C as arguments, function B has arguments v and w, function C has arguments x and D, and function D has arguments y and z. In other words, a two-dimensional structure for the following equation is expressed.
(A (B v w) (C x (D y z)))
For example, Patent Documents 1 and 2 show a method of executing an operation using an instruction stack and a data stack as a functional language execution method.

この命令スタックとデータスタックを用いて演算を実行する方式の場合、当然のこととして、命令スタックとデータスタックという手段が必要となり、それらの手段を持たない装置(例えば、手続き型の命令処理を実行する装置)では、その方式の実行が困難あるいはその方式をエミュレーションするために処理性能が低下するという問題がある。   In the case of a method of executing an operation using this instruction stack and data stack, naturally, means such as an instruction stack and a data stack are necessary, and a device without such means (for example, executing procedural instruction processing) However, it is difficult to execute the method, or the processing performance deteriorates due to emulation of the method.

特開平2−230426号公報JP-A-2-230426 特開平1−243126号公報JP-A-1-243126

本発明は、命令スタックとデータスタックを持たない装置(例えば、手続き型の命令処理を実行する装置)において、関数型制御言語を実行することを可能とした言語変換装置および言語変換プログラムを提供することを目的とする。   The present invention provides a language conversion device and a language conversion program that can execute a functional control language in a device that does not have an instruction stack and a data stack (for example, a device that executes procedural instruction processing). For the purpose.

提案する言語変換装置は、関数型言語で記述された制御処理プログラムを手続型の命令処理を行なう装置で実行可能な言語形式に変換する。この言語変換装置は、関数型言語の命令/変数オペランドの各要素の配列を記憶した関数型言語記憶部と、上記配列の各要素を取得し、それぞれをノードとしたツリー構造を作成し、ツリー構造記憶部に出力するツリー構造作成部と、上記ツリー構造中の子供ノード持たないノードであるリーフ以外のノードにインスタンス名を付与するインスタンス名付与部と、上記インスタンス名を付与されたツリー構造に対して、子供ノードがリーフしかないノードを見つけ、そのノードに記述された関数を呼び出し、その呼び出した結果の代入文を、代入先をそのノードに付与されたインスタンス名として作成し、手続型言語の命令群を記憶する手続型言語記憶部に出力する代入文作成部と、上記手続型言語記憶部に出力したノードの子供ノードのすべてを上記ツリー構造中から削除する削除処理部と、を有し、上記ツリー構造が1つのノードになるまで、上記代入文作成処理および上記削除処理を繰り返すものである。   The proposed language conversion device converts a control processing program described in a functional language into a language format that can be executed by a device that performs procedural instruction processing. This language conversion apparatus acquires a functional language storage unit storing an array of elements of instruction / variable operands of a functional language, and obtains each element of the array, creates a tree structure using each element as a node, A tree structure creation unit that outputs to the structure storage unit, an instance name assignment unit that assigns instance names to nodes other than leaves that are nodes that do not have child nodes in the tree structure, and a tree structure that is assigned the instance name On the other hand, a node whose child node has only a leaf is found, a function described in the node is called, an assignment statement as a result of the call is created, and an assignment destination is created as an instance name given to the node. An assignment statement creation unit that outputs to the procedural language storage unit that stores the instruction group of the node and a child node of the node that is output to the procedural language storage unit. The hand has a deletion section to be deleted from the tree structure, until the tree structure is one node, but repeating the assignment statement creation processing and the deletion processing.

提案する言語変換装置によれば、関数型言語の命令/変数オペランドの各要素の配列から生成されたツリー構造を用いて、ネストされた子供の関数が命令の実行順序で親関数の前に、代入文作成部および削除処理部による操作によって並び換えられ、親関数は、子供関数の実行結果が代入されたオペランド(インスタンス名が付けられた変数)を用いて実行される。このような並び換えにより、命令スタックとデータスタックを持たない装置(例えば、手続き型の命令処理を実行する装置)において、関数型制御言語を実行することが可能となる。   According to the proposed language conversion device, using a tree structure generated from an array of each element of a functional language instruction / variable operand, a nested child function is preceded by a parent function in the instruction execution order. The parent function is executed by using an operand (a variable with an instance name) substituted with the execution result of the child function. By such rearrangement, it is possible to execute the functional control language in a device that does not have an instruction stack and a data stack (for example, a device that executes procedural instruction processing).

本発明の一実施形態に係る言語変換装置の構成を示すブロック図である。It is a block diagram which shows the structure of the language converter which concerns on one Embodiment of this invention. 関数型言語(FCL)格納装置に格納されるFCLの式に対応する配列の一例を示した図である。It is the figure which showed an example of the arrangement | sequence corresponding to the expression of FCL stored in a functional language (FCL) storage device. 二次元構造格納装置に格納されるツリー構造の一例を示した図である。It is the figure which showed an example of the tree structure stored in a two-dimensional structure storage apparatus. 手続型言語格納装置に格納される手続型言語の命令群の一例を示した図である。It is the figure which showed an example of the instruction group of the procedural language stored in the procedural language storage device. 関数型言語(FCL)格納装置に記憶された配列の内容から、ツリー構造を作成する処理のフローチャートである。It is a flowchart of the process which produces a tree structure from the content of the array memorize | stored in the functional language (FCL) storage device. 本実施形態の言語変換処理のフローチャートである。It is a flowchart of the language conversion process of this embodiment. 関数型制御言語の位置付けを示す図である。It is a figure which shows the positioning of a functional control language. 関数型制御言語の基本構造を示す図である。It is a figure which shows the basic structure of a functional control language. 関数型制御言語の二次元機能構造の一例を表現した図である。It is a figure expressing an example of the two-dimensional functional structure of a functional control language.

以下図面に基づいて、本発明の実施形態について詳細を説明する。
図1は、本発明の一実施形態に係る言語変換装置の構成を示すブロック図である。例えば、図の各ブロックはハードウェアあるいはソフトウェアとして実現される。
Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
FIG. 1 is a block diagram showing a configuration of a language conversion apparatus according to an embodiment of the present invention. For example, each block in the figure is realized as hardware or software.

図1に示すように、言語変換装置は、関数型言語(FCL)格納装置11と、二次元構造(ツリー)変換部12と、二次元構造格納装置13と、関数名−インスタンス名作成部14と、命令並び換え部15と、手続型言語格納装置16と、を有する。   As shown in FIG. 1, the language conversion device includes a functional language (FCL) storage device 11, a two-dimensional structure (tree) conversion unit 12, a two-dimensional structure storage device 13, and a function name-instance name creation unit 14. And an instruction rearrangement unit 15 and a procedural language storage device 16.

関数型言語(FCL)格納装置11は、FCLの命令・変数オペランドを配列として格納したメモリである。
例えば、FCLの下記式に対して、図2に示すような配列が、関数型言語(FCL)格納装置11に格納される。
(A (B v w) (C x (D y z)))
上式では、A、B、C、Dが関数であり、v、w、x、y、zが引数である。図2に示すように、関数を示す変数は開き括弧“(”とともに、関数型言語(FCL)格納装置11の配列の要素に格納するようにしている。また、関数終了子は閉じ括弧“)”として、引数(オペランド)はそのまま、配列の要素に格納するようにしている。
The functional language (FCL) storage device 11 is a memory that stores FCL instructions and variable operands as an array.
For example, an array as shown in FIG. 2 is stored in the functional language (FCL) storage device 11 for the following expression of FCL.
(A (B v w) (C x (D y z)))
In the above equation, A, B, C, and D are functions, and v, w, x, y, and z are arguments. As shown in FIG. 2, the variable indicating the function is stored in the array element of the functional language (FCL) storage device 11 together with the opening parenthesis “(”. The function terminator is the closing parenthesis “). ", The argument (operand) is stored in the array element as it is.

二次元構造(ツリー)変換部12は、関数型言語(FCL)格納装置11に記憶された配列の内容を、その配列の各要素を節(以下、「ノード」という)としてツリー構造化する。   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”).

ノードは、図3に示すように、ノード名称、インスタンス名、子供ノードへのポインタ、次ノードへのポインタ、の各項目を有する。ある関数は、別の関数および変数オペランドを引数とすることができる。呼び出し元の関数からその引数をポイントするときは、“子供ノードへのポインタ”に値を設定する。一方、呼び出し元の関数が同一である引数間では、“次ノードへのポインタ” に値を設定することで、自分に続く引数を指定する。   As shown in FIG. 3, each node has items of a node name, an instance name, a pointer to a child node, and a pointer to the next node. One function can take other functions and variable operands as arguments. When pointing the argument from the caller function, set a value to "pointer to child node". On the other hand, between the arguments with the same caller function, the argument following itself is specified by setting a value to “pointer to next node”.

二次元構造(ツリー)変換部12は、ツリー構造化に際し、関数部を親のノード、引数部を子供のノードにする。二次元構造(ツリー)変換部12の処理結果は、二次元構造格納装置13に出力される。   The two-dimensional structure (tree) conversion unit 12 sets a function part as a parent node and an argument part as a child node when forming a tree structure. The processing result of the two-dimensional structure (tree) conversion unit 12 is output to the two-dimensional structure storage device 13.

関数名−インスタンス名作成部14は、二次元構造格納装置13の格納内容を参照して、そのツリー構造の末端部(すなわち、子供ノードを持たないノード、以下、このようなノードを「リーフ」という)以外のノードにツリー内での固有の名称(以下、「インスタンス名」という)を付ける。この処理後は、リーフのインスタンス名のみが空欄となる。   The function name-instance name creation unit 14 refers to the stored contents of the two-dimensional structure storage device 13 and refers to the end of the tree structure (ie, a node having no child nodes, hereinafter referred to as “leaf”). A unique name in the tree (hereinafter referred to as “instance name”) is assigned to a node other than After this process, only the leaf instance name is blank.

図3に、二次元構造格納装置に格納されるツリー構造の一例を示す。図3では、インスタンス名を“INST_”+“(自動採番により割り振られた)番号”の形式にしているが、各関数を識別可能な任意の方法によりインスタンス名を付与可能である。また、図3のような二次元構造(ツリー構造)を表現するのに、XML(Extensible Markup Language)で記述されたテキストによるデータ構造を使用することができる。XMLの場合、ツリー構造データの追加/削除/検索などの操作を容易に行なうことができる。   FIG. 3 shows an example of a tree structure stored in the two-dimensional structure storage device. In FIG. 3, the instance name is in the form of “INST _” + “number (assigned by automatic numbering)”, but the instance name can be given by any method that can identify each function. Further, 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.

命令並び換え部15は、二次元構造格納装置13に格納されたツリー構造を末端に向かう方向に順にたどって、子供ノードがリーフしかないノードを見つけ、その子供ノードがリーフしかないノードについて、ノードに記述された関数を呼び出して、その関数の値を代入する代入文を作成して、手続型言語格納装置16に格納する。なお、代入先はそのノードのインスタンス名とする。   The instruction rearrangement unit 15 sequentially searches the tree structure stored in the two-dimensional structure storage device 13 in the direction toward the end, finds a node whose child node has only a leaf, Is called, and an assignment statement for assigning the value of the function is created and stored in the procedural language storage device 16. The assignment destination is the instance name of the node.

続いて、命令並び換え部15は、上記処理で手続型言語格納装置16に格納したノードの子供ノードをすべて削除する。そして、最上位の親ノードまで戻り、同様の処理を繰り返す。ツリー構造上のノードの数が1つになるまでこの処理を行なう。   Subsequently, the instruction rearrangement unit 15 deletes all child nodes of the nodes stored in the procedural language storage device 16 by the above processing. Then, the process returns to the highest parent node and the same processing is repeated. This process is performed until the number of nodes on the tree structure becomes one.

命令並び換え部15による以上の操作によって、ネストされた子供の関数が命令の実行順序で親関数の前に並び換えられ、親関数は、子供関数の実行結果が代入されたオペランド(インスタンス名が付けられた変数)を用いて実行される。   Through the above operations by the instruction rearrangement unit 15, the nested child functions are rearranged before the parent function in the instruction execution order, and the parent function is an operand (instance name is assigned to the execution result of the child function). It is executed using the attached variable).

図4に、手続型言語格納装置16に格納される手続型言語の命令群の一例を示す。図4では、手続型の命令処理を行なう装置で実行可能な命令として、PASCAL言語の場合が示されている。この言語では、代入を“:=”で表し、関数呼び出しを“関数名(引数1,引数2,...)”で表している。   FIG. 4 shows an example of a procedural language instruction group stored in the procedural language storage device 16. FIG. 4 shows the case of the PASCAL language as an instruction that can be executed by a device that performs procedural instruction processing. In this language, substitution is represented by “: =”, and function call is represented by “function name (argument 1, argument 2,...)”.

図5は、関数型言語(FCL)格納装置11に記憶された配列の内容から、ツリー構造を作成する処理のフローチャートである。このフローチャートの処理は、二次元構造(ツリー)変換部12によって実行される。   FIG. 5 is a flowchart of a process for creating a tree structure from the contents of the array stored in the functional language (FCL) storage device 11. The processing of this flowchart is executed by the two-dimensional structure (tree) conversion unit 12.

図5のステップS1において、ルートノード(一番上位の要素:処理を再帰的に実行するためのダミーノード)を生成し、そのルートノードを現在処理中ノードに設定する。すなわち、そのルートノードのアドレスを現在処理中ノードポインタに設定する。   In step S1 of FIG. 5, a root node (highest element: a dummy node for recursively executing the process) is generated, and the root node is set as a currently processing node. That is, the address of the root node is set in the currently processed node pointer.

続く、ステップS2で、関数型言語(FCL)格納装置11に記憶された配列の現在位置からデータが読み出される。そして、ステップS3でデータの種類が判定される。
読み出されたデータ(配列の要素)が開き括弧“(”+“文字(列)”の形式をしていれば、ステップS3において、そのデータは関数であると判定される。この場合、ステップS4において、その関数の名称(“文字(列)”)をノード名称に設定したノードが新規作成され、ステップS7に進む。
In subsequent step S2, data is read from the current position of the array stored in the functional language (FCL) storage device 11. In step S3, the type of data is determined.
If the read data (element of the array) is in the form of open parenthesis “(” + “character (string)”, it is determined in step S3 that the data is a function. In S4, a new node is created in which the name of the function (“character (string)”) is set as the node name, and the process proceeds to step S7.

読み出されたデータ(配列の要素)が “文字(列)”の形式をしていれば、ステップS3において、そのデータはオペランドであると判定される。この場合、ステップS5において、そのオペランドの名称(“文字(列)”)をノード名称に設定したノードが新規作成され、ステップS6において、その新規作成されたノードの子供ノードへのポインタに“NULL”が設定され、ステップS7に進む。   If the read data (array element) is in the form of “character (string)”, it is determined in step S3 that the data is an operand. In this case, in step S5, a new node is created with the name of the operand ("character (string)") set as the node name. In step S6, a pointer to the child node of the newly created node is set to "NULL". "Is set, and the process proceeds to step S7.

ステップS4またはステップS6から制御を渡されたステップS7では、新規作成したノードを現在処理中ノードに設定する。
ステップS7に続くステップS8では、新規作成したノードに対する次ノードあるいは子供ノードへのポインタの設定処理が実行される。
In step S7 to which control is passed from step S4 or step S6, the newly created node is set as the currently processing node.
In step S8 following step S7, a process for setting a pointer to the next node or child node for the newly created node is executed.

すなわち、現在処理中ノードが関数に対応したものであり、かつ、新規作成したノードが関数に対応したもののときに、新規作成したノードの次ノードへのポインタに“NULL”を設定し、現在処理中ノードがオペランドに対応したものであり、かつ、新規作成したノードがオペランドに対応したもののときに、新規作成したノードの次ノードへのポインタに“NULL”を設定し、現在処理中ノードがオペランドに対応したものであり、かつ、新規作成したノードが関数に対応したもののときに、新規作成したノードの次ノードへのポインタに“NULL”を設定し、現在処理中ノードが関数に対応したものであり、かつ、新規作成したノードがオペランドに対応したもののときに、新規作成したノードの子供ノードへのポインタに“NULL”を設定する処理が実行される。そして、ステップS2に戻り、次のデータ(配列の要素)の読み込み処理が実行される。   That is, when the currently processed node corresponds to a function and the newly created node corresponds to a function, “NULL” is set to the pointer to the next node of the newly created node, and the current process is performed. When the middle node corresponds to the operand and the newly created node corresponds to the operand, “NULL” is set to the pointer to the next node of the newly created node, and the currently processed node is the operand. If the newly created node corresponds to a function and the pointer to the next node of the newly created node is set to “NULL”, the currently processed node corresponds to the function. And the newly created node corresponds to the operand, the pointer to the child node of the newly created node is “N The process of setting the LL "is executed. Then, the process returns to step S2, and the next data (array element) reading process is executed.

一方、ステップS2で読み出されたデータ(配列の要素)が閉じ括弧“)”の形式をしていれば、ステップS3において、そのデータは関数終了子であると判定される。この場合、ステップS9において、そのときの現在処理中ノードの次ノードへのポインタに“NULL”を設定し、続くステップS10で、その終了した関数のノードを現在処理中ノードに設定する。そして、ステップS2に戻り、次のデータ(配列の要素)の読み込み処理が実行される。   On the other hand, if the data (element of the array) read in step S2 is in the form of a closing parenthesis “)”, it is determined in step S3 that the data is a function terminator. In this case, in step S9, "NULL" is set to the pointer to the next node of the current processing node at that time, and in the subsequent step S10, the node of the finished function is set as the current processing node. Then, the process returns to step S2, and the next data (array element) reading process is executed.

図6は、本実施形態の言語変換処理のフローチャートである。このフローチャートは図1の言語変換装置の各ブロックによって実行される。
この処理に先立って、関数型言語(FCL)格納装置11には、FCLの命令・変数オペランドが配列として予め格納されているものとする。
FIG. 6 is a flowchart of language conversion processing according to this embodiment. This flowchart is executed by each block of the language conversion apparatus of FIG.
Prior to this processing, it is assumed that FCL instruction / variable operands are stored in advance in the functional language (FCL) storage device 11 as an array.

図6のステップS21において、二次元構造(ツリー)変換部12によって、関数型言語(FCL)格納装置11に記憶された配列の内容が、その配列の各要素をノードとしてとしてツリー構造化される。その詳細は図5のフローチャートに示した通りである。なお、その二次元構造(ツリー)変換部12による処理結果(ツリー構造)は、二次元構造格納装置13に格納される。   In step S21 of FIG. 6, the contents of the array stored in the functional language (FCL) storage device 11 are made into a tree structure by using each element of the array as a node by the two-dimensional structure (tree) conversion unit 12. . The details are as shown in the flowchart of FIG. The processing result (tree structure) by the two-dimensional structure (tree) conversion unit 12 is stored in the two-dimensional structure storage device 13.

続く、ステップS22では、関数名−インスタンス名作成部14によって、二次元構造格納装置13の格納内容を参照して、そのツリー構造のリーフ以外のノードにインスタンス名が付与される。   In step S22, the function name-instance name creation unit 14 refers to the stored contents of the two-dimensional structure storage device 13 and assigns instance names to nodes other than the leaves of the tree structure.

そして、ステップS22に続くステップS23で、ノード総数カウント処理がノード総数カウント部(不図示)によって行われる。これは、ツリー構造のその時点におけるノード総数をカウントする処理である。   In step S23 subsequent to step S22, the node total count processing is performed by a node total count section (not shown). This is a process of counting the total number of nodes at that point in the tree structure.

続くステップS24では、ステップS23でカウントされたノード総数が“1”に等しいかどうかが判定される。
ステップS24でノード総数が“1”に等しいと判定された場合、一連の処理を終了する。
In subsequent step S24, it is determined whether or not the total number of nodes counted in step S23 is equal to "1".
If it is determined in step S24 that the total number of nodes is equal to “1”, the series of processing ends.

ステップS24でノード総数が“1”に等しくないと判定された場合、ステップS25で、命令並び換え部15によって、二次元構造格納装置13に格納されたツリー構造が末端に向かう方向にたどられて、子供ノードがリーフしかないノードが検索される。この検索の結果として、子供ノードがリーフしかないノードが見つけられ、その子供ノードがリーフしかないノードについて、ノードに記述された関数が呼び出されて、その関数の値を代入する代入文が、代入先をそのノードのインスタンス名として作成されて、手続型言語格納装置16に格納される。   When it is determined in step S24 that the total number of nodes is not equal to “1”, in step S25, the instruction rearrangement unit 15 traces the tree structure stored in the two-dimensional structure storage device 13 in the direction toward the end. Thus, a node having only a leaf as a child node is searched. As a result of this search, a node whose child node only has a leaf is found, and for the node whose child node only has a leaf, the function described in the node is called, and an assignment statement that assigns the value of that function is assigned The destination is created as the instance name of the node and stored in the procedural language storage device 16.

続く、ステップS26で、命令並び換え部15によって、上記処理で手続型言語格納装置16に格納したノードの子供ノードがすべて削除される。そして、ステップS23に戻り、同様の処理を繰り返す。ツリー構造上のノードの数が1つになるまでこの処理を行なう。   In step S26, the instruction rearrangement unit 15 deletes all child nodes of the nodes stored in the procedural language storage device 16 by the above processing. And it returns to step S23 and repeats the same process. This process is performed until the number of nodes on the tree structure becomes one.

関数型言語の命令/変数オペランドの各要素の配列から生成されたツリー構造を用いて、ネストされた子供の関数が命令の実行順序で親関数の前に、命令並び換え部15による以上の操作によって並び換えられ、親関数は、子供関数の実行結果が代入されたオペランド(インスタンス名が付けられた変数)を用いて実行される。   Using the tree structure generated from the array of each element of the instruction / variable operand in the functional language, the above operation by the instruction rearrangement unit 15 is performed before the nested child function precedes the parent function in the instruction execution order. The parent function is executed using an operand (a variable with an instance name) to which the execution result of the child function is assigned.

このような並び換えにより、命令スタックとデータスタックを持たない装置(例えば、手続き型の命令処理を実行する装置)において、関数型制御言語を実行することが可能となる。   By such rearrangement, it is possible to execute the functional control language in a device that does not have an instruction stack and a data stack (for example, a device that executes procedural instruction processing).

11 関数型言語(FCL)格納装置
12 二次元構造(ツリー)変換部
13 二次元構造格納装置
14 関数名−インスタンス名作成部
15 命令並び換え部
16 手続型言語格納装置
DESCRIPTION OF SYMBOLS 11 Functional language (FCL) storage device 12 Two-dimensional structure (tree) conversion unit 13 Two-dimensional structure storage device 14 Function name-instance name creation unit 15 Instruction rearrangement unit 16 Procedural language storage device

Claims (6)

関数型言語で記述された制御処理プログラムを手続型の命令処理を行なう装置で実行可能な言語形式に変換する言語変換装置において、
関数型言語の命令/変数オペランドの各要素の配列を記憶した関数型言語記憶部と、
前記配列の各要素を取得し、その各要素のうちで前記命令に対応する関数および前記変数オペランドをノードとしたツリー構造を作成し、該ツリー構造を記憶するツリー構造記憶部に出力するツリー構造作成部と、
前記ツリー構造中の子供ノードを持たないノードであるリーフ以外のノードにインスタンス名を付与するインスタンス名付与部と、
前記インスタンス名を付与されたツリー構造に対して、子供ノードがリーフしかないノードを見つけ、そのノードに記述された関数を呼び出し、その呼び出した結果の代入文を、代入先をそのノードに付与されたインスタンス名として作成し、手続型言語の命令群を記憶する手続型言語記憶部に出力する代入文作成部と、
前記手続型言語記憶部に出力したノードの子供ノードのすべてを前記ツリー構造中から削除する削除処理部と、を有し、
前記ツリー構造が1つのノードになるまで、前記代入文作成部による処理および前記削除処理部による処理を繰り返すことを特徴とする言語変換装置。
In a language conversion device that converts a control processing program described in a functional language into a language format executable by a device that performs procedural instruction processing,
A functional language storage unit storing an array of each element of a functional language instruction / variable operand;
A tree structure that obtains each element of the array, creates a tree structure having the function corresponding to the instruction and the variable operand among the elements as nodes, and outputs the tree structure to a tree structure storage unit that stores the tree structure The creation department;
An instance name giving unit that gives an instance name to a node other than a leaf that is a node having no child nodes in the tree structure;
For the tree structure given the instance name, find a node whose child node has only a leaf, call the function described in that node, and assign the assignment statement of the call result to the node. An assignment statement creation unit that creates an instance name and outputs it to a procedural language storage unit that stores a procedural language instruction group;
A deletion processing unit that deletes all child nodes of the node output to the procedural language storage unit from the tree structure;
The language conversion device, wherein the processing by the assignment statement creation unit and the processing by the deletion processing unit are repeated until the tree structure becomes one node.
前記ノードは、ノード名称、呼び出し元の関数がその引数をポイントするときに使用する子供ノードへのポインタ、呼び出し元の関数が同一である引数間において次の引数をポイントするときに使用する次ノードへのポインタの各項目を有し、
前記ツリー構造作成部は、前記関数型言語記憶部の配列から、関数を読み出したときに、その関数の名称をノード名称に持つノードを新規作成し、その新規作成したノードを現在処理中ノードとし、
前記関数型言語記憶部の配列から、オペランドを読み出したときに、そのオペランドの名称をノード名称に持つノードを新規作成し、その新規作成したノードを現在処理中ノードとし、その新規作成したノードの子供ノードへのポインタを無効とし、
前記関数型言語記憶部の配列から、関数終了子を読み出したときに、そのときの現在処理中ノードの次ノードへのポインタを無効とし、その終了した関数のノードを現在処理中ノードとすることを、前記関数型言語記憶部の配列から要素を読み出す度に実行する、ことを特徴とする請求項1記載の言語変換装置。
The node is a node name, a pointer to a child node used when the calling function points to the argument, and a next node used when pointing to the next argument between arguments having the same calling function. Each item with a pointer to
When the tree structure creation unit reads a function from the array of the functional language storage unit, the tree structure creation unit newly creates a node having the name of the function as a node name, and sets the newly created node as a currently processing node. ,
When an operand is read from the array of the functional language storage unit, a node having the name of the operand as a node name is newly created, and the newly created node is set as a currently processing node, and the newly created node Invalidate the pointer to the child node,
When a function terminator is read from the array of the functional language storage unit, the pointer to the next node of the current processing node at that time is invalidated, and the node of the completed function is set as the current processing node. The language conversion device according to claim 1, wherein the language conversion device is executed every time an element is read from the array of the functional language storage unit.
前記ツリー構造作成部は、
現在処理中ノードが関数に対応したものであり、かつ、前記新規作成したノードが関数に対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードがオペランドに対応したものであり、かつ、前記新規作成したノードがオペランドに対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードがオペランドに対応したものであり、かつ、前記新規作成したノードが関数に対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードが関数に対応したものであり、かつ、前記新規作成したノードがオペランドに対応したもののときに、前記新規作成したノードの子供ノードへのポインタを無効とする、ことを特徴とする請求項2記載の言語変換装置。
The tree structure creation unit
When the node currently being processed corresponds to a function, and the newly created node corresponds to a function, the pointer to the next node of the newly created node is invalidated,
When the currently processed node corresponds to an operand and the newly created node corresponds to an operand, the pointer to the next node of the newly created node is invalidated,
When the node currently being processed corresponds to an operand, and the newly created node corresponds to a function, the pointer to the next node of the newly created node is invalidated,
A pointer to a child node of the newly created node is invalidated when the node currently being processed corresponds to a function and the newly created node corresponds to an operand. The language conversion device according to claim 2.
関数型言語で記述された制御処理プログラムを手続型の命令処理を行なう装置で実行可能な言語形式に変換する処理を、関数型言語の命令/変数オペランドの各要素の配列を記憶した関数型言語記憶部と、手続型言語の命令群を記憶する手続型言語記憶部とを有する言語変換装置に実行させるプログラムにおいて、
前記関数型言語記憶部の配列の各要素を取得し、その各要素のうちで前記命令に対応する関数および前記変数オペランドをノードとしたツリー構造を作成し、該ツリー構造を記憶するツリー構造記憶部に出力するツリー構造作成ステップと、
前記ツリー構造中の子供ノードを持たないノードであるリーフ以外のノードにインスタンス名を付与するインスタンス名付与ステップと、
前記インスタンス名を付与されたツリー構造に対して、子供ノードがリーフしかないノードを見つけ、そのノードに記述された関数を呼び出し、その呼び出した結果の代入文を、代入先をそのノードに付与されたインスタンス名として作成し、前記手続型言語記憶部に出力する代入文作成ステップと、
前記手続型言語記憶部に出力したノードの子供ノードのすべてを前記ツリー構造中から削除する削除処理ステップと、を有し、
前記ツリー構造が1つのノードになるまで、前記代入文作成ステップおよび前記削除処理ステップを繰り返すことを特徴とする言語変換プログラム。
A functional language that stores an array of elements of instruction / variable operands in a functional language to convert a control processing program written in a functional language into a language format that can be executed by a device that performs procedural instruction processing In a program to be executed by a language conversion device having a storage unit and a procedural language storage unit that stores a procedural language instruction group,
A tree structure storage that obtains each element of the array of the functional language storage unit, creates a tree structure with the function corresponding to the instruction and the variable operand as a node among the elements, and stores the tree structure Tree structure creation step to output to
An instance name giving step for giving an instance name to a node other than a leaf that is a node having no child nodes in the tree structure;
For the tree structure given the instance name, find a node whose child node has only a leaf, call the function described in that node, and assign the assignment statement of the call result to the node. Creating an assigned instance name and outputting it to the procedural language storage unit,
A deletion processing step of deleting all child nodes of the node output to the procedural language storage unit from the tree structure,
A language conversion program characterized by repeating the assignment statement creation step and the deletion processing step until the tree structure becomes one node.
前記ノードは、ノード名称、呼び出し元の関数がその引数をポイントするときに使用する子供ノードへのポインタ、呼び出し元の関数が同一である引数間において次の引数をポイントするときに使用する次ノードへのポインタの各項目を有し、
前記ツリー構造作成ステップにおいて、前記関数型言語記憶部の配列から、関数を読み出したときに、その関数の名称をノード名称に持つノードを新規作成し、その新規作成したノードを現在処理中ノードとし、
前記関数型言語記憶部の配列から、オペランドを読み出したときに、そのオペランドの名称をノード名称に持つノードを新規作成し、その新規作成したノードを現在処理中ノードとし、その新規作成したノードの子供ノードへのポインタを無効とし、
前記関数型言語記憶部の配列から、関数終了子を読み出したときに、そのときの現在処理中ノードの次ノードへのポインタを無効とし、その終了した関数のノードを現在処理中ノードとすることを、前記関数型言語記憶部の配列から要素を読み出す度に実行する、ことを特徴とする請求項4記載の言語変換プログラム。
The node is a node name, a pointer to a child node used when the calling function points to the argument, and a next node used when pointing to the next argument between arguments having the same calling function. Each item with a pointer to
In the tree structure creation step, when a function is read from the array of the functional language storage unit, a node having the name of the function as a node name is newly created, and the newly created node is set as a currently processing node. ,
When an operand is read from the array of the functional language storage unit, a node having the name of the operand as a node name is newly created, and the newly created node is set as a currently processing node, and the newly created node Invalidate the pointer to the child node,
When a function terminator is read from the array of the functional language storage unit, the pointer to the next node of the current processing node at that time is invalidated, and the node of the completed function is set as the current processing node. 5. The language conversion program according to claim 4, which is executed every time an element is read from the array of the functional language storage unit.
さらに、前記ツリー構造作成ステップにおいて、
現在処理中ノードが関数に対応したものであり、かつ、前記新規作成したノードが関数に対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードがオペランドに対応したものであり、かつ、前記新規作成したノードがオペランドに対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードがオペランドに対応したものであり、かつ、前記新規作成したノードが関数に対応したもののときに、前記新規作成したノードの次ノードへのポインタを無効とし、
現在処理中ノードが関数に対応したものであり、かつ、前記新規作成したノードがオペランドに対応したもののときに、前記新規作成したノードの子供ノードへのポインタを無効とする、ことを特徴とする請求項5記載の言語変換プログラム。
Furthermore, in the tree structure creation step,
When the node currently being processed corresponds to a function, and the newly created node corresponds to a function, the pointer to the next node of the newly created node is invalidated,
When the currently processed node corresponds to an operand and the newly created node corresponds to an operand, the pointer to the next node of the newly created node is invalidated,
When the node currently being processed corresponds to an operand, and the newly created node corresponds to a function, the pointer to the next node of the newly created node is invalidated,
A pointer to a child node of the newly created node is invalidated when the node currently being processed corresponds to a function and the newly created node corresponds to an operand. The language conversion program according to claim 5.
JP2010254254A 2010-11-12 2010-11-12 Language conversion device and language conversion program Active JP5541102B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2010254254A JP5541102B2 (en) 2010-11-12 2010-11-12 Language conversion device and language conversion program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2010254254A JP5541102B2 (en) 2010-11-12 2010-11-12 Language conversion device and language conversion program

Publications (2)

Publication Number Publication Date
JP2012104065A JP2012104065A (en) 2012-05-31
JP5541102B2 true JP5541102B2 (en) 2014-07-09

Family

ID=46394342

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2010254254A Active JP5541102B2 (en) 2010-11-12 2010-11-12 Language conversion device and language conversion program

Country Status (1)

Country Link
JP (1) JP5541102B2 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5966801B2 (en) * 2012-09-19 2016-08-10 富士電機株式会社 Language converter, program
CN109992259B (en) * 2019-04-15 2020-10-30 成都四方伟业软件股份有限公司 Function dynamic creating method and device and electronic equipment
CN112269610A (en) * 2020-10-26 2021-01-26 南京燚麒智能科技有限公司 Method and device for executing batch model algorithm

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05289712A (en) * 1992-04-08 1993-11-05 Fuji Electric Co Ltd Language converting device
JP3164730B2 (en) * 1994-04-28 2001-05-08 富士電機株式会社 Tabular circuit description generator and method
JPH07334388A (en) * 1994-06-07 1995-12-22 Fuji Electric Co Ltd Debugging device for function type information processor

Also Published As

Publication number Publication date
JP2012104065A (en) 2012-05-31

Similar Documents

Publication Publication Date Title
US7739696B2 (en) Message translation systems and methods
CN106648662B (en) Report generation device and method based on project cost calculation description language BCL
JP5541102B2 (en) Language conversion device and language conversion program
CN108170435A (en) A kind of source code conversion method, device and equipment
CN115562629A (en) RPA flow representation method, system, device and storage medium
JP2009181446A (en) Program generating device and block diagram generating apparatus
CN105204837A (en) Realizing method and device for logic programming
JP5966801B2 (en) Language converter, program
JP5664237B2 (en) XML processing apparatus, XML processing method, and XML processing program
CN106610898B (en) A kind of generation method of the Java code SSA single path based on JPF
JP2009163662A (en) Information processor, control method of information processor, and control program of information processor
WO2010095004A1 (en) Priority search trees
JP6175306B2 (en) Control program dividing apparatus, control program dividing method and recording medium therefor
JP6502044B2 (en) Data analysis device, data analysis method, and program.
JP7059757B2 (en) API processing method, terminal, API processing program
JP6402639B2 (en) Language converter
JP5100220B2 (en) XML document conversion apparatus, XML document restoration apparatus, and XML document processing apparatus
US20020143511A1 (en) Method and computer program product for system design support
Barros et al. From non-autonomous Petri net models to executable state machines
JP6376138B2 (en) Information conversion apparatus, information conversion system, and information conversion method
Ramamoorthy et al. Compilation techniques for recognition of parallel processable tasks in arithmetic expressions
See et al. Development of LLVM compilation toolchain for IoT processor targeting wireless measurement applications
CN116483597B (en) Data sharing method, device, equipment and storage medium
JP2014157384A (en) Parallelization design support system, program, and method
JPS6022373B2 (en) Program conversion mechanism for programmable control equipment

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20131011

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20140318

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: 20140408

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20140421

R150 Certificate of patent or registration of utility model

Ref document number: 5541102

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

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

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250