//Language: WML with some basic PHP


// tokens
Token=tnone
Token=tstring
Token=tcomment
Token=tident
Token=tresword
Token=turl
Token=twhitespace
Token=tsymbol
Token=twmlasp
Token=tentity
Token=tunknown
Token=tdoctype
Token=tXMLinstr

// tokens - php
Token=tphpident
Token=tphpinteger
Token=tphpfloat
Token=tphpstring
Token=tphpcomment
Token=tphpresword
Token=tphpvar

// tokens - other
Token=turl
Token=twhitespace


// states
State=snormal
State=sstring1
State=sstring2
State=scomment1
State=stagname
State=swmltag
State=swmlvalue
State=swmlPHP
State=swmlASP
State=sdoctype
State=sdoctypeval
State=sxmlinstr
State=sxmlinstrval

// states - php
State=sphpstring1
State=sphpstring2
State=sphpstring3
State=sphpcomment1
State=sphpcomment2
State=sphpcomment3
State=sphpvar

//delims
Delimiters=;.,:'"{}[]()<>?!@#$%^&*-+=|\/


//Common
snormal <                          stagname    tsymbol
stagname [a-z_A-Z][a-z_A-Z0-9]*    swmltag     tunknown
swmltag [^\>^\'^\"^#32^\=]*        swmltag     tident
stagname /                         stagname    tsymbol
swmltag /                          swmltag     tsymbol
swmltag =                          swmlvalue   tsymbol
swmlvalue [^\>^#32^\=]*            swmltag     tstring
stagname >                         snormal     tsymbol
swmltag >                          snormal     tsymbol


//white space
snormal #32*                     snormal   twhitespace
swmltag #32*                     swmltag   tsymbol


//strings
swmlvalue  \"                    sstring2   tstring
swmltag    \"                    sstring2   tstring
sstring2   [^\"^\<]*              sstring2   tstring
sstring2   <[^?]                  sstring2   tstring
sstring2   \"                     swmltag   tstring
sstring2   \"\"                   sstring2   tstring
sstring2   \\                     sstring2   tstring


// numbers
//swmltag [0-9][0-9]*              swmltag  tinteger
//swmltag \#[0-9A-F]+              swmltag  tinteger
//swmltag [1-9][0-9]*\.[0-9]*                    swmltag  tfloat
//swmltag [1-9][0-9]*{\.[0-9]+}|e{[\+\-]}|[0-9]+ swmltag  tfloat


// comments
snormal   <\!--                scomment1 tcomment
scomment1 -                    scomment1 tcomment
scomment1  -->                 snormal   tcomment
scomment1 [^\-]*               scomment1 tcomment

// ASP
snormal    <\%                 swmlASP  twmlasp
swmlASP [^\%]*                 swmlASP  twmlasp
swmlASP \%[^>]                 swmlASP  twmlasp
swmlASP [\%]*>                 snormal  twmlasp

// DOCTYPE

snormal <\!DOCTYPE                 sdoctype    tdoctype
sdoctype [^>^\"]*                  sdoctype    tdoctype
sdoctype >                         snormal     tdoctype

sdoctype  \"                       sdoctypeval  tdoctype
sdoctypeval  [^\"]*                sdoctypeval  tdoctype
sdoctypeval  \"                    sdoctype     tdoctype

// XML

snormal <?xml                       sxmlinstr    tXMLinstr
sxmlinstr [^>^\"]*                  sxmlinstr    tXMLinstr
sxmlinstr >                         snormal      tXMLinstr

sxmlinstr  \"                       sxmlinstrval  tXMLinstr
sxmlinstrval  [^\"]*                sxmlinstrval  tXMLinstr
sxmlinstrval  \"                    sxmlinstr     tXMLinstr

//reswords
stagname 'a'        swmltag  tresword
stagname 'access'   swmltag  tresword
stagname 'anchor'   swmltag  tresword
stagname 'b'        swmltag  tresword
stagname 'big'      swmltag  tresword
stagname 'br'       swmltag  tresword
stagname 'card'     swmltag  tresword
stagname 'do'       swmltag  tresword
stagname 'em'       swmltag  tresword
stagname 'fieldset' swmltag  tresword
stagname 'go'       swmltag  tresword
stagname 'head'     swmltag  tresword
stagname 'i'        swmltag  tresword
stagname 'img'      swmltag  tresword
stagname 'input'    swmltag  tresword
stagname 'meta'     swmltag  tresword
stagname 'noop'     swmltag  tresword
stagname 'onevent'  swmltag  tresword
stagname 'optgroup' swmltag  tresword
stagname 'option'   swmltag  tresword
stagname 'p'        swmltag  tresword
stagname 'postfield' swmltag  tresword
stagname 'pre'      swmltag  tresword
stagname 'prev'     swmltag  tresword
stagname 'refresh'  swmltag  tresword
stagname 'select'   swmltag  tresword
stagname 'setvar'   swmltag  tresword
stagname 'small'    swmltag  tresword
stagname 'strong'   swmltag  tresword
stagname 'table'    swmltag  tresword
stagname 'td'       swmltag  tresword
stagname 'template' swmltag  tresword
stagname 'timer'    swmltag  tresword
stagname 'tr'       swmltag  tresword
stagname 'u'        swmltag  tresword
stagname 'wml'      swmltag  tresword

// entities
snormal  &lsquo;    snormal  tentity
snormal  &amp;      snormal  tentity
snormal  &apos;     snormal  tentity
snormal  &gt;       snormal  tentity
snormal  &lt;       snormal  tentity
snormal  &nbsp;     snormal  tentity
snormal  &quot;     snormal  tentity
snormal  &shy;      snormal  tentity
snormal  &\#[0-9]*; snormal  tentity

// PHP -------------------------------------------------------------------------

snormal  <?[^x]                     swmlPHP    tphpresword    SaveState
swmlPHP ?>                          snormal    tphpresword    LoadState

stagname  <?                         swmlPHP   tphpresword    SaveState
shtmltag  <?                         swmlPHP   tphpresword    SaveState
stagname  <?                         swmlPHP   tphpresword    SaveState
shtmlvalue  <?                       swmlPHP   tphpresword    SaveState

sstring1  <?                         swmlPHP   tphpresword    SaveState
sstring2  <?                         swmlPHP   tphpresword    SaveState

// PHP -------------------------------------------------------------------------

// reswords
swmlPHP 'break'        swmlPHP tphpresword
swmlPHP 'case'         swmlPHP tphpresword
swmlPHP 'class'        swmlPHP tphpresword
swmlPHP 'continue'     swmlPHP tphpresword
swmlPHP 'default'      swmlPHP tphpresword
swmlPHP 'do'           swmlPHP tphpresword
swmlPHP 'echo'         swmlPHP tphpresword
swmlPHP 'else'         swmlPHP tphpresword
swmlPHP 'elseif'       swmlPHP tphpresword
swmlPHP 'endfor'       swmlPHP tphpresword
swmlPHP 'endif'        swmlPHP tphpresword
swmlPHP 'endswitch'    swmlPHP tphpresword
swmlPHP 'endwhile'     swmlPHP tphpresword
swmlPHP 'extends'      swmlPHP tphpresword
swmlPHP 'for'          swmlPHP tphpresword
swmlPHP 'function'     swmlPHP tphpresword
swmlPHP 'global'       swmlPHP tphpresword
swmlPHP 'if'           swmlPHP tphpresword
swmlPHP 'int'          swmlPHP tphpresword
swmlPHP 'old_function' swmlPHP tphpresword
swmlPHP 'print'        swmlPHP tphpresword
swmlPHP 'pval'         swmlPHP tphpresword
swmlPHP 'return'       swmlPHP tphpresword
swmlPHP 'static'       swmlPHP tphpresword
swmlPHP 'string'       swmlPHP tphpresword
swmlPHP 'switch'       swmlPHP tphpresword
swmlPHP 'var'          swmlPHP tphpresword
swmlPHP 'void'         swmlPHP tphpresword
swmlPHP 'while'        swmlPHP tphpresword

// idents
swmlPHP   [a-z_A-Z][a-z_A-Z0-9]* swmlPHP   tphpident

// variables
swmlPHP \$                        sphpvar  tphpvar
sphpvar [a-z_A-Z][a-z_A-Z0-9]*    swmlPHP  tphpvar

// numbers
swmlPHP [0-9][0-9]*              swmlPHP  tphpinteger
swmlPHP 0x[0-9A-F]+              swmlPHP  tphpinteger
swmlPHP [1-9][0-9]*\.[0-9]*                     swmlPHP  tphpfloat
swmlPHP [1-9][0-9]*{\.[0-9]+}|e{[\+\-]}|[0-9]+  swmlPHP  tphpfloat

//strings
swmlPHP  \'                      sphpstring1   tphpstring
sphpstring1  [^\']*              sphpstring1   tphpstring
sphpstring1  \'                  swmlPHP       tphpstring
sphpstring1  \'\'                sphpstring1   tphpstring
sphpstring1   \\                 sphpstring1   tphpstring
sphpstring1   \\\'               sphpstring1   tphpstring

swmlPHP  \"                      sphpstring2   tphpstring
sphpstring2  [^\"]*              sphpstring2   tphpstring
sphpstring2  \"                  swmlPHP       tphpstring
sphpstring2  \"\"                sphpstring2   tphpstring
sphpstring2   \\                 sphpstring2   tphpstring
sphpstring2   \\\"               sphpstring2   tphpstring

swmlPHP    \`                    sphpstring3   tphpstring
sphpstring3   [^\`]*             sphpstring3   tphpstring
sphpstring3   \`                 swmlPHP       tphpstring
sphpstring3   \`\`               sphpstring3   tphpstring
sphpstring3   \\                 sphpstring3   tphpstring
sphpstring3   \\\`               sphpstring3   tphpstring

//comments
swmlPHP   //                       sphpcomment1  tphpcomment
sphpcomment1  .*                   swmlPHP       tphpcomment
sphpcomment1 $                     swmlPHP       tphpcomment

swmlPHP   \#                       sphpcomment2  tphpcomment
sphpcomment2  .*                   swmlPHP       tphpcomment
sphpcomment2 $                     swmlPHP       tphpcomment

swmlPHP   /\*                      sphpcomment3  tphpcomment
sphpcomment3  [^\*]*               sphpcomment3  tphpcomment
sphpcomment3  \*[^/]               sphpcomment3  tphpcomment
sphpcomment3  [\*]*/               swmlPHP       tphpcomment

