<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roundtrip to Shanghai via Tokyo &#187; src2xml</title>
	<atom:link href="http://kohei.us/tag/src2xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohei.us</link>
	<description>Kohei Yoshida&#039;s Webspace</description>
	<lastBuildDate>Tue, 22 May 2012 04:18:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Hack Week: Day 5 (Friday) &#8211; The last day</title>
		<link>http://kohei.us/2007/06/30/hack-week-day-5-friday-the-last-day/</link>
		<comments>http://kohei.us/2007/06/30/hack-week-day-5-friday-the-last-day/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 05:26:51 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[hack week]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[novell]]></category>
		<category><![CDATA[src2xml]]></category>

		<guid isPermaLink="false">http://blog.kohei.us/2007/06/30/hack-week-day-5-friday-the-last-day/</guid>
		<description><![CDATA[Well, today was the last day of Hack Week, but unfortunately I wasn&#8217;t able to squish the remaining 20% unconverted resource files like I planned to do yesterday. I squished only 5%. This brings my conversion success rate from yesterday&#8217;s &#8230; <a href="http://kohei.us/2007/06/30/hack-week-day-5-friday-the-last-day/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, today was the last day of Hack Week, but unfortunately I wasn&#8217;t able to squish the remaining 20% unconverted resource files like I planned to do yesterday.  I squished only 5%.  This brings my conversion success rate from yesterday&#8217;s 80% to 85%.  I&#8217;m pretty happy with this result, however, considering that some of those resource files I tried to convert are not even dialog resource files.</p>
<p>Here is what I did today:</p>
<ul>
<li>Fixed incorrect expansion of preprocessing macros.  It just didn&#8217;t do the right thing when performing recursive macro expansion.  This time I really got it right, but it consumed the majority of today&#8217;s hacking time. :-(</li>
<li>Reworked my expression evaluation code to fully support the reverse Polish notation (RPN).  The absence of this feature caused a parse failure on some files because the position and the size of some widgets are given as a mathematical expression (e.g. (24 + 10)/2) instead of a single number.  I got the RPN parser to work, but then I realized that I could have just used Python&#8217;s builtin <code>eval</code> function to evaluate a whole expression in one step.  Well, duh!  I learned how to code the RPN builder to evaluate an expression, though, which was fun exercise.</li>
</ul>
<p>So, this concludes this week&#8217;s Novell Hack Week event.  It was certainly fun, although I couldn&#8217;t do everything I wanted to do.  I&#8217;ll be back to my normal hacking activities on next Monday.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/06/30/hack-week-day-5-friday-the-last-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hack Week: Day 4 (Thursday) &#8211; The joy of preprocessing macros (not!)</title>
		<link>http://kohei.us/2007/06/29/hack-week-day-4-thursday-the-joy-of-preprocessing-macros-not/</link>
		<comments>http://kohei.us/2007/06/29/hack-week-day-4-thursday-the-joy-of-preprocessing-macros-not/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 14:25:49 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[hack week]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[novell]]></category>
		<category><![CDATA[src2xml]]></category>

		<guid isPermaLink="false">http://blog.kohei.us/2007/06/29/hack-week-day-4-thursday-the-joy-of-preprocessing-macros-not/</guid>
		<description><![CDATA[Well, I didn&#8217;t have much huge achievement yesterday &#8211; day 4 of our Novell&#8217;s Hack Week. But here is a list of things I&#8217;ve done to improve the robustness of the converter script. Added support to (semi-)correctly parse the preprocessing &#8230; <a href="http://kohei.us/2007/06/29/hack-week-day-4-thursday-the-joy-of-preprocessing-macros-not/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well, I didn&#8217;t have much huge achievement yesterday &#8211; day 4 of our Novell&#8217;s Hack Week.  But here is a list of things I&#8217;ve done to improve the robustness of the converter script.</p>
<ul>
<li>Added support to (semi-)correctly parse the preprocessing macros, both ones that take no arguments and ones that <em>do</em> take arguments, as well as ones that include other macros recursively.</li>
<li>Added support to parse header files, without which many preprocessing macros would be left undefined, thus causing a parse failure.</li>
<li>Added arithmetic support, again in the preprocessing macros.</li>
<li>Numerous bug fixes that were uncovered while working on the preprocessing macro support, as well as some re-write of the algorithms to make them work better.</li>
</ul>
<p>My conclusion?  <strong>Preprocessing macros are evil!</strong>  Since macros are expanded before the source file is parsed, it has its own syntax rules that are different from the host language.  A simple expansion is rather easy, but once they start taking arguments, recursively using other macros (or the combination of the two), things become a bit tricky.  Anyway, the worst is over I hope&#8230;</p>
<p>With this improvement, I can now correctly convert 80% of all of the src files we have in our OO.o source tree.  Hopefully I can squish the remaining 20% today.</p>
<p>To recap (for those who missed my previous Hack Week posts), I am working on writing a .src to .xml converter script to migrate the existing dialog resource files (which are statically designed) to new xml format that has layout information.  The new xml files will be used as a starting point for re-designing all our existing dialogs for the new dialog layout engine in development.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/06/29/hack-week-day-4-thursday-the-joy-of-preprocessing-macros-not/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hack Week: .src converter to convert ~700 .src files</title>
		<link>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/</link>
		<comments>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/#comments</comments>
		<pubDate>Thu, 28 Jun 2007 05:21:03 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[hack week]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[novell]]></category>
		<category><![CDATA[openoffice.org]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[src2xml]]></category>

		<guid isPermaLink="false">http://blog.kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/</guid>
		<description><![CDATA[So, after some discussion with Ricardo, I have decided to take on the task of writing a converter script to convert ~700 .src files into xml files, which will be used as a starting point for re-designing each and every &#8230; <a href="http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, after some discussion with Ricardo, I have decided to take on the <a href="http://wiki.services.openoffice.org/wiki/VCL_UI_Rework#.src_converter">task of writing a converter script to convert ~700 .src files into xml files</a>, which will be used as a starting point for re-designing each and every dialog for the new dialog layout engine.  I was initially thinking about working on the dialog editor, but sounds like Ricardo has it under control.  So better not mess with that. :-)</p>
<p>When writing a converter script, it of course involves parsing a source file in order to generate output.  Typically there are two ways to go about this.</p>
<ol>
<li> Parse the source file partially for just the information you need using a flat search, and ignore the rest, or</li>
<li>Parse the source file fully according to the syntax of the language, using a lexer-parser pattern.</li>
</ol>
<p>The advantage of the first method is simplicity; it&#8217;s pretty easy to set up a simple regexp-based parser and start parsing.  The disadvantage of it is that, once the parsing need grows, as you need to pick up more and more information, the parser code becomes complex with full of special case handling, and eventually requires a total re-write.  Good luck with extending such code as the need grows even further.</p>
<p>The second method, while it takes a little upfront effort, is extensible once the framework is set up, and the code usually becomes better structured with only a minimum special case handling if designed correctly.  This method is also well-suited for parsing a token-based language, where whitespace and linebreak characters are only for syntactic sugar and does not affect its semantics.   For example, C/C++ and Java are token-based, while Python is not.  Since the syntax of the src files is very similar to that of C, I&#8217;ve decided to use the second method for this task.</p>
<p>I spent yesterday and today writing this converter script from scratch (in Python), and I&#8217;ve come to a point where it parses a large number of src files and correctly generate their xml output files.  Here is one example case.</p>
<p><strong>The source file:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: crnrdlg.src,v $
 *
 *  $Revision: 1.44 $
 *
 *  last change: $Author: ihi $ $Date: 2007/04/19 16:36:48 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/</span>
<span style="color: #339933;">#include &quot;crnrdlg.hrc&quot;</span>
ModelessDialog RID_SCDLG_COLROWNAMERANGES
<span style="color: #009900;">&#123;</span>
    OutputSize <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    Hide <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    SVLook <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">256</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">181</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
    HelpId <span style="color: #339933;">=</span> HID_COLROWNAMERANGES <span style="color: #339933;">;</span>
    Moveable <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// Closeable = TRUE;   // Dieser Dialog hat einen Cancel-Button !</span>
    FixedLine FL_ASSIGN
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">6</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">3</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">188</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Range&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ListBox LB_RANGE
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">85</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        VScroll <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Edit ED_AREA
    <span style="color: #009900;">&#123;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">105</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">165</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">12</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ImageButton RB_AREA
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">104</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">13</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">15</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> FALSE <span style="color: #339933;">;</span>
        QuickHelpText <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    RadioButton BTN_COLHEAD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">20</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">121</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">171</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Contains ~column labels&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    RadioButton BTN_ROWHEAD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">20</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">135</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">171</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">10</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Contains ~row labels&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    FixedText FT_DATA_LABEL
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">151</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;For ~data range&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Edit ED_DATA
    <span style="color: #009900;">&#123;</span>
        Border <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">12</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">162</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">165</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">12</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    ImageButton RB_DATA
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">179</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">161</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">13</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">15</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> FALSE <span style="color: #339933;">;</span>
        QuickHelpText <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    OKButton BTN_OK
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">6</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    CancelButton BTN_CANCEL
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">23</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    PushButton BTN_ADD
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">104</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;~Add&quot;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
        DefButton <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    PushButton BTN_REMOVE
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">122</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;~Delete&quot;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    HelpButton BTN_HELP
    <span style="color: #009900;">&#123;</span>
        Pos <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">200</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">43</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        Size <span style="color: #339933;">=</span> MAP_APPFONT <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">50</span> <span style="color: #339933;">,</span> <span style="color: #0000dd;">14</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
        TabStop <span style="color: #339933;">=</span> TRUE <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    Text <span style="color: #009900;">&#91;</span> en<span style="color: #339933;">-</span>US <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Define Label Range&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and here is the output after the conversion:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modeless-dialog</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;181&quot;</span> <span style="color: #000066;">help-id</span>=<span style="color: #ff0000;">&quot;HID_COLROWNAMERANGES&quot;</span> <span style="color: #000066;">hide</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">moveable</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">output-size</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">sv-look</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Define Label Range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;256&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://openoffice.org/2007/layout&quot;</span> <span style="color: #000066;">xmlns:cnt</span>=<span style="color: #ff0000;">&quot;http://openoffice.org/2007/layout/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;vbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed-line</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;FL_ASSIGN&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;188&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;6&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;3&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ok-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_OK&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list-box</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;LB_RANGE&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;85&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">vscroll</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;14&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cancel-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_CANCEL&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;23&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;help-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_HELP&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;43&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;hbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;RB_AREA&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">quick-help-text</span>=<span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;13&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;104&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;push-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_ADD&quot;</span> <span style="color: #000066;">def-button</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;~Add&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;104&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/hbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;edit</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ED_AREA&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;165&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;105&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;radio-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_COLHEAD&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Contains ~column labels&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;171&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;121&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;push-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_REMOVE&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;14&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;~Delete&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;122&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;radio-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;BTN_ROWHEAD&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Contains ~row labels&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;171&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;20&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;135&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed-text</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;FT_DATA_LABEL&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;8&quot;</span> <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;For ~data range&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;151&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;image-button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;RB_DATA&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">quick-help-text</span>=<span style="color: #ff0000;">&quot;Shrink&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;13&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;179&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;161&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;edit</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ED_DATA&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">tab-stop</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;165&quot;</span> <span style="color: #000066;">x</span>=<span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #000066;">y</span>=<span style="color: #ff0000;">&quot;162&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/vbox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modeless-dialog<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>These are the steps I take to convert each file.  First, the source file is read character-by-character to get tokenized by the lexer class, and this is where the comments (both multi-line and single line) get stripped out and the preprocessing macros are defined.  The tokens are then passed to the parser class to build a syntax tree (preprocessor macros are expanded here), which is then converted into an intermediate XML tree with names translated and some attribute types converted properly, such as the position and the size, which are originally given as MAP_APPFONT( a, b ) format.  Also, some unnecessary information is discarded at this stage.</p>
<p>Once that&#8217;s done, it further translates the intermediate XML tree into another XML tree that has layout elements.  The X and Y positions of each widget are used in order to layout the widgets properly by wrapping them with &lt;vbox&gt; and &lt;hbox&gt; elements as needed.  The tree is then dumped into a stream of text, which is what you see above.</p>
<p>Unfortunately this task is not done yet.  As it turns out, some src files even require inclusion of header files in order to be parsed correctly, which means I need to honor those <code>#include "foo.hrc"</code> header include directives.   Right now, they are ignored.  On top of that, there may also be cases where the <code>#ifdef</code> directives might need to be interpreted correctly, but so far ignoring them has not caused any side-effect.</p>
<p>I&#8217;m sure there are other problems I&#8217;ll encounter as I parse more src files, but I&#8217;d say the end is near. :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/06/28/hack-week-src-converter-to-convert-700-src-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

