Source code translating method, recording medium containing...

Data processing: software development – installation – and managem – Software program development tool – Translation of code

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C717S142000, C717S143000, C717S137000

Reexamination Certificate

active

06516461

ABSTRACT:

This application is based on Patent Application No. 2000-15021 filed Jan. 24, 2000 in Japan, the content of which is incorporated hereinto by reference.
BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates generally to a method of translating a source code, a recording medium for containing a source code translator program, and a source code translator device, and more particularly to such method, recording medium, and device as mentioned above that may be used in conjunction with a compiler, a preprocessor, an extensible programming language implementation, a source code parsing tool, a source code translating tool, and the like.
2. Description of the Prior Art
(1) Definition of Terms
Before proceeding, the definitions for the terms that are used throughout the specification are provided, as follows:
Abstract Syntax Tree
The internal representation of a source code written in the Structured Programming Language. Representing a source code in the form of the abstract syntax tree makes it easier to parse and translate the source code than treating it as a character string.
Expression
In C, Java and like programming languages, the syntax defines constants, variables, operators, assignment expressions and the like as “expression”. The left side and right side operands of a binary operator are also defined as “expression”.
Statement
In C, Java and like programming languages, the syntax defines if-statement, while-statement, compound statement and the like as “statement”.
Expression Statement
This is the term that is used in the specifications of C, Java and like programming languages. Any expression that contains semicolon “;” is called “expression statement”. In the syntax, the expression statement is defined as one of the statements.
Separator
The separator or delimiter is a symbol that may be used with any expression to allow the expression to be treated as if it were a statement. In C, C++, Java and like programming languages, the semicolon “;” is used as a separator, for example.
Backquote Macro
In some programming languages, that enable the program itself to be operated within a given program, this is the construct that may be used to separate the program itself from that given program. In the Lisp programming language, for example, (+ x
1
) is a program code that says “Add 1 to x”. When this program code itself is to be described within a Lisp program, it may be described as (+ x
1
). A value may be embedded directly inside a program code written in backquote. For example, in LISP, ‘(+ x
2
, (+ y
1
)) means a program code described as ‘(+ x
2
), if y contains a value of 1.
Construct
Component which constructs a source code written in programming language. Variables, constants, operators, assignment expressions, if-statement, while-statement, and the like are called “construct”, for example.
(2) Prior Art
Next, a source code translator program according to the prior art is discussed. Firstly, the following discussion covers the typical conventional source code translator program that is designed to process a source code written in C or like programming language.
By definition, the source code translator program is a program that accepts a source code written in a particular language as input, and performs certain conversion processing against the input source code to produce the corresponding output source code in any language that may be the same as or different from the original language. The source code translator program is also called “preprocessor”. Generally, the source code translator program parses the construct of the input source code, and converts the source code into the internal representation that makes the subsequent translation process easier. In many cases, this internal representation has a tree structure, which is known as the “Abstract Syntax Tree”.
In the prior art, when a source code containing any expression statements is represented as the abstract syntax tree, the abstract syntax tree may be described in a straightforward way by using nodes that represent the expression statements. Here, the expression statement refers to any expression that is followed by a semicolon “;”, which is usually found in C, for example.
Now, the expression statement is discussed in a little more detail.
In the C language, and other languages, such as C++ and Java, that are similar in the syntax rules to C, the statement and the expression are distinguished from each other. For example, “x”, “0”, “x+1”, and “x=0” are an expression, respectively, whereas if-statement and while-statement are statements. In C, any expression followed by “;” is usually treated as a statement. This may be called the expression statement. For example, “x=0;” is an expression statement, which is considered as a statement.
To provide a better understanding of the prior art, consider a specific case for a simple language where the syntax is defined by BNF (Backus-Naur Form), as shown below:
statement ::= if-statement | expression-statement
if-statement ::= “if” “(“expression”)” statement
“else” statement
expression-statement ::= expression“;”
expression ::= equality-comparison | assignment |
variable | constant
equality comparison ::= expression “==” expression
assignment ::= expression “=” expression
FIG. 1
depicts the abstract syntax tree that may be represented according to the prior art.
FIG. 1
shows how the following program code written in the above simple language,
if (x==0) y=0; else y=1;
may be represented as the abstract syntax tree by using the prior art.
FIGS. 2 through 6
show a recursive algorithm according to the prior art that converts an abstract syntax tree into an appropriate character string for output. Specifically,
FIG. 2
is a flowchart showing the steps in a typical prior art procedure for translating the abstract syntax tree into a character string.
FIG. 3
is a flowchart showing the steps in a typical prior art procedure for producing an if-statement as output.
FIG. 4
is a flowchart showing the steps in a typical prior art procedure for producing an “expression statement” as output.
FIG. 5
is a flowchart showing the steps in a typical prior art procedure for producing an “equality comparison” as output.
FIG. 6
is a flowchart showing the steps in a typical prior art procedure for producing an “assignment” as output. Now, those procedures are described below as they are related to the abstract syntax tree shown in FIG.
1
.
The process starts with invoking the “Procedure for Outputting an Abstract Syntax Tree” shown in FIG.
2
. The abstract syntax tree being processed corresponds to the abstract syntax tree T
11
in FIG.
1
. The procedure in
FIG. 2
takes a branch, depending on the type of the root node in the abstract syntax tree being processed. Since the root node in the abstract syntax tree T
11
is if-statement, a branch occurs to invoke the “Procedure for Producing “if” Statement”(Step S
21
).
In the “Procedure for Producing “if” Statement” in
FIG. 3
, a string “if (” is first produced (Step S
31
). To output “x==0” contained in the first occurrence of the subtree, the “Procedure for Outputting an Abstract Syntax Tree” in
FIG. 2
is recursively invoked (Step S
32
). Then, an output string of “)” is obtained (Step S
33
). Then, to output “y=0;” contained in the second occurrence of the subtree, the “Procedure for Outputting an Abstract Syntax Tree” in
FIG. 2
is recursively invoked (Step S
34
). Then, an output string “else” is obtained (Step S
35
). Finally, to output “y=1;” contained in the third occurrence of the subtree, the “Procedure for Outputting an Abstract Syntax Tree” in
FIG. 2
is recursively invoked (Step S
36
). Then, the procedure in
FIG. 3
ends, returning to the step that invoked this procedure.
Specifically, the steps S
32
, S
34
and S
36
recursively invoking the procedure in
FIG. 2
are

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Source code translating method, recording medium containing... does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Source code translating method, recording medium containing..., we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Source code translating method, recording medium containing... will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-3133333

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.