/usr/share/doc/rexical/examples/xhtmlparser.rex is in rexical 1.0.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | #
# xhtmlparser.rex
# lexical scanner definition for rex
#
# usage
# rex xhtmlparser.rex --stub
# ruby xhtmlparser.rex.rb sample.xhtml
#
class XHTMLParser
option
ignorecase
macro
BLANK \s+
TAG_IN \<
TAG_OUT \>
ETAG_IN \<\/
ETAG_OUT \/\>
XTAG_IN \<\?
XTAG_OUT \?\>
EXT \!
REM \-\-
EQUAL \=
Q1 \'
Q2 \"
rule
# [:state] pattern [actions]
{XTAG_IN} { state = :TAG; [:xtag_in, text] }
{ETAG_IN} { state = :TAG; [:etag_in, text] }
{TAG_IN} { state = :TAG; [:tag_in, text] }
:TAG {EXT} { state = :EXT; [:ext, text] }
:EXT {REM} { state = :REM; [:rem_in, text] }
:EXT {XTAG_OUT} { state = nil; [:xtag_out, text] }
:EXT {TAG_OUT} { state = nil; [:tag_out, text] }
:EXT .+(?={REM}) { [:exttext, text] }
:EXT .+(?={TAG_OUT}) { [:exttext, text] }
:EXT .+(?=$) { [:exttext, text] }
:EXT \n
:REM {REM} { state = :EXT; [:rem_out, text] }
:REM .+(?={REM}) { [:remtext, text] }
:REM .+(?=$) { [:remtext, text] }
:REM \n
:TAG {BLANK}
:TAG {XTAG_OUT} { state = nil; [:xtag_out, text] }
:TAG {ETAG_OUT} { state = nil; [:etag_out, text] }
:TAG {TAG_OUT} { state = nil; [:tag_out, text] }
:TAG {EQUAL} { [:equal, text] }
:TAG {Q1} { state = :Q1; [:quote1, text] } # '
:Q1 {Q1} { state = :TAG; [:quote1, text] } # '
:Q1 [^{Q1}]+(?={Q1}) { [:value, text] } # '
:TAG {Q2} { state = :Q2; [:quote2, text] } # "
:Q2 {Q2} { state = :TAG; [:quote2, text] } # "
:Q2 [^{Q2}]+(?={Q2}) { [:value, text] } # "
:TAG [\w\-]+(?={EQUAL}) { [:attr, text] }
:TAG [\w\-]+ { [:element, text] }
\s+(?=\S)
.*\S(?=\s*{ETAG_IN}) { [:text, text] }
.*\S(?=\s*{TAG_IN}) { [:text, text] }
.*\S(?=\s*$) { [:text, text] }
\s+(?=$)
inner
end
|