Recently, I written converter program with ruby, It is enable to convert a source file of c plus plus to html format.
The converter program can change tab space to span tag of html, and color keywords.
Color of keywords is blue.
Next code is converter program.
#!/usr/bin/ruby
def convertKeyWords(arg)
if(arg =~ /(<)/ ) then
arg.gsub!($1, "<")
end
if(arg =~ /(>)/ ) then
arg.gsub!($1, ">")
end
if( arg =~ /(if)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(typedef)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(class)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(using namespace)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(while)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end 
if(arg =~ /(for)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(void)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(int)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(double)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(char)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(#include)/ ) then
arg.gsub!($1, "<span style=\"color:blue;\"><b>" + $1 + "</b></span>")
end
if(arg =~ /(\/\/.*)/ ) then
arg.gsub!($1, "<span style=\"color:green;\"><b>" + $1 + "</b></span>")
end
arg
end
begin
if( ARGV[0] == nil ) then
puts " Usage: cpp2html.rb sourcefile"
puts "    Sourcefile must be cplusplus source file."
exit(1);
end
puts "<HTML>\n<HEAD>\n<TITLE>\n" + ARGV[0]+ "\n</TITLE>\n</HEAD>\n"
unless FileTest::file?(ARGV[0]) then 
puts "not file"
end
sourcefile = File.new(ARGV[0]);
comment_count = 0
indent_count = 0;
while line = sourcefile.gets() 
if (/^=begin/ =~ line) then
comment_count = 1;
next
end
if (/^=end/ =~ line) then
comment_count = 0;
next
end
next if (comment_count == 1 )
line = line.chop
next if( line.empty? )
# count indent
# Following code is error! ToDo
indent_count -= 1 if ( /\}s*$/ =~ line )
# convert from tab to style
tmp = ""
for i in 0...indent_count
tmp += "<span style=\"margin-left:20px;\">"
end
# count indent
indent_count += 1 if ( /\s*\{/ =~ line )
# converting
# check key wards
line = convertKeyWords(line)
line.gsub!(/^\s+/, tmp)
line += "<br>\n"
puts line
end
puts "</HTML>"
end
1/28/2009
1/25/2009
Default Argument
When I write define of function or method with C++, I always write next code.
I want that user of my function understand the function more easily than next code.
Above code is the same as before function used default argument.
Using Default argument, Code line decreases.
namespace my{
enum Type{
NONE = 0x00,
SCALAR = 0x01,
VECTOR = 0x03,
};
void function(double* , Type type = NONE);
}
I want that user of my function understand the function more easily than next code.
namespace my{
enum Type{
NONE = 0x00,
SCALAR = 0x01,
VECTOR = 0x03,
};
void function(double* , Type type);
void function(double*);
}
Above code is the same as before function used default argument.
Using Default argument, Code line decreases.
1/10/2009
Message Box With Gtk
I want a simple function showing Message box in gtk like Windows'API.
Therefore I make next code.
Therefore I make next code.
1/09/2009
Where is Google Chrome of Linux
I wait for the news Google ship Google Chrome on Linux.
Now, I use FireFox3.0.5 on Ubuntu8.04.
Then Google Chrome on Linux is stable, I try to use the Browser.
Since Firefox is good application, I have no dissatisfaction in Firefox.
But, I like new goods and Google!
I would like to use Google Chrome, but I don't use WindowsXP or Windows Vista.
Now, I use FireFox3.0.5 on Ubuntu8.04.
Then Google Chrome on Linux is stable, I try to use the Browser.
Since Firefox is good application, I have no dissatisfaction in Firefox.
But, I like new goods and Google!
I would like to use Google Chrome, but I don't use WindowsXP or Windows Vista.
1/08/2009
Electrical Vehicle
I found a wonderful company. 
This company make electrical vehicle, and sales it.
The electrical vehicle is named Tesla Roadstar.
Name of the company is "Tesla Motors".
Already Tesla Motors sold 100 Tesla Roadstares or more.
This fact is a wonderful thing!!
I hope that the company became success.
This company make electrical vehicle, and sales it.
The electrical vehicle is named Tesla Roadstar.
Name of the company is "Tesla Motors".
Already Tesla Motors sold 100 Tesla Roadstares or more.
This fact is a wonderful thing!!
I hope that the company became success.
Nintendo DSi
Recently, I bought a Nintendo DSi that is handy game.
Generally Nintendo DSi is famous as No1 Game console.
Then I always attend my office with it, and I gaming.
I bought two game soft for it, One is Final Fantasy3, Another classic simulation game.
Generally Nintendo DSi is famous as No1 Game console.
Then I always attend my office with it, and I gaming.
I bought two game soft for it, One is Final Fantasy3, Another classic simulation game.
1/07/2009
My Site Renewal
I have published open source, strip experiment creating triangle strip data from 3dcg data.
It is placed at this site.
Recently, I make this site renewal.
Additionally, This site allow visitor to download free 3dcg data.
It is placed at this site.
Recently, I make this site renewal.
Additionally, This site allow visitor to download free 3dcg data.
1/06/2009
Test Data
Subscribe to:
Comments (Atom)
 


