'*******************************************************************************
' EverEdit Syntax File
' Language:    PHP
' Maintainer:  www.everedit.net	Morler
' History:
'   2012/02/15	First Version
'	2012/06/21	Added PHP5.3
'	2014/05/16	Added php syntax in rTagString1 and rTagString2
'	2014/05/16	Added $ into wordchars
'   2014/07/23  Added phpdoc/EOT highlight and improved ?> close detection
'   2014/08/21  Fixed a ?> close detection debug in single line comment
'	2014/09/14  Added number match
'*******************************************************************************
Include( ".\html_base.mac" )

Set rPhp=html.CreateRegion( COLOR_DEFAULT, "<\?(php)?(?![a-zA-Z0-9_\-])", "+?>+", False )
rPhp.Name = "source.php"

'comment
Set rPhpBlockComment=html.CreateRegion( COLOR_COMMENT2, "+/*+", "+*/+", False )
rPhpBlockComment.AddItem( html.CreateItem( COLOR_STRING2, "@\w+", False) )

Set rPhpLineComment=html.CreateRegion( COLOR_COMMENT1, "+//+", "(?=\?>)|$", False )
Set rPhpLineCommentSharp=html.CreateRegion( COLOR_COMMENT1, "+#+", "(?=\?>)|$", False )

Set rPhpEOT=html.CreateRegion( COLOR_STRING1, "+<<<EOT+", "+EOT;+", True )
Set rPhpEOF=html.CreateRegion( COLOR_STRING2, "+<<<EOF+", "+EOF;+", True )
'string
Set rPhpString1=html.CreateStringRegion( COLOR_STRING2, """", "\", True )
Set rPhpString2=html.CreateStringRegion( COLOR_STRING1, "'", "\", True )
'php vars in string
rPhpEOT.AddItem( html.CreateItem(COLOR_VAR, "\$\w+|\{\$.+\}", False) )
rPhpString1.AddItem( html.CreateItem(COLOR_VAR, "(?=[^\\])\$\w+|\{\$.+?\}", False) )

rPhp.AddItem( html.CreateItem(COLOR_NUMBER, "\b([0-9]+\.?[0-9]*|0x[0-9a-fA-F]+)\b", False) )

rPhp.AddRegion( rPhpEOT )
rPhp.AddRegion( rPhpEOF )
rPhp.AddRegion( rPhpBlockComment )
rPhp.AddRegion( rPhpLineComment )
rPhp.AddRegion( rPhpLineCommentSharp )
rPhp.AddRegion( rPhpString2 )
rPhp.AddRegion( rPhpString1 )

html.AddWordFromFile rPhp, SCRIPT_PATH & "\php.kwd"

'<php and ?>
rPhp.AddItem( html.CreateItem(COLOR_SUBLAN, "<\?(php)?|\?>", False) )

'php vars
rPhp.AddItem( html.CreateItem(COLOR_VAR, "\$\w+", False) )

rPhp.AddSnippet "php.snippet"
rPhp.AddCallTip "php.ecp", True 

'folding
Call rPhp.FoldText( "\{", False )
Call rPhp.UnfoldText( "\}", False )
Call rPhp.CommentLine("//")
Call rPhp.CommentBlock("/*", "*/")
Call rPhp.SetPairs( "[](){}""""''" )
Call rPhp.IndentText( "\{$", False )
Call rPhp.UnindentText( "^\s*}$", False )

Set rPhpInTag=html.CopyRegion( rPhp )
rHtmlTag.AddRegion( rPhpInTag )

Set rPhpInString1=html.CopyRegion( rPhp )
rTagString1.AddRegion rPhpInString1

Set rPhpInString2=html.CopyRegion( rPhp )
rTagString2.AddRegion rPhpInString2
'-----------------------add rPhp to html parser
html.AddRegion( rPhp )
html.AddRegion( rScript )
html.AddRegion( rCss )
html.AddRegion( rHtmlBlockComment )
html.AddRegion( rHtmlTag )
html.WordChars="$"
