On 9 May 2007, at 15:40, Xaris wrote:

I have made the parse tree with bison of a like html language which finds if
the input file is written correctly or not.

But i want to add code in order to make an interpreter which takes as input
the like html language and as output it gives the html code.

As Satya pointed out, you might investigate similar solutions first, in order to save work. Perhaps the Usenet newsgroup comp.compilers can give you an input.

But one method is to check what semantical structures, say in the form of ASTs (Abstract Syntax Trees), the HTML language produce, and how to write them back into HTML. Then you merely parse your language into those ASTs, and write it out as HTML.

The AST differs from the parse tree in that for example parenthesizes are being removed, resulting in an operator structure. The parenthesizes can then be put back by checking the relative precedence of the operator and the argument.

For example, suppose one language uses infix notation, like A => B, and the other prefix notation, => A B, then. Both get the AST
     =>
   /   \
  A     B
And it is not difficult to write it out in either language.

  Hans Aberg




_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to