# This file quite literally tells RTML the "rules" governing the TML document structure. You could modify this file
# if you are directly inventing a TML-ish language of your own, but otherwise it's probably best to leave this file
# as it is, or else you are at risk of generating invalid TML.
#
# Was going to store all of this in the DB, but decided it's probably better for everyone to just static load it.
# Might revisit this someday, but for now, whatever.

tags %W{
  a baddata base br call_func card col colgroup dd defaults display div dl dt econn error form getvar h1 h2 h3 h4 h5
  h6 head hr img input layout li link log logdcl logrec next ol p pinentry postvar pre print prompt screen setvar span
  strtemplate submit submit_log table tbody td textarea tfoot tform th thead tml tmlpost tr ul vardcl variant
}

root :tml
order do
  head :base, :link, :defaults, :error
  logdcl :vardcl, :layout
  screen :setvar, :strtemplate, :logrec, :next, :error, :call_func, :display, :print, :submit, :tform
  submit :econn, :getvar, :submit_log
  table :col, :colgroup, :thead, :tfoot, :tbody, :tr
  tform :baddata, :card, :prompt, :pinentry
  tml :head, :vardcl, :logdcl, :screen
end
children :layout, all_tag_names - [:form]
children :print, %W{div dl h1 h2 h3 h4 h5 h6 hr img log ol p pre table ul form}
children :display, %W{a br div dl form getvar h1 h2 h3 h4 h5 h6 hr img input log ol p pre span table textarea ul}
children :p, %W{a br getvar input span textarea}
children do
  a :img
  baddata %W{a br div dl h1 h2 h3 h4 h5 h6 hr img getvar ol p pre span table ul}
  colgroup :col
  dd %W{a br span getvar input textarea div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul form}
  div %W{a br div dl form getvar h1 h2 h3 h4 h5 h6 hr img input ol p pre span table textarea ul}
  dl %W{dt dd}, :minimum => 1 #dt+ dd+
  dt %W{a br div dl form getvar h1 h2 h3 h4 h5 h6 hr img input ol p pre span table textarea ul}
  econn :variant #variant*
  error :variant #variant*
  form %W{div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul input textarea}
  h1 %W{a br getvar input span textarea}
  h2 %W{a br getvar input span textarea}
  h3 %W{a br getvar input span textarea}
  h4 %W{a br getvar input span textarea}
  h5 %W{a br getvar input span textarea}
  h6 %W{a br getvar input span textarea}
  head %W{base defaults error}, :minimum => 0, :maximum => 1 #base?, defaults?, error?
  head :link # link*
  input :baddata, :minimum => 0, :maximum => 1
  li %W{a br span getvar input textarea div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul form}
  log %W{vardcl layout}
  send :next, %W{variant}
  ol :li
  pre %W{a br getvar input span textarea}
  prompt %W{div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul}
  screen %W{setvar strtemplate logrec}
  screen %W{next error call_func display print submit tform}, :maximum => 1
  span %W{a br span getvar input textarea}
  strtemplate :getvar, :minimum => 0, :maximum => 9
  submit :econn, :maximum => 1
  submit %W{getvar submit_log}
  table %W{col colgroup tbody tr}
  table %W{thead tfoot}, :maximum => 1
  tbody :tr
  td %W{a br span getvar input textarea div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul form dd display li print td
        th}
  textarea :baddata, :maximum => 1
  tfoot :tr
  tform %W{baddata prompt}, :maximum => 1
  tform :card
  tform :pinentry, :maximum => 1
  th %W{a br span getvar input textarea div dl h1 h2 h3 h4 h5 h6 hr img ol p pre table ul form dd display li print td
        th}
  thead :tr
  tml :head, :maximum => 1
  tml %W{vardcl logdcl screen}
  tmlpost :postvar
  tr :th, :td
  ul :li
  variant :li
end

freeze # prevent further modification of the rules