mheder / sztakipedia-parser

Automatically exported from code.google.com/p/sztakipedia-parser
GNU General Public License v2.0
0 stars 0 forks source link

Rewrite code to follow the Visitor design pattern #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currentyl, the *Tag classes roughly conform to an abstract syntax tree's [1] 
nodes, while the the conversion to HTML is done by the *Tag classes themselves.

This approach mixes data and presentation and would be messy to extend to more 
output languages. Therefore, the HTML generation should be separated to a 
single class following the Visitor design pattern (see HTMLTagVisitor for a 
stub).

[1] http://en.wikipedia.org/wiki/Abstract_syntax_tree
[2] http://en.wikipedia.org/wiki/Visitor_pattern#Java_example
[3] http://hillside.net/plop/plop2003/Papers/Jones-ImplementingASTs.pdf

Original issue reported on code.google.com by illes.s...@gmail.com on 21 Jul 2011 at 11:34

GoogleCodeExporter commented 9 years ago
Steps

1. Move (Ctrl-X) HTML generation code from Tag.openTag()/Tag.closeTag() methods 
to HTMLTagVisitor.visit() (see e.g. HTMLTagVisitor.visit(BoldTag)
2. replace addAttribute() and addClass() methods by core Java class attributes 
of primitive (e.g. boolean) or standard library types (e.g. Set String)
3. rename *Converter to *Interpreter
4. if all *Tag classes are simplified to "dumb" data-only classes, consider 
switching to code generation (JavaCC or SableCC (sablecc.org))
5. Consider moving all logic in the DefaultInterpreter in the JavaCC grammar

Original comment by illes.s...@gmail.com on 22 Jul 2011 at 12:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
1st and 3rd steps are completed.

Original comment by olh...@gmail.com on 29 Jul 2011 at 8:33