#
# xml parser
#

class XHTMLParser

rule
  target        : /* none */
                | xml_doc

  xml_doc       : xml_header  extra  xml_body
                | xml_header  xml_body
                | xml_body

  xml_header    : xtag_in  element  attributes  xtag_out

  xml_body      : tag_from  contents  tag_to

  tag_from      : tag_in  element  attributes  tag_out

  tag_empty     : tag_in  element  attributes  etag_out

  tag_to        : etag_in  element  tag_out

  attributes    : /* none */
                | attributes  attribute

  attribute     : attr  equal  quoted

  quoted        : quote1  value  quote1
                | quote2  value  quote2

  contents      : /* none */
                | contents  content

  content       : text
                | extra
                | tag_from  contents  tag_to
                | tag_empty

  extra         : tag_in  ext  extra_texts  tag_out

  extra_texts   : /* none */
                | extra_texts  rem_in  remtexts  rem_out
                | extra_texts  exttext

  remtexts      : remtext
                | remtexts  remtext

end

---- header ----
#
# generated by racc
#
require 'xhtmlparser.rex'
---- inner ----

---- footer ----

exit  if ARGV.size == 0
filename = ARGV.shift

htmlparser = XHTMLParser.new
htmlparser.scan_file  filename

