[antlr-interest] Grammar file for HTML template
Jun Lu
laomao at jaxwiki.net
Wed Sep 6 19:42:35 PDT 2006
Hi,
I am thinking to start an open source project of PhpBB Java clone. I
want to take advantage of the available PhpBB templates, languages and
images.
One problem is how to convert phpBB templates into some form of Java
or JSP. A sample template (tpl file) is attached below.
There are 3 patterns I need to deal with.
1. variables: {[A-Z_]+} : replaced with a bean property
2. loop: <!-- BEGIN [a-z_]+_rows --> .... <!-- END [a-z_]+_rows -->
: replaced with array of beans
3. condition: <!-- BEGIN switch_[a-z_]+ --> ... <!-- END
switch_[a-z_]+ --> : replaced with "if (..)"
I am new to Antlr. I am not sure if this makes sense.
Can anyone help me find a sample grammar file of this kind so I can
continue to work on?
Any opinions on would be appreciated.
Mao
<tr>
<th class="thHead" colspan="2">{L_ADD_A_POLL}</th>
</tr>
<tr>
<td class="row1" colspan="2"><span
class="gensmall">{L_ADD_POLL_EXPLAIN}</span></td>
</tr>
<tr>
<td class="row1"><span class="gen"><b>{L_POLL_QUESTION}</b></span></td>
<td class="row2"><span class="genmed"><input type="text"
name="poll_title" size="50" maxlength="255" class="post"
value="{POLL_TITLE}" /></span></td>
</tr>
<!-- BEGIN poll_option_rows -->
<tr>
<td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td>
<td class="row2"><span class="genmed"><input type="text"
name="poll_option_text[{poll_option_rows.S_POLL_OPTION_NUM}]"
size="50" class="post" maxlength="255"
value="{poll_option_rows.POLL_OPTION}" /></span> <input
type="submit" name="edit_poll_option" value="{L_UPDATE_OPTION}"
class="liteoption" /> <input type="submit"
name="del_poll_option[{poll_option_rows.S_POLL_OPTION_NUM}]"
value="{L_DELETE_OPTION}" class="liteoption" /></td>
</tr>
<!-- END poll_option_rows -->
<tr>
<td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td>
<td class="row2"><span class="genmed"><input type="text"
name="add_poll_option_text" size="50" maxlength="255" class="post"
value="{ADD_POLL_OPTION}" /></span> <input type="submit"
name="add_poll_option" value="{L_ADD_OPTION}" class="liteoption"
/></td>
</tr>
<tr>
<td class="row1"><span class="gen"><b>{L_POLL_LENGTH}</b></span></td>
<td class="row2"><span class="genmed"><input type="text"
name="poll_length" size="3" maxlength="3" class="post"
value="{POLL_LENGTH}" /></span> <span
class="gen"><b>{L_DAYS}</b></span> <span
class="gensmall">{L_POLL_LENGTH_EXPLAIN}</span></td>
</tr>
<!-- BEGIN switch_poll_delete_toggle -->
<tr>
<td class="row1"><span class="gen"><b>{L_POLL_DELETE}</b></span></td>
<td class="row2"><input type="checkbox" name="poll_delete" /></td>
</tr>
<!-- END switch_poll_delete_toggle -->
More information about the antlr-interest
mailing list