💾 Archived View for gemini.conman.org › extensions › port70 › handlers › blog › html.peg captured on 2021-12-04 at 18:04:22.

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

#########################################################################
#
# Copyright 2020 by Sean Conner.  All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# Comments, questions and criticisms can be sent to: sean@conman.org
#
########################################################################

BODY      <- flow+ !.
flow      <- block / inline

# **************************************
# INLINE tags
# **************************************

inline    <- fontstyle / phrase / special  / iINS   / formctrl / iDEL / Cinline / PCDATA
fontstyle <- TT        / I      / B        / BIG    / SMALL    / U
phrase    <- EM        / STRONG / DFN      / CODE   / SAMP     / KBD  / VAR / CITE / ABBR / ACRONYM
special   <- A         / IMG    / BR       / SCRIPT / BDO      / Q    / SUB / SUP  / SPAN / OBJECT /  FONT / MAP
formctrl  <- INPUT     / SELECT / TEXTAREA / LABEL  / BUTTON

TT        <- "<" _TT       & ET { tagi(yy,"tt");       } attrs*         S* ">" inline*           "</" _TT       ">"   { endtag(yy); }
I         <- "<" _I        & ET { tagi(yy,"i");        } attrs*         S* ">" inline*           "</" _I        ">"   { endtag(yy); }
B         <- "<" _B        & ET { tagi(yy,"b");        } attrs*         S* ">" inline*           "</" _B        ">"   { endtag(yy); }
BIG       <- "<" _BIG      & ET { tagi(yy,"big");      } attrs*         S* ">" inline*           "</" _BIG      ">"   { endtag(yy); }
SMALL     <- "<" _SMALL    & ET { tagi(yy,"small");    } attrs*         S* ">" inline*           "</" _SMALL    ">"   { endtag(yy); }
U         <- "<" _U        & ET { tagi(yy,"u");        } attrs*         S* ">" inline*           "</" _U        ">"   { endtag(yy); } # XXX non-standard
EM        <- "<" _EM       & ET { tagi(yy,"em");       } attrs*         S* ">" inline*           "</" _EM       ">"   { endtag(yy); }
STRONG    <- "<" _STRONG   & ET { tagi(yy,"strong");   } attrs*         S* ">" inline*           "</" _STRONG   ">"   { endtag(yy); }
DFN       <- "<" _DFN      & ET { tagi(yy,"dfn");      } attrs*         S* ">" inline*           "</" _DFN      ">"   { endtag(yy); }
CODE      <- "<" _CODE     & ET { tagi(yy,"code");     } attrs*         S* ">" inline*           "</" _CODE     ">"   { endtag(yy); }
SAMP      <- "<" _SAMP     & ET { tagi(yy,"samp");     } attrs*         S* ">" inline*           "</" _SAMP     ">"   { endtag(yy); }
KBD       <- "<" _KBD      & ET { tagi(yy,"kbd");      } attrs*         S* ">" inline*           "</" _KBD      ">"   { endtag(yy); }
VAR       <- "<" _VAR      & ET { tagi(yy,"var");      } attrs*         S* ">" inline*           "</" _VAR      ">"   { endtag(yy); }
CITE      <- "<" _CITE     & ET { tagi(yy,"cite");     } attrs*         S* ">" inline*           "</" _CITE     ">"   { endtag(yy); }
ABBR      <- "<" _ABBR     & ET { tagi(yy,"abbr");     } attrs*         S* ">" inline*           "</" _ABBR     ">"   { endtag(yy); }
ACRONYM   <- "<" _ACRONYM  & ET { tagi(yy,"acronym");  } attrs*         S* ">" inline*           "</" _ACRONYM  ">"   { endtag(yy); }
A         <- "<" _A        & ET { tagi(yy,"a");        } A_attr*        S* ">" (!A inline)*      "</" _A        ">"   { endtag(yy); }
IMG       <- "<" _IMG      & ET { tagi(yy,"img");      } IMG_attr*      S* ">"               (S* "</" _IMG      ">")? { endtag(yy); }
BR        <- "<" _BR       & ET { tagi(yy,"br");       } coreattrs*     S* ">"               (S* "</" _BR       ">")? { endtag(yy); }
SCRIPT    <- "<" _SCRIPT   & ET { tagi(yy,"script");   } SCRIPT_attr*   S* ">" scriptDATA        "</" _SCRIPT   ">"   { endtag(yy); }
BDO       <- "<" _BDO      & ET { tagi(yy,"bdo");      } BDO_attr*      S* ">" inline*           "</" _BDO      ">"   { endtag(yy); }
Q         <- "<" _Q        & ET { tagi(yy,"q");        } Q_attr*        S* ">" inline*           "</" _Q        ">"   { endtag(yy); }
SUB       <- "<" _SUB      & ET { tagi(yy,"sub");      } attrs*         S* ">" inline*           "</" _SUB      ">"   { endtag(yy); }
SUP       <- "<" _SUP      & ET { tagi(yy,"sup");      } attrs*         S* ">" inline*           "</" _SUP      ">"   { endtag(yy); }
SPAN      <- "<" _SPAN     & ET { tagi(yy,"span");     } attrs*         S* ">" inline*           "</" _SPAN     ">"   { endtag(yy); }
OBJECT    <- "<" _OBJECT   & ET { tagi(yy,"object");   } OBJECT_attr*   S* ">" object_flow*      "</" _OBJECT   ">"   { endtag(yy); }
PARAM     <- "<" _PARAM    & ET { tagi(yy,"param");    } PARAM_attr*    S* ">"               (S* "</" _PARAM    ">")? { endtag(yy); }
EMBED     <- "<" _EMBED    & ET { tagi(yy,"embed");    } EMBED_attr*    S* ">" inline*           "</" _EMBED    ">"   { endtag(yy); }
FONT      <- "<" _FONT     & ET { tagi(yy,"font");     } FONT_attr*     S* ">" inline*           "</" _FONT     ">"   { endtag(yy); }
MAP       <- "<" _MAP      & ET { tagi(yy,"map");      } MAP_attr*      S* ">" map_flow+         "</" _MAP      ">"   { endtag(yy); }
AREA      <- "<" _AREA     & ET { tagi(yy,"area");     } AREA_attr*     S* ">"               (S* "</" _AREA     ">")? { endtag(yy); }
INPUT     <- "<" _INPUT    & ET { tagi(yy,"input");    } INPUT_attr*    S* ">"               (S* "</" _INPUT    ">")? { endtag(yy); }
SELECT    <- "<" _SELECT   & ET { tagi(yy,"select");   } SELECT_attr*   S* ">" select_flow+      "</" _SELECT   ">"   { endtag(yy); }
TEXTAREA  <- "<" _TEXTAREA & ET { tagi(yy,"textarea"); } TEXTAREA_attr* S* ">" PCDATA*           "</" _TEXTAREA ">"   { endtag(yy); }
LABEL     <- "<" _LABEL    & ET { tagi(yy,"label");    } LABEL_attr*    S* ">" (! LABEL inline)* "</" _LABEL    ">"   { endtag(yy); }
BUTTON    <- "<" _BUTTON   & ET { tagi(yy,"button");   } BUTTON_attr*   S* ">" button_flow*      "</" _BUTTON   ">"   { endtag(yy); }
OPTGROUP  <- "<" _OPTGROUP & ET { tagi(yy,"optgroup"); } OPTGROUP_attr* S* ">" (OPTION / S)+     "</" _OPTGROUP ">"   { endtag(yy); }
OPTION    <- "<" _OPTION   & ET { tagi(yy,"option");   } OPTION_attr*   S* ">" PCDATA*           "</" _OPTION   ">"   { endtag(yy); }
iINS      <- "<" _INS      & ET { tagi(yy,"ins");      } INSDEL_attr*   S* ">" flow*             "</" _INS      ">"   { endtag(yy); }
iDEL      <- "<" _DEL      & ET { tagi(yy,"del");      } INSDEL_attr*   S* ">" flow*             "</" _DEL      ">"   { endtag(yy); }

object_flow     <- PARAM / EMBED / flow
map_flow        <- block / AREA / S
select_flow     <- OPTGROUP / OPTION / S
button_flow     <- ! (A / formctrl / FORM / FIELDSET) flow

# *************************************
# BLOCK tags
# *************************************

block       <- P    / PRE  / DL    / NOSCRIPT / BLOCKQUOTE
            /  FORM / HR   / TABLE / FIELDSET / ADDRESS
            /  H1   / H2   / H3    / H4       / H5
            /  H6   / UL   / OL    / DIV
            /  bINS / bDEL / Cblock
            
BLOCKQUOTE  <- S* "<" _BLOCKQUOTE & ET { tagb(yy,"blockquote"); } bq_attr*     S* ">" S* bq_flow+        "</" _BLOCKQUOTE ">" S*   { endtag(yy); }
P           <- S* "<" _P          & ET { tagb(yy,"p");          } attrs*       S* ">" S* inline*        ("</" _P          ">" S*)? { endtag(yy); }
HR          <- S* "<" _HR         & ET { tagb(yy,"hr");         } attrs*       S* ">" S*                ("</" _HR         ">" S*)? { endtag(yy); }
ADDRESS     <- S* "<" _ADDRESS    & ET { tagb(yy,"address");    } attrs*       S* ">" S* inline*         "</" _ADDRESS    ">" S*   { endtag(yy); }
H1          <- S* "<" _H1         & ET { tagb(yy,"h1");         } attrs*       S* ">" S* inline*         "</" _H1         ">" S*   { endtag(yy); }
H2          <- S* "<" _H2         & ET { tagb(yy,"h2");         } attrs*       S* ">" S* inline*         "</" _H2         ">" S*   { endtag(yy); }
H3          <- S* "<" _H3         & ET { tagb(yy,"h3");         } attrs*       S* ">" S* inline*         "</" _H3         ">" S*   { endtag(yy); }
H4          <- S* "<" _H4         & ET { tagb(yy,"h4");         } attrs*       S* ">" S* inline*         "</" _H4         ">" S*   { endtag(yy); }
H5          <- S* "<" _H5         & ET { tagb(yy,"h5");         } attrs*       S* ">" S* inline*         "</" _H5         ">" S*   { endtag(yy); }
H6          <- S* "<" _H6         & ET { tagb(yy,"h6");         } attrs*       S* ">" S* inline*         "</" _H6         ">" S*   { endtag(yy); }
DIV         <- S* "<" _DIV        & ET { tagb(yy,"div");        } div_attr*    S* ">" S* flow*           "</" _DIV        ">" S*   { endtag(yy); }
DL          <- S* "<" _DL         & ET { tagb(yy,"dl");         } attrs*       S* ">" S* (DT / DD)+      "</" _DL         ">" S*   { endtag(yy); }
DT          <- S* "<" _DT         & ET { tagb(yy,"dt");         } attrs*       S* ">" S* inline*        ("</" _DT         ">" S*)? { endtag(yy); }
DD          <- S* "<" _DD         & ET { tagb(yy,"dd");         } attrs*       S* ">" S* flow*          ("</" _DD         ">" S*)? { endtag(yy); }
UL          <- S* "<" _UL         & ET { tagb(yy,"ul");         } attrs*       S* ">" S* (LI / Cblock)+  "</" _UL         ">" S*   { endtag(yy); }
OL          <- S* "<" _OL         & ET { tagb(yy,"ol");         } OL_attr*     S* ">" S* (LI / Cblock)+  "</" _OL         ">" S*   { endtag(yy); }
LI          <- S* "<" _LI         & ET { tagb(yy,"li");         } attrs*       S* ">" S* flow*          ("</" _LI         ">" S*)? { endtag(yy); }
NOSCRIPT    <- S* "<" _NOSCRIPT   & ET { tagb(yy,"noscript");   } attrs*       S* ">" S* block+          "</" _NOSCRIPT   ">" S*   { endtag(yy); }
FORM        <- S* "<" _FORM       & ET { tagb(yy,"form");       } FORM_attr*   S* ">" S* FORM_flow*      "</" _FORM       ">" S*   { endtag(yy); }
FIELDSET    <- S* "<" _FIELDSET   & ET { tagb(yy,"fieldset");   } attrs*       S* ">" S* fs_flow*        "</" _FIELDSET   ">" S*   { endtag(yy); }
LEGEND      <- S* "<" _LEGEND     & ET { tagb(yy,"legend");     } legend_attr* S* ">" S* inline*         "</" _LEGEND     ">" S*   { endtag(yy); }
TABLE       <- S* "<" _TABLE      & ET { tagb(yy,"table");      } TABLE_attr*  S* ">" S* TABLE_flow      "</" _TABLE      ">" S*   { endtag(yy); }
CAPTION     <- S* "<" _CAPTION    & ET { tagb(yy,"caption");    } attrs*       S* ">" S* inline*         "</" _CAPTION    ">" S*   { endtag(yy); }
COL         <- S* "<" _COL        & ET { tagb(yy,"col");        } col_attr*    S* ">" S*                ("</" _COL        ">" S*)? { endtag(yy); }
COLGROUP    <- S* "<" _COLGROUP   & ET { tagb(yy,"colgroup");   } col_attr*    S* ">" S* COL*           ("</" _COLGROUP   ">" S*)? { endtag(yy); }
THEAD       <- S* "<" _THEAD      & ET { tagb(yy,"thead");      } tr_attr*     S* ">" S* TR+            ("</" _THEAD      ">" S*)? { endtag(yy); }
TFOOT       <- S* "<" _TFOOT      & ET { tagb(yy,"tfoot");      } tr_attr*     S* ">" S* TR+            ("</" _TFOOT      ">" S*)? { endtag(yy); }
TR          <- S* "<" _TR         & ET { tagb(yy,"tr");         } tr_attr*     S* ">" S* (TH / TD)+     ("</" _TR         ">" S*)? { endtag(yy); }
TH          <- S* "<" _TH         & ET { tagb(yy,"th");         } THD_attr*    S* ">" S* flow*          ("</" _TH         ">" S*)? { endtag(yy); }
TD          <- S* "<" _TD         & ET { tagb(yy,"td");         } THD_attr*    S* ">" S* flow*          ("</" _TD         ">" S*)? { endtag(yy); }
bINS        <- S* "<" _INS        & ET { tagb(yy,"ins");        } INSDEL_attr* S* ">" S* flow*           "</" _INS        ">" S*   { endtag(yy); }
bDEL        <- S* "<" _DEL        & ET { tagb(yy,"del");        } INSDEL_attr* S* ">" S* flow*           "</" _DEL        ">" S*   { endtag(yy); }

        #------------------------------------------------------
        # TBODY opening and closing tag are optional.  Lovely.
        #------------------------------------------------------
        
TBODY       <- (S* "<" _TBODY & ET { tagb(yy,"tbody"); } tr_attr* S* ">" S* / { tagb(yy,"tbody"); })
               TR+
               (S* "</" _TBODY    ">" S*)? { endtag(yy); }

PRE         <- S* "<" _PRE & ET { tagb(yy,"pre"); yy->pre = true; } attrs* S* ">"
               ((" " / "\t")* "\r"? "\n")?
               PRE_flow*
               "</" _PRE ">" S* { endtag(yy); yy->pre = false; }
               
bq_flow     <- block / SCRIPT
PRE_flow    <- ! (IMG / OBJECT / BIG / SMALL / SUB / SUP) inline
FORM_flow   <- ! FORM (block / SCRIPT)
fs_flow     <- LEGEND/ flow / PCDATA
TABLE_flow  <- CAPTION? (COL / COLGROUP)* THEAD? TFOOT? TBODY+

# *******************************************
# Attributes
# *******************************************

_defval <- ( S* "=" S* _value / nil)
_value  <- '"' { luaL_buffinit(yy->L,&yy->buf); } (! '"' CHAR)* { luaL_pushresult(&yy->buf); } '"'
        /  "'" { luaL_buffinit(yy->L,&yy->buf); } (! "'" CHAR)* { luaL_pushresult(&yy->buf); } "'"
        /      { luaL_buffinit(yy->L,&yy->buf); } (! S   CHAR)* { luaL_pushresult(&yy->buf); }
        
attrs           <- coreattrs / i18n / events
coreattrs       <- attr_id / attr_class / attr_style / attr_title
i18n            <- attr_lang / attr_dir
events          <- attr_onclick    / attr_ondblclick  / attr_onmousedown
                /  attr_onmouseup  / attr_onmouseover / attr_onmousemove
                /  attr_onmouseout / attr_onkeypress  / attr_onkeydown
                /  attr_onkeyup
                
reserved        <- attr_datasrc / attr_datafld
cellhalign      <- attr_align / attr_char / attr_charoff
cellvalign      <- attr_valign

A_attr          <- attrs
                /  attr_charset  / attr_type   / attr_name     / attr_href
                /  attr_hreflang / attr_rel    / attr_rev      / attr_accesskey
                /  attr_shape    / attr_coords / attr_tabindex / attr_onfocus
                /  attr_onblur
                
IMG_attr        <- attrs
                /  attr_src    / attr_alt   / attr_longdesc / attr_name
                /  attr_height / attr_width / attr_usemap   / attr_ismap
                
BDO_attr        <- coreattrs / attr_lang / attr_dir
Q_attr          <- attrs / attr_cite
MAP_attr        <- attrs / attr_name
INSDEL_attr     <- attrs / attr_cite / attr_datetime

AREA_attr       <- attrs
                /  attr_shape     / attr_coords  / attr_href
                /  attr_nohref    / attr_alt     / attr_tabindex
                /  attr_accesskey / attr_onfocus / attr_onblur
                
FONT_attr       <- coreattrs / i18n
                /  attr_size / attr_color / attr_face
                
EMBED_attr      <- attrs
                /  attr_align
                /  attr_allowfullscreen
                /  attr_allowscriptaccess
                /  attr_bgcolor
                /  attr_flashvars
                /  attr_height
                /  attr_href
                /  attr_pluginspage
                /  attr_quality
                /  attr_src
                /  attr_type
                /  attr_width
                
PARAM_attr      <-  attr_id / attr_name / attr_value / attr_valuetype
                /   attr_type
                
OBJECT_attr     <- attrs
                /  attr_declare  / attr_classid  / attr_codebase / attr_data
                /  attr_type     / attr_codetype / attr_archive  / attr_standby
                /  attr_height   / attr_width    / attr_usemap   / attr_name
                /  attr_tabindex / reserved
                
SCRIPT_attr     <- events
                /  attr_charset / attr_type / attr_src
                /  attr_defer   / attr_for  / attr_event
                
INPUT_attr      <- attrs
                /  attr_type     / attr_name      / attr_value   / attr_checked
                /  attr_disabled / attr_readonly  / attr_size    / attr_maxlength
                /  attr_src      / attr_alt       / attr_usemap  / attr_ismap
                /  attr_tabindex / attr_accesskey / attr_onfocus / attr_onblur
                /  attr_onselect / attr_onchange  / attr_accept  / reserved
                
SELECT_attr     <- attrs
                /  attr_name     / attr_size    / attr_multiple / attr_disabled
                /  attr_tabindex / attr_onfocus / attr_onblur   / attr_onchange
                /  reserved
                
TEXTAREA_attr   <- attrs
                /  attr_name     / attr_rows     / attr_cols      / attr_disabled
                /  attr_readonly / attr_tabindex / attr_accesskey / attr_onfocus
                /  attr_onblur   / attr_onselect / attr_onchange  / reserved
                
LABEL_attr      <- attrs
                /  attr_for / attr_accesskey / attr_onfocus / attr_onblur
                
BUTTON_attr     <- attrs
                /  attr_name     / attr_value    / attr_type2
                /  attr_disabled / attr_tabindex / attr_accesskey
                /  attr_onfocus  / attr_onblur   / reserved
                
OPTGROUP_attr   <- attrs / attr_disabled / attr_label OPTION_attr <- attrs
                /  attr_selected / attr_disabled / attr_label / attr_value
                
FORM_attr       <- attrs
                /  attr_action / attr_method   / attr_enctype / attr_accept
                /  attr_name   / attr_onsubmit / attr_onreset / attr_accept_charset
                
TABLE_attr      <- attrs
                /  attr_abbr    / attr_axis    / attr_headers / attr_scope
                /  attr_rowspan / attr_colspan / cellhalign   / cellvalign
                /  attr_summary / attr_rules   / attr_frame   / attr_datapagesize
                /  attr_cellspacing / attr_cellpadding / attr_border
                
bq_attr         <- attrs / attr_cite
div_attr        <- attrs / reserved
OL_attr         <- attrs / attr_start / attr_type
legend_attr     <- attrs / attr_accesskey
col_attr        <- attrs / attr_span / attr_width / cellhalign / cellvalign
tr_attr         <- attrs / cellhalign / cellvalign

THD_attr        <- attrs
                /  attr_abbr    / attr_axis    / attr_headers / attr_scope
                /  attr_rowspan / attr_colspan / cellhalign   / cellvalign
                
ET     <- " " / "\t" / "\r" / "\n" / ">" # end tag
EA     <- " " / "\t" / "\r" / "\n" / "=" / ">" # end attribute

EQ      <- S* "=" S*

_vDIR   <- EQ ('"' _LTR '"' / "'" _LTR "'" / _LTR) { lua_pushliteral(yy->L,"ltr"); }
        /  EQ ('"' _RTL '"' / "'" _RTL "'" / _RTL) { lua_pushliteral(yy->L,"rtl"); }
        
_vALIGN <- EQ ('"' _ALIGN   '"' / "'" _ALIGN   "'" / _ALIGN  ) { lua_pushliteral(yy->L,"align");   }
        /  EQ ('"' _LEFT    '"' / "'" _LEFT    "'" / _LEFT   ) { lua_pushliteral(yy->L,"left");    }
        /  EQ ('"' _CENTER  '"' / "'" _CENTER  "'" / _CENTER ) { lua_pushliteral(yy->L,"center");  }
        /  EQ ('"' _RIGHT   '"' / "'" _RIGHT   "'" / _RIGHT  ) { lua_pushliteral(yy->L,"right");   }
        /  EQ ('"' _JUSTIFY '"' / "'" _JUSTIFY "'" / _JUSTIFY) { lua_pushliteral(yy->L,"justify"); }
        /  EQ ('"' _CHAR    '"' / "'" _CHAR    "'" / _CHAR   ) { lua_pushliteral(yy->L,"char");    }
        
_vAFS       <- EQ ('"' _TRUE '"' / "'" _TRUE "'" / _TRUE ) { lua_pushliteral(yy->L,"true"); }
            /  { lua_pushliteral(yy->L,"allowfullscreen"); }
_vCHECKED   <- EQ ('"' _CHECKED '"' / "'" _CHECKED "'" / _CHECKED) { lua_pushliteral(yy->L,"checked"); }
            /  { lua_pushliteral(yy->L,"checked"); }
_vDECLARE   <- EQ ('"' _DECLARE '"' / "'" _DECLARE "'" / _DECLARE) { lua_pushliteral(yy->L,"declare"); }
            /  { lua_pushliteral(yy->L,"declare"); }
_vDEFER     <- EQ ('"' _DEFER '"' / "'" _DEFER "'" / _DEFER) { lua_pushliteral(yy->L,"defer"); }
            /  { lua_pushliteral(yy->L,"defer"); }
_vDISABLED  <- EQ ('"' _DISABLED '"' / "'" _DISABLED "'" / _DISABLED) { lua_pushliteral(yy->L,"disabled"); }
            /  { lua_pushliteral(yy->L,"disabled"); }
            
_vFRAME     <- EQ ('"' _VOID   '"' / "'" _VOID   "'" / _VOID  ) { lua_pushliteral(yy->L,"void");   }
            /  EQ ('"' _ABOVE  '"' / "'" _ABOVE  "'" / _ABOVE ) { lua_pushliteral(yy->L,"above");  }
            /  EQ ('"' _BELOW  '"' / "'" _BELOW  "'" / _BELOW ) { lua_pushliteral(yy->L,"below");  }
            /  EQ ('"' _HSIDES '"' / "'" _HSIDES "'" / _HSIDES) { lua_pushliteral(yy->L,"hsides"); }
            /  EQ ('"' _LHS    '"' / "'" _LHS    "'" / _LHS   ) { lua_pushliteral(yy->L,"lhs");    }
            /  EQ ('"' _RHS    '"' / "'" _RHS    "'" / _RHS   ) { lua_pushliteral(yy->L,"rhs");    }
            /  EQ ('"' _VSIDES '"' / "'" _VSIDES "'" / _VSIDES) { lua_pushliteral(yy->L,"vsides"); }
            /  EQ ('"' _BOX    '"' / "'" _BOX    "'" / _BOX   ) { lua_pushliteral(yy->L,"box");    }
            /  EQ ('"' _BORDER '"' / "'" _BORDER "'" / _BORDER) { lua_pushliteral(yy->L,"border"); }
            
_vISMAP     <- EQ ('"' _ISMAP '"' / "'" _ISMAP "'" / _ISMAP) { lua_pushliteral(yy->L,"ismap"); }
            /  { lua_pushliteral(yy->L,"ismap"); }
            
_vMETHOD    <- EQ ('"' _GET  '"' / "'" _GET "'"  / _GET ) { lua_pushliteral(yy->L,"GET");  }
            /  EQ ('"' _POST '"' / "'" _POST "'" / _POST) { lua_pushliteral(yy->L,"POST"); }
            
_vMULTIPLE  <- EQ ('"' _MULTIPLE '"' / "'" _MULTIPLE "'" / _MULTIPLE) { lua_pushliteral(yy->L,"multiple"); }
            /  { lua_pushliteral(yy->L,"multiple"); }
            
_vNOHREF    <- EQ ('"' _NOHREF '"' / "'" _NOHREF "'" / _NOHREF) { lua_pushliteral(yy->L,"nohref"); }
            /  { lua_pushliteral(yy->L,"nohref"); }
            
_vREADONLY  <- EQ ('"' _READONLY '"' / "'" _READONLY "'" / _READONLY) { lua_pushliteral(yy->L,"readonly"); }
            /  { lua_pushliteral(yy->L,"readonly"); }
            
_vRULES     <- EQ ('"' _NONE   '"' / "'" _NONE   "'" / _NONE  ) { lua_pushliteral(yy->L,"none");   }
            /  EQ ('"' _GROUPS '"' / "'" _GROUPS "'" / _GROUPS) { lua_pushliteral(yy->L,"groups"); }
            /  EQ ('"' _ROWS   '"' / "'" _ROWS   "'" / _ROWS  ) { lua_pushliteral(yy->L,"rows");   }
            /  EQ ('"' _COLS   '"' / "'" _COLS   "'" / _COLS  ) { lua_pushliteral(yy->L,"cols");   }
            /  EQ ('"' _ALL    '"' / "'" _ALL    "'" / _ALL   ) { lua_pushliteral(yy->L,"all");    }
            
_vSELECTED  <- EQ ('"' _SELECTED '"' / "'" _SELECTED "'" / _SELECTED) { lua_pushliteral(yy->L,"selected"); }
            /  { lua_pushliteral(yy->L,"selected"); }
            
_vTYPE2     <- EQ ('"' _BUTTON '"' / "'" _BUTTON "'" / _BUTTON) { lua_pushliteral(yy->L,"button"); }
            /  EQ ('"' _SUBMIT '"' / "'" _SUBMIT "'" / _SUBMIT) { lua_pushliteral(yy->L,"submit"); }
            /  EQ ('"' _RESET  '"' / "'" _RESET  "'" / _RESET ) { lua_pushliteral(yy->L,"reset");  }
            
_vVALIGN    <- EQ ('"' _TOP      '"' / "'" _TOP      "'" / _TOP     ) { lua_pushliteral(yy->L,"top");      }
            /  EQ ('"' _MIDDLE   '"' / "'" _MIDDLE   "'" / _MIDDLE  ) { lua_pushliteral(yy->L,"middle");   }
            /  EQ ('"' _BOTTOM   '"' / "'" _BOTTOM   "'" / _BOTTOM  ) { lua_pushliteral(yy->L,"bottom");   }
            /  EQ ('"' _BASELINE '"' / "'" _BASELINE "'" / _BASELINE) { lua_pushliteral(yy->L,"baseline"); }
            
_vVALUETYPE <- EQ ('"' _DATA   '"' / "'" _DATA   "'" / _DATA  ) { lua_pushliteral(yy->L,"DATA");   }
            /  EQ ('"' _REF    '"' / "'" _REF    "'" / _REF   ) { lua_pushliteral(yy->L,"REF");    }
            /  EQ ('"' _OBJECT '"' / "'" _OBJECT "'" / _OBJECT) { lua_pushliteral(yy->L,"OBJECT"); }
            
_vnum       <- EQ '"' < [0-9]+ > '"' { lua_pushinteger(yy->L,strtoul(yytext,NULL,10)); }
            /  EQ "'" < [0-9]+ > "'" { lua_pushinteger(yy->L,strtoul(yytext,NULL,10)); }
            /  EQ       [0-9]+ >     { lua_pushinteger(yy->L,strtoul(yytext,NULL,10)); }
            
attr_abbr               <- S+ _ABBR              & EA _defval     { setfield(yy,"abbr"); }
attr_accept             <- S+ _ACCEPT            & EA _defval     { setfield(yy,"accept"); }
attr_accept_charset     <- S+ _ACCEPT_CHARSET    & EA _defval     { setfield(yy,"accept_charset"); }
attr_accesskey          <- S+ _ACCESSKEY         & EA _defval     { setfield(yy,"accesskey"); }
attr_action             <- S+ _ACTION            & EA _defval     { setfield(yy,"action"); }
attr_align              <- S+ _ALIGN             & EA _vALIGN     { setfield(yy,"align"); }
attr_allowfullscreen    <- S+ _ALLOWFULLSCREEN   & EA _vAFS       { setfield(yy,"allowfullscreen"); }
attr_allowscriptaccess  <- S+ _ALLOWSCRIPTACCESS & EA _defval     { setfield(yy,"allowscriptaccess"); }
attr_alt                <- S+ _ALT               & EA _defval     { setfield(yy,"alt"); }
attr_archive            <- S+ _ARCHIVE           & EA _defval     { setfield(yy,"archive"); }
attr_axis               <- S+ _AXIS              & EA _defval     { setfield(yy,"axis"); }
attr_bgcolor            <- S+ _BGCOLOR           & EA _defval     { setfield(yy,"bgcolor"); }
attr_border             <- S+ _BORDER            & EA _defval     { setfield(yy,"border"); }
attr_cellpadding        <- S+ _CELLPADDING       & EA _defval     { setfield(yy,"cellpadding"); }
attr_cellspacing        <- S+ _CELLSPACING       & EA _defval     { setfield(yy,"cellspacing"); }
attr_char               <- S+ _CHAR              & EA _defval     { setfield(yy,"char"); }
attr_charoff            <- S+ _CHAROFF           & EA _defval     { setfield(yy,"charoff"); }
attr_charset            <- S+ _CHARSET           & EA _defval     { setfield(yy,"charset"); }
attr_checked            <- S+ _CHECKED           & EA _vCHECKED   { setfield(yy,"checked"); }
attr_cite               <- S+ _CITE              & EA _defval     { setfield(yy,"cite"); }
attr_class              <- S+ _CLASS             & EA _defval     { setfield(yy,"class"); }
attr_classid            <- S+ _CLASSID           & EA _defval     { setfield(yy,"classid"); }
attr_codebase           <- S+ _CODEBASE          & EA _defval     { setfield(yy,"codebase"); }
attr_codetype           <- S+ _CODETYPE          & EA _defval     { setfield(yy,"codetype"); }
attr_color              <- S+ _COLOR             & EA _defval     { setfield(yy,"color"); }
attr_cols               <- S+ _COLS              & EA _vnum       { setfield(yy,"cols"); }
attr_colspan            <- S+ _COLSPAN           & EA _vnum       { setfield(yy,"colspan"); }
attr_coords             <- S+ _COORDS            & EA _defval     { setfield(yy,"coords"); }
attr_data               <- S+ _DATA              & EA _defval     { setfield(yy,"data"); }
attr_datafld            <- S+ _DATAFLD           & EA _defval     { setfield(yy,"datafld"); }
attr_datapagesize       <- S+ _DATAPAGESIZE      & EA _defval     { setfield(yy,"datapagesize"); }
attr_datasrc            <- S+ _DATASRC           & EA _defval     { setfield(yy,"datasrc"); }
attr_datetime           <- S+ _DATETIME          & EA _defval     { setfield(yy,"datetime"); }
attr_declare            <- S+ _DECLARE           & EA _vDECLARE   { setfield(yy,"declare"); }
attr_defer              <- S+ _DEFER             & EA _vDEFER     { setfield(yy,"defer"); }
attr_dir                <- S+ _DIR               & EA _vDIR       { setfield(yy,"dir"); }
attr_disabled           <- S+ _DISABLED          & EA _vDISABLED  { setfield(yy,"disabled"); }
attr_enctype            <- S+ _ENCTYPE           & EA _defval     { setfield(yy,"enctype"); }
attr_event              <- S+ _EVENT             & EA _defval     { setfield(yy,"event"); }
attr_face               <- S+ _FACE              & EA _defval     { setfield(yy,"face"); }
attr_flashvars          <- S+ _FLASHVARS         & EA _defval     { setfield(yy,"flashvars"); }
attr_for                <- S+ _FOR               & EA _defval     { setfield(yy,"for"); }
attr_frame              <- S+ _FRAME             & EA _vFRAME     { setfield(yy,"frame"); }
attr_headers            <- S+ _HEADERS           & EA _defval     { setfield(yy,"headers"); }
attr_height             <- S+ _HEIGHT            & EA _defval     { setfield(yy,"height"); }
attr_href               <- S+ _HREF              & EA _defval     { setfield(yy,"href"); }
attr_hreflang           <- S+ _HREFLANG          & EA _defval     { setfield(yy,"hreflang"); }
attr_id                 <- S+ _ID                & EA _defval     { setfield(yy,"id"); }
attr_ismap              <- S+ _ISMAP             & EA _vISMAP     { setfield(yy,"ismap"); }
attr_label              <- S+ _LABEL             & EA _defval     { setfield(yy,"label"); }
attr_lang               <- S+ _LANG              & EA _defval     { setfield(yy,"lang"); }
attr_longdesc           <- S+ _LONGDESC          & EA _defval     { setfield(yy,"longdesc"); }
attr_maxlength          <- S+ _MAXLENGTH         & EA _vnum       { setfield(yy,"maxlength"); }
attr_method             <- S+ _METHOD            & EA _vMETHOD    { setfield(yy,"method"); }
attr_multiple           <- S+ _MULTIPLE          & EA _vMULTIPLE  { setfield(yy,"multiple"); }
attr_name               <- S+ _NAME              & EA _defval     { setfield(yy,"name"); }
attr_nohref             <- S+ _NOHREF            & EA _vNOHREF    { setfield(yy,"nohref"); }
attr_onblur             <- S+ _ONBLUR            & EA _defval     { setfield(yy,"onblur"); }
attr_onchange           <- S+ _ONCHANGE          & EA _defval     { setfield(yy,"onchange"); }
attr_onclick            <- S+ _ONCLICK           & EA _defval     { setfield(yy,"onclick"); }
attr_ondblclick         <- S+ _ONDBLCLICK        & EA _defval     { setfield(yy,"ondblclick"); }
attr_onfocus            <- S+ _ONFOCUS           & EA _defval     { setfield(yy,"onfocus"); }
attr_onkeydown          <- S+ _ONKEYDOWN         & EA _defval     { setfield(yy,"onkeydown"); }
attr_onkeypress         <- S+ _ONKEYPRESS        & EA _defval     { setfield(yy,"onkeypress"); }
attr_onkeyup            <- S+ _ONKEYUP           & EA _defval     { setfield(yy,"onkeyup"); }
attr_onmousedown        <- S+ _ONMOUSEDOWN       & EA _defval     { setfield(yy,"onmousedown"); }
attr_onmousemove        <- S+ _ONMOUSEMOVE       & EA _defval     { setfield(yy,"onmousemove"); }
attr_onmouseout         <- S+ _ONMOUSEOUT        & EA _defval     { setfield(yy,"onmouseout"); }
attr_onmouseover        <- S+ _ONMOUSEOVER       & EA _defval     { setfield(yy,"onmouseover"); }
attr_onmouseup          <- S+ _ONMOUSEUP         & EA _defval     { setfield(yy,"onmouseup"); }
attr_onreset            <- S+ _ONRESET           & EA _defval     { setfield(yy,"onreset"); }
attr_onselect           <- S+ _ONSELECT          & EA _defval     { setfield(yy,"onselect"); }
attr_onsubmit           <- S+ _ONSUBMIT          & EA _defval     { setfield(yy,"onsubmit"); }
attr_pluginspage        <- S+ _PLUGINSPAGE       & EA _defval     { setfield(yy,"pluginspage"); }
attr_quality            <- S+ _QUALITY           & EA _defval     { setfield(yy,"quality"); }
attr_readonly           <- S+ _READONLY          & EA _vREADONLY  { setfield(yy,"readonly"); }
attr_rel                <- S+ _REL               & EA _defval     { setfield(yy,"rel"); }
attr_rev                <- S+ _REV               & EA _defval     { setfield(yy,"rev"); }
attr_rows               <- S+ _ROWS              & EA _vnum       { setfield(yy,"rows"); }
attr_rowspan            <- S+ _ROWSPAN           & EA _vnum       { setfield(yy,"rowspan"); }
attr_rules              <- S+ _RULES             & EA _vRULES     { setfield(yy,"rules"); }
attr_scope              <- S+ _SCOPE             & EA _defval     { setfield(yy,"scope"); }
attr_selected           <- S+ _SELECTED          & EA _vSELECTED  { setfield(yy,"selected"); }
attr_shape              <- S+ _SHAPE             & EA _defval     { setfield(yy,"shape"); }
attr_size               <- S+ _SIZE              & EA _defval     { setfield(yy,"size"); }
attr_span               <- S+ _SPAN              & EA _vnum       { setfield(yy,"span"); }
attr_src                <- S+ _SRC               & EA _defval     { setfield(yy,"src"); }
attr_standby            <- S+ _STANDBY           & EA _defval     { setfield(yy,"standby"); }
attr_start              <- S+ _START             & EA _vnum       { setfield(yy,"start"); }
attr_style              <- S+ _STYLE             & EA _defval     { setfield(yy,"style"); }
attr_summary            <- S+ _SUMMARY           & EA _defval     { setfield(yy,"summary"); }
attr_tabindex           <- S+ _TABINDEX          & EA _vnum       { setfield(yy,"tabindex"); }
attr_title              <- S+ _TITLE             & EA _defval     { setfield(yy,"title"); }
attr_type               <- S+ _TYPE              & EA _defval     { setfield(yy,"type"); }
attr_type2              <- S+ _TYPE2             & EA _vTYPE2     { setfield(yy,"type2"); }
attr_usemap             <- S+ _USEMAP            & EA _defval     { setfield(yy,"usemap"); }
attr_valign             <- S+ _VALIGN            & EA _vVALIGN    { setfield(yy,"valign"); }
attr_value              <- S+ _VALUE             & EA _defval     { setfield(yy,"value"); }
attr_valuetype          <- S+ _VALUETYPE         & EA _vVALUETYPE { setfield(yy,"valuetype"); }
attr_width              <- S+ _WIDTH             & EA _defval     { setfield(yy,"width"); }

# ****************************

_A                 <- ('A'/'a')
_ABBR              <- ('A'/'a') ('B'/'b') ('B'/'b') ('R'/'r')
_ABOVE             <- ('A'/'a') ('B'/'b') ('O'/'o') ('V'/'v') ('E'/'e')
_ACCEPT            <- ('A'/'a') ('C'/'c') ('C'/'c') ('E'/'e') ('P'/'p') ('T'/'t')
_ACCEPT_CHARSET    <- ('A'/'a') ('C'/'c') ('C'/'c') ('E'/'e') ('P'/'p') ('T'/'t') '_' ('C'/'c') ('H'/'h') ('A'/'a') ('R'/'r') ('S'/'s') ('E'/'e') ('T'/'t')
_ACCESSKEY         <- ('A'/'a') ('C'/'c') ('C'/'c') ('E'/'e') ('S'/'s') ('S'/'s') ('K'/'k') ('E'/'e') ('Y'/'y')
_ACRONYM           <- ('A'/'a') ('C'/'c') ('R'/'r') ('O'/'o') ('N'/'n') ('Y'/'y') ('M'/'m')
_ACTION            <- ('A'/'a') ('C'/'c') ('T'/'t') ('I'/'i') ('O'/'o') ('N'/'n')
_ADDRESS           <- ('A'/'a') ('D'/'d') ('D'/'d') ('R'/'r') ('E'/'e') ('S'/'s') ('S'/'s')
_ALIGN             <- ('A'/'a') ('L'/'l') ('I'/'i') ('G'/'g') ('N'/'n')
_ALL               <- ('A'/'a') ('L'/'l') ('L'/'l')
_ALLOWFULLSCREEN   <- ('A'/'a') ('L'/'l') ('L'/'l') ('O'/'o') ('W'/'w') ('F'/'f') ('U'/'u') ('L'/'l') ('L'/'l') ('S'/'s') ('C'/'c') ('R'/'r') ('E'/'e') ('E'/'e') ('N'/'n')
_ALLOWSCRIPTACCESS <- ('A'/'a') ('L'/'l') ('L'/'l') ('O'/'o') ('W'/'w') ('S'/'s') ('C'/'c') ('R'/'r') ('I'/'i') ('P'/'p') ('T'/'t') ('A'/'a') ('C'/'c') ('C'/'c') ('E'/'e') ('S'/'s') ('S'/'s')
_ALT               <- ('A'/'a') ('L'/'l') ('T'/'t')
_ARCHIVE           <- ('A'/'a') ('R'/'r') ('C'/'c') ('H'/'h') ('I'/'i') ('V'/'v') ('E'/'e')
_AREA              <- ('A'/'a') ('R'/'r') ('E'/'e') ('A'/'a')
_AXIS              <- ('A'/'a') ('X'/'x') ('I'/'i') ('S'/'s')
_B                 <- ('B'/'b')
_BASELINE          <- ('B'/'b') ('A'/'a') ('S'/'s') ('E'/'e') ('L'/'l') ('I'/'i') ('N'/'n') ('E'/'e')
_BDO               <- ('B'/'b') ('D'/'d') ('O'/'o')
_BELOW             <- ('B'/'b') ('E'/'e') ('L'/'l') ('O'/'o') ('W'/'w')
_BGCOLOR           <- ('B'/'b') ('G'/'g') ('C'/'c') ('O'/'o') ('L'/'l') ('O'/'o') ('R'/'r')
_BIG               <- ('B'/'b') ('I'/'i') ('G'/'g')
_BLOCKQUOTE        <- ('B'/'b') ('L'/'l') ('O'/'o') ('C'/'c') ('K'/'k') ('Q'/'q') ('U'/'u') ('O'/'o') ('T'/'t') ('E'/'e')
_BORDER            <- ('B'/'b') ('O'/'o') ('R'/'r') ('D'/'d') ('E'/'e') ('R'/'r')
_BOTTOM            <- ('B'/'b') ('O'/'o') ('T'/'t') ('T'/'t') ('O'/'o') ('M'/'m')
_BOX               <- ('B'/'b') ('O'/'o') ('X'/'x')
_BR                <- ('B'/'b') ('R'/'r')
_BUTTON            <- ('B'/'b') ('U'/'u') ('T'/'t') ('T'/'t') ('O'/'o') ('N'/'n')
_CAPTION           <- ('C'/'c') ('A'/'a') ('P'/'p') ('T'/'t') ('I'/'i') ('O'/'o') ('N'/'n')
_CELLPADDING       <- ('C'/'c') ('E'/'e') ('L'/'l') ('L'/'l') ('P'/'p') ('A'/'a') ('D'/'d') ('D'/'d') ('I'/'i') ('N'/'n') ('G'/'g')
_CELLSPACING       <- ('C'/'c') ('E'/'e') ('L'/'l') ('L'/'l') ('S'/'s') ('P'/'p') ('A'/'a') ('C'/'c') ('I'/'i') ('N'/'n') ('G'/'g')
_CENTER            <- ('C'/'c') ('E'/'e') ('N'/'n') ('T'/'t') ('E'/'e') ('R'/'r')
_CHAR              <- ('C'/'c') ('H'/'h') ('A'/'a') ('R'/'r')
_CHAROFF           <- ('C'/'c') ('H'/'h') ('A'/'a') ('R'/'r') ('O'/'o') ('F'/'f') ('F'/'f')
_CHARSET           <- ('C'/'c') ('H'/'h') ('A'/'a') ('R'/'r') ('S'/'s') ('E'/'e') ('T'/'t')
_CHECKED           <- ('C'/'c') ('H'/'h') ('E'/'e') ('C'/'c') ('K'/'k') ('E'/'e') ('D'/'d')
_CITE              <- ('C'/'c') ('I'/'i') ('T'/'t') ('E'/'e')
_CLASS             <- ('C'/'c') ('L'/'l') ('A'/'a') ('S'/'s') ('S'/'s')
_CLASSID           <- ('C'/'c') ('L'/'l') ('A'/'a') ('S'/'s') ('S'/'s') ('I'/'i') ('D'/'d')
_CODE              <- ('C'/'c') ('O'/'o') ('D'/'d') ('E'/'e')
_CODEBASE          <- ('C'/'c') ('O'/'o') ('D'/'d') ('E'/'e') ('B'/'b') ('A'/'a') ('S'/'s') ('E'/'e')
_CODETYPE          <- ('C'/'c') ('O'/'o') ('D'/'d') ('E'/'e') ('T'/'t') ('Y'/'y') ('P'/'p') ('E'/'e')
_COL               <- ('C'/'c') ('O'/'o') ('L'/'l')
_COLGROUP          <- ('C'/'c') ('O'/'o') ('L'/'l') ('G'/'g') ('R'/'r') ('O'/'o') ('U'/'u') ('P'/'p')
_COLOR             <- ('C'/'c') ('O'/'o') ('L'/'l') ('O'/'o') ('R'/'r')
_COLS              <- ('C'/'c') ('O'/'o') ('L'/'l') ('S'/'s')
_COLSPAN           <- ('C'/'c') ('O'/'o') ('L'/'l') ('S'/'s') ('P'/'p') ('A'/'a') ('N'/'n')
_COORDS            <- ('C'/'c') ('O'/'o') ('O'/'o') ('R'/'r') ('D'/'d') ('S'/'s')
_DATA              <- ('D'/'d') ('A'/'a') ('T'/'t') ('A'/'a')
_DATAFLD           <- ('D'/'d') ('A'/'a') ('T'/'t') ('A'/'a') ('F'/'f') ('L'/'l') ('D'/'d')
_DATAPAGESIZE      <- ('D'/'d') ('A'/'a') ('T'/'t') ('A'/'a') ('P'/'p') ('A'/'a') ('G'/'g') ('E'/'e') ('S'/'s') ('I'/'i') ('Z'/'z') ('E'/'e')
_DATASRC           <- ('D'/'d') ('A'/'a') ('T'/'t') ('A'/'a') ('S'/'s') ('R'/'r') ('C'/'c')
_DATETIME          <- ('D'/'d') ('A'/'a') ('T'/'t') ('E'/'e') ('T'/'t') ('I'/'i') ('M'/'m') ('E'/'e')
_DD                <- ('D'/'d') ('D'/'d')
_DECLARE           <- ('D'/'d') ('E'/'e') ('C'/'c') ('L'/'l') ('A'/'a') ('R'/'r') ('E'/'e')
_DEFER             <- ('D'/'d') ('E'/'e') ('F'/'f') ('E'/'e') ('R'/'r')
_DEL               <- ('D'/'d') ('E'/'e') ('L'/'l')
_DFN               <- ('D'/'d') ('F'/'f') ('N'/'n')
_DIR               <- ('D'/'d') ('I'/'i') ('R'/'r')
_DISABLED          <- ('D'/'d') ('I'/'i') ('S'/'s') ('A'/'a') ('B'/'b') ('L'/'l') ('E'/'e') ('D'/'d')
_DIV               <- ('D'/'d') ('I'/'i') ('V'/'v')
_DL                <- ('D'/'d') ('L'/'l')
_DT                <- ('D'/'d') ('T'/'t')
_EM                <- ('E'/'e') ('M'/'m')
_EMBED             <- ('E'/'e') ('M'/'m') ('B'/'b') ('E'/'e') ('D'/'d')
_ENCTYPE           <- ('E'/'e') ('N'/'n') ('C'/'c') ('T'/'t') ('Y'/'y') ('P'/'p') ('E'/'e')
_EVENT             <- ('E'/'e') ('V'/'v') ('E'/'e') ('N'/'n') ('T'/'t')
_FACE              <- ('F'/'f') ('A'/'a') ('C'/'c') ('E'/'e')
_FIELDSET          <- ('F'/'f') ('I'/'i') ('E'/'e') ('L'/'l') ('D'/'d') ('S'/'s') ('E'/'e') ('T'/'t')
_FLASHVARS         <- ('F'/'f') ('L'/'l') ('A'/'a') ('S'/'s') ('H'/'h') ('V'/'v') ('A'/'a') ('R'/'r') ('S'/'s')
_FONT              <- ('F'/'f') ('O'/'o') ('N'/'n') ('T'/'t')
_FOR               <- ('F'/'f') ('O'/'o') ('R'/'r')
_FORM              <- ('F'/'f') ('O'/'o') ('R'/'r') ('M'/'m')
_FRAME             <- ('F'/'f') ('R'/'r') ('A'/'a') ('M'/'m') ('E'/'e')
_GET               <- ('G'/'g') ('E'/'e') ('T'/'t')
_GROUPS            <- ('G'/'g') ('R'/'r') ('O'/'o') ('U'/'u') ('P'/'p') ('S'/'s')
_H1                <- ('H'/'h') '1'
_H2                <- ('H'/'h') '2'
_H3                <- ('H'/'h') '3'
_H4                <- ('H'/'h') '4'
_H5                <- ('H'/'h') '5'
_H6                <- ('H'/'h') '6'
_HEADERS           <- ('H'/'h') ('E'/'e') ('A'/'a') ('D'/'d') ('E'/'e') ('R'/'r') ('S'/'s')
_HEIGHT            <- ('H'/'h') ('E'/'e') ('I'/'i') ('G'/'g') ('H'/'h') ('T'/'t')
_HR                <- ('H'/'h') ('R'/'r')
_HREF              <- ('H'/'h') ('R'/'r') ('E'/'e') ('F'/'f')
_HREFLANG          <- ('H'/'h') ('R'/'r') ('E'/'e') ('F'/'f') ('L'/'l') ('A'/'a') ('N'/'n') ('G'/'g')
_HSIDES            <- ('H'/'h') ('S'/'s') ('I'/'i') ('D'/'d') ('E'/'e') ('S'/'s')
_I                 <- ('I'/'i')
_ID                <- ('I'/'i') ('D'/'d')
_IMG               <- ('I'/'i') ('M'/'m') ('G'/'g')
_INPUT             <- ('I'/'i') ('N'/'n') ('P'/'p') ('U'/'u') ('T'/'t')
_INS               <- ('I'/'i') ('N'/'n') ('S'/'s')
_ISMAP             <- ('I'/'i') ('S'/'s') ('M'/'m') ('A'/'a') ('P'/'p')
_JUSTIFY           <- ('J'/'j') ('U'/'u') ('S'/'s') ('T'/'t') ('I'/'i') ('F'/'f') ('Y'/'y')
_KBD               <- ('K'/'k') ('B'/'b') ('D'/'d')
_LABEL             <- ('L'/'l') ('A'/'a') ('B'/'b') ('E'/'e') ('L'/'l')
_LANG              <- ('L'/'l') ('A'/'a') ('N'/'n') ('G'/'g')
_LEFT              <- ('L'/'l') ('E'/'e') ('F'/'f') ('T'/'t')
_LEGEND            <- ('L'/'l') ('E'/'e') ('G'/'g') ('E'/'e') ('N'/'n') ('D'/'d')
_LHS               <- ('L'/'l') ('H'/'h') ('S'/'s')
_LI                <- ('L'/'l') ('I'/'i')
_LONGDESC          <- ('L'/'l') ('O'/'o') ('N'/'n') ('G'/'g') ('D'/'d') ('E'/'e') ('S'/'s') ('C'/'c')
_LTR               <- ('L'/'l') ('T'/'t') ('R'/'r')
_MAP               <- ('M'/'m') ('A'/'a') ('P'/'p')
_MAXLENGTH         <- ('M'/'m') ('A'/'a') ('X'/'x') ('L'/'l') ('E'/'e') ('N'/'n') ('G'/'g') ('T'/'t') ('H'/'h')
_METHOD            <- ('M'/'m') ('E'/'e') ('T'/'t') ('H'/'h') ('O'/'o') ('D'/'d')
_MIDDLE            <- ('M'/'m') ('I'/'i') ('D'/'d') ('D'/'d') ('L'/'l') ('E'/'e')
_MULTIPLE          <- ('M'/'m') ('U'/'u') ('L'/'l') ('T'/'t') ('I'/'i') ('P'/'p') ('L'/'l') ('E'/'e')
_NAME              <- ('N'/'n') ('A'/'a') ('M'/'m') ('E'/'e')
_NOHREF            <- ('N'/'n') ('O'/'o') ('H'/'h') ('R'/'r') ('E'/'e') ('F'/'f')
_NONE              <- ('N'/'n') ('O'/'o') ('N'/'n') ('E'/'e')
_NOSCRIPT          <- ('N'/'n') ('O'/'o') ('S'/'s') ('C'/'c') ('R'/'r') ('I'/'i') ('P'/'p') ('T'/'t')
_OBJECT            <- ('O'/'o') ('B'/'b') ('J'/'j') ('E'/'e') ('C'/'c') ('T'/'t')
_OL                <- ('O'/'o') ('L'/'l')
_ONBLUR            <- ('O'/'o') ('N'/'n') ('B'/'b') ('L'/'l') ('U'/'u') ('R'/'r')
_ONCHANGE          <- ('O'/'o') ('N'/'n') ('C'/'c') ('H'/'h') ('A'/'a') ('N'/'n') ('G'/'g') ('E'/'e')
_ONCLICK           <- ('O'/'o') ('N'/'n') ('C'/'c') ('L'/'l') ('I'/'i') ('C'/'c') ('K'/'k')
_ONDBLCLICK        <- ('O'/'o') ('N'/'n') ('D'/'d') ('B'/'b') ('L'/'l') ('C'/'c') ('L'/'l') ('I'/'i') ('C'/'c') ('K'/'k')
_ONFOCUS           <- ('O'/'o') ('N'/'n') ('F'/'f') ('O'/'o') ('C'/'c') ('U'/'u') ('S'/'s')
_ONKEYDOWN         <- ('O'/'o') ('N'/'n') ('K'/'k') ('E'/'e') ('Y'/'y') ('D'/'d') ('O'/'o') ('W'/'w') ('N'/'n')
_ONKEYPRESS        <- ('O'/'o') ('N'/'n') ('K'/'k') ('E'/'e') ('Y'/'y') ('P'/'p') ('R'/'r') ('E'/'e') ('S'/'s') ('S'/'s')
_ONKEYUP           <- ('O'/'o') ('N'/'n') ('K'/'k') ('E'/'e') ('Y'/'y') ('U'/'u') ('P'/'p')
_ONMOUSEDOWN       <- ('O'/'o') ('N'/'n') ('M'/'m') ('O'/'o') ('U'/'u') ('S'/'s') ('E'/'e') ('D'/'d') ('O'/'o') ('W'/'w') ('N'/'n')
_ONMOUSEMOVE       <- ('O'/'o') ('N'/'n') ('M'/'m') ('O'/'o') ('U'/'u') ('S'/'s') ('E'/'e') ('M'/'m') ('O'/'o') ('V'/'v') ('E'/'e')
_ONMOUSEOUT        <- ('O'/'o') ('N'/'n') ('M'/'m') ('O'/'o') ('U'/'u') ('S'/'s') ('E'/'e') ('O'/'o') ('U'/'u') ('T'/'t')
_ONMOUSEOVER       <- ('O'/'o') ('N'/'n') ('M'/'m') ('O'/'o') ('U'/'u') ('S'/'s') ('E'/'e') ('O'/'o') ('V'/'v') ('E'/'e') ('R'/'r')
_ONMOUSEUP         <- ('O'/'o') ('N'/'n') ('M'/'m') ('O'/'o') ('U'/'u') ('S'/'s') ('E'/'e') ('U'/'u') ('P'/'p')
_ONRESET           <- ('O'/'o') ('N'/'n') ('R'/'r') ('E'/'e') ('S'/'s') ('E'/'e') ('T'/'t')
_ONSELECT          <- ('O'/'o') ('N'/'n') ('S'/'s') ('E'/'e') ('L'/'l') ('E'/'e') ('C'/'c') ('T'/'t')
_ONSUBMIT          <- ('O'/'o') ('N'/'n') ('S'/'s') ('U'/'u') ('B'/'b') ('M'/'m') ('I'/'i') ('T'/'t')
_OPTGROUP          <- ('O'/'o') ('P'/'p') ('T'/'t') ('G'/'g') ('R'/'r') ('O'/'o') ('U'/'u') ('P'/'p')
_OPTION            <- ('O'/'o') ('P'/'p') ('T'/'t') ('I'/'i') ('O'/'o') ('N'/'n')
_P                 <- ('P'/'p')
_PARAM             <- ('P'/'p') ('A'/'a') ('R'/'r') ('A'/'a') ('M'/'m')
_PLUGINSPAGE       <- ('P'/'p') ('L'/'l') ('U'/'u') ('G'/'g') ('I'/'i') ('N'/'n') ('S'/'s') ('P'/'p') ('A'/'a') ('G'/'g') ('E'/'e')
_POST              <- ('P'/'p') ('O'/'o') ('S'/'s') ('T'/'t')
_PRE               <- ('P'/'p') ('R'/'r') ('E'/'e')
_Q                 <- ('Q'/'q')
_QUALITY           <- ('Q'/'q') ('U'/'u') ('A'/'a') ('L'/'l') ('I'/'i') ('T'/'t') ('Y'/'y')
_READONLY          <- ('R'/'r') ('E'/'e') ('A'/'a') ('D'/'d') ('O'/'o') ('N'/'n') ('L'/'l') ('Y'/'y')
_REF               <- ('R'/'r') ('E'/'e') ('F'/'f')
_REL               <- ('R'/'r') ('E'/'e') ('L'/'l')
_RESET             <- ('R'/'r') ('E'/'e') ('S'/'s') ('E'/'e') ('T'/'t')
_REV               <- ('R'/'r') ('E'/'e') ('V'/'v')
_RHS               <- ('R'/'r') ('H'/'h') ('S'/'s')
_RIGHT             <- ('R'/'r') ('I'/'i') ('G'/'g') ('H'/'h') ('T'/'t')
_ROWS              <- ('R'/'r') ('O'/'o') ('W'/'w') ('S'/'s')
_ROWSPAN           <- ('R'/'r') ('O'/'o') ('W'/'w') ('S'/'s') ('P'/'p') ('A'/'a') ('N'/'n')
_RTL               <- ('R'/'r') ('T'/'t') ('L'/'l')
_RULES             <- ('R'/'r') ('U'/'u') ('L'/'l') ('E'/'e') ('S'/'s')
_SAMP              <- ('S'/'s') ('A'/'a') ('M'/'m') ('P'/'p')
_SCOPE             <- ('S'/'s') ('C'/'c') ('O'/'o') ('P'/'p') ('E'/'e')
_SCRIPT            <- ('S'/'s') ('C'/'c') ('R'/'r') ('I'/'i') ('P'/'p') ('T'/'t')
_SELECT            <- ('S'/'s') ('E'/'e') ('L'/'l') ('E'/'e') ('C'/'c') ('T'/'t')
_SELECTED          <- ('S'/'s') ('E'/'e') ('L'/'l') ('E'/'e') ('C'/'c') ('T'/'t') ('E'/'e') ('D'/'d')
_SHAPE             <- ('S'/'s') ('H'/'h') ('A'/'a') ('P'/'p') ('E'/'e')
_SIZE              <- ('S'/'s') ('I'/'i') ('Z'/'z') ('E'/'e')
_SMALL             <- ('S'/'s') ('M'/'m') ('A'/'a') ('L'/'l') ('L'/'l')
_SPAN              <- ('S'/'s') ('P'/'p') ('A'/'a') ('N'/'n')
_SRC               <- ('S'/'s') ('R'/'r') ('C'/'c')
_STANDBY           <- ('S'/'s') ('T'/'t') ('A'/'a') ('N'/'n') ('D'/'d') ('B'/'b') ('Y'/'y')
_START             <- ('S'/'s') ('T'/'t') ('A'/'a') ('R'/'r') ('T'/'t')
_STRONG            <- ('S'/'s') ('T'/'t') ('R'/'r') ('O'/'o') ('N'/'n') ('G'/'g')
_STYLE             <- ('S'/'s') ('T'/'t') ('Y'/'y') ('L'/'l') ('E'/'e')
_SUB               <- ('S'/'s') ('U'/'u') ('B'/'b')
_SUBMIT            <- ('S'/'s') ('U'/'u') ('B'/'b') ('M'/'m') ('I'/'i') ('T'/'t')
_SUMMARY           <- ('S'/'s') ('U'/'u') ('M'/'m') ('M'/'m') ('A'/'a') ('R'/'r') ('Y'/'y')
_SUP               <- ('S'/'s') ('U'/'u') ('P'/'p')
_TABINDEX          <- ('T'/'t') ('A'/'a') ('B'/'b') ('I'/'i') ('N'/'n') ('D'/'d') ('E'/'e') ('X'/'x')
_TABLE             <- ('T'/'t') ('A'/'a') ('B'/'b') ('L'/'l') ('E'/'e')
_TBODY             <- ('T'/'t') ('B'/'b') ('O'/'o') ('D'/'d') ('Y'/'y')
_TD                <- ('T'/'t') ('D'/'d')
_TEXTAREA          <- ('T'/'t') ('E'/'e') ('X'/'x') ('T'/'t') ('A'/'a') ('R'/'r') ('E'/'e') ('A'/'a')
_TFOOT             <- ('T'/'t') ('F'/'f') ('O'/'o') ('O'/'o') ('T'/'t')
_TH                <- ('T'/'t') ('H'/'h')
_THEAD             <- ('T'/'t') ('H'/'h') ('E'/'e') ('A'/'a') ('D'/'d')
_TITLE             <- ('T'/'t') ('I'/'i') ('T'/'t') ('L'/'l') ('E'/'e')
_TOP               <- ('T'/'t') ('O'/'o') ('P'/'p')
_TR                <- ('T'/'t') ('R'/'r')
_TRUE              <- ('T'/'t') ('R'/'r') ('U'/'u') ('E'/'e')
_TT                <- ('T'/'t') ('T'/'t')
_TYPE              <- ('T'/'t') ('Y'/'y') ('P'/'p') ('E'/'e')
_TYPE2             <- ('T'/'t') ('Y'/'y') ('P'/'p') ('E'/'e') '2'
_U                 <- ('U'/'u')
_UL                <- ('U'/'u') ('L'/'l')
_USEMAP            <- ('U'/'u') ('S'/'s') ('E'/'e') ('M'/'m') ('A'/'a') ('P'/'p')
_VALIGN            <- ('V'/'v') ('A'/'a') ('L'/'l') ('I'/'i') ('G'/'g') ('N'/'n')
_VALUE             <- ('V'/'v') ('A'/'a') ('L'/'l') ('U'/'u') ('E'/'e')
_VALUETYPE         <- ('V'/'v') ('A'/'a') ('L'/'l') ('U'/'u') ('E'/'e') ('T'/'t') ('Y'/'y') ('P'/'p') ('E'/'e')
_VAR               <- ('V'/'v') ('A'/'a') ('R'/'r')
_VOID              <- ('V'/'v') ('O'/'o') ('I'/'i') ('D'/'d')
_VSIDES            <- ('V'/'v') ('S'/'s') ('I'/'i') ('D'/'d') ('E'/'e') ('S'/'s')
_WIDTH             <- ('W'/'w') ('I'/'i') ('D'/'d') ('T'/'t') ('H'/'h')

# ***********************************
# Misc definitions
# ***********************************

Cinline <-     "<!--" ___comment_start ___comment_data* ___comment_stop
Cblock  <-     "<!--" ___comment_start ___comment_data* ___comment_stop S*
	# ^^^ add S* here at some point

___comment_start <- {
                      lua_createtable(yy->L,0,0);
                      luaL_buffinit(yy->L,&yy->buf);
                    }
___comment_data  <- < ! "-->" . > { luaL_addchar(&yy->buf,*yytext); }
___comment_stop  <- "-->"
                    {
                      luaL_pushresult(&yy->buf);
                      lua_setfield(yy->L,-2,"comment");
                      lua_pushinteger(yy->L,luaL_len(yy->L,-2) + 1);
                      lua_insert(yy->L,-2);
                      lua_settable(yy->L,-3);
                    }
                    
PCDATA  <- {
             luaL_buffinit(yy->L,&yy->buf);
           }
           (! "<" CHAR)+
           {
             luaL_pushresult(&yy->buf);
             lua_pushinteger(yy->L,luaL_len(yy->L,-2) + 1);
             lua_insert(yy->L,-2);
             lua_settable(yy->L,-3);
           }
           
scriptDATA <- {
                luaL_buffinit(yy->L,&yy->buf);
              }
              (!("</" _SCRIPT ">") CHAR)*
              {
                luaL_pushresult(&yy->buf);
                lua_pushinteger(yy->L,luaL_len(yy->L,-2) + 1);
                lua_insert(yy->L,-2);
                lua_settable(yy->L,-3);
              }
              
CHAR    <- "&#x" < HEXDIG+      > ";" { deentifyn(yy,yytext,16); }
        /  "&#X" < HEXDIG+      > ";" { deentifyn(yy,yytext,16); }
        /  "&#"  < DIGIT+       > ";" { deentifyn(yy,yytext,10); }
        /  "&"   < [A-Za-z0-9]+ > ";" { deentify(yy,yytext); }
        /  < S+ > {
                    if (yy->pre)
                      luaL_addlstring(&yy->buf,yytext,yyleng);
                    else
                      luaL_addchar(&yy->buf,' ');
                  } # handle PRE
        / < . >  { luaL_addchar(&yy->buf,*yytext); }
        
DIGIT   <- [0-9]
HEXDIG  <- [0-9A-Fa-f]
nil     <- { lua_pushliteral(yy->L,""); }
S       <- " " / "\t" / "\r" / "\n"