Menu

[dc0a3d]: / syntax / php.jsf  Maximize  Restore  History

Download this file

340 lines (281 with data), 5.6 kB

# JOE syntax highlight file for PHP
# modified by Eric Lin

# TODO:
#  * heredoc support (as good as possible)
#  * highlight function and class names?

# Define colors

=Idle
=Comment
=Constant
=Number		+Constant
=String		+Constant
=StringEscape	+Escape
=Character	+Constant
=CharacterEscape +Escape
=Boolean	+Constant
=Escape
=Keyword
=Variable	+DefinedIdent
=Builtin	+DefinedFunc
=Operator	+Keyword
=Statement	+Keyword
=Conditional	+Statement
=Loop		+Statement
=Structure	+Statement
=Label		+DefinedIdent
=StorageClass	+Type +Keyword

# Call HTML highlighter.  It will call the PHP highlighter subroutine in this file.

:begin Idle
	*	call_failed	noeat call=html.html(php)

:call_failed Variable
	*	call_failed

# PHP highlighter.

.subr php

:idle Idle
	*		idle
	"<"		idle_done
	"?"		idle_qmark
	"%"		idle_hash
	"#"		sh_comment	recolor=-1
	"/"		slash
	"0-9"		first_digit	recolor=-1
	"'"		string_sq	recolor=-1
	"\""		string_dq	recolor=-1
	"\`"		string_bq	recolor=-1
	"\i"		ident		buffer
	"$"   php_var recolor=-1
	"-" maybe_method
	"{}"  brace recolor=-1

:idle_done Idle
	*		idle noeat
	"/"		idle noeat recolor=-2 return
	"<"		idle_here

:idle_here Idle
	*		idle noeat
	"<"		here_doc

:here_doc Idle
	*		idle noeat
	" 	"	here_doc
	"\i"		here_name buffer

:here_name Idle
	*		inhere_doc save_s
	"\c"		here_name

:inhere_doc Constant
	*		inhere_not_eol
	"\n"		inhere_doc
	"\i"		inhere_name buffer

:inhere_not_eol Constant
	*		inhere_not_eol
	"\n"		inhere_doc

:inhere_name Constant
	*		inhere_doc
	";"		inhere_doc strings
	"&"		idle
done
	"\c"		inhere_name
	
:brace Builtin
  * idle  noeat
	
:php_var Variable
  * idle noeat
  "\c" php_var

:var_indqstring Variable
	*	string_dq	recolor=-1
	"\i"	var_indqstringr
	"\""	string_dq	noeat
	"\\"	string_dq_esc	recolor=-1

:var_indqstringr Variable
	*	string_dq	recolor=-1
	"\c"	var_indqstringr
	"\""	string_dq	noeat
	"\\"	string_dq_esc	recolor=-1

:var_inbqstring Variable
	*	string_bq	recolor=-1
	"\i"	var_inbqstringr
	"\`"	string_bq	noeat
	"\\"	string_bq_esc	recolor=-1

:var_inbqstringr Variable
	*	string_bq	recolor=-1
	"\c"	var_inbqstringr
	"\`"	string_bq	noeat
	"\\"	string_bq_esc	recolor=-1

:maybe_method Builtin
	*		idle  recolor=-1
	"?"		idle_qmark 
	"%"		idle_hash
	"#"		sh_comment	recolor=-1
	"/"		slash
	"0-9"		first_digit	recolor=-1
	"'"		string_sq	recolor=-1
	"\""		string_dq	recolor=-1
	"\i"	ident		buffer
	"$"   php_var recolor=-1
	"{}"  brace recolor=-1
  ">" method  recolor=-2
  
:method Builtin
	*	idle	recolor=-1
	"\i\c"	method	recolor=-1

:idle_qmark Idle
	*		idle		noeat
	">"		idle recolor=-2 return

:idle_hash Idle
	*		idle	noeat
	">"		idle recolor=-2 return

:sh_comment Comment comment
	*		sh_comment
	"BFHNTX"	sh_comment	noeat call=comment_todo.comment_todo()
	"\n"		idle

:slash Idle
	*		idle		noeat
	"*"		comment		recolor=-2
	"/"		line_comment	recolor=-2

:comment Comment comment
	*		comment
	"*"		maybe_end_comment
	"BFHNTX"	comment		noeat call=comment_todo.comment_todo()

:maybe_end_comment Comment comment
	*		comment
	"/"		idle
	"*"		maybe_end_comment

:line_comment Comment comment
	*		line_comment
	"\n"		idle
	"BFHNTX"	line_comment	noeat call=comment_todo.comment_todo()

:string_sq Character string
	*		string_sq
	"\'"		idle
	"\\"		string_sq_esc	recolor=-1

:string_sq_esc CharacterEscape string
	*		string_sq
	"\n"		string_sq	recolor=-2

:string_dq String string
	*		string_dq
	"$"     var_indqstring recolor=-1
	"\""		idle
	"\\"		string_dq_esc	recolor=-1

:string_dq_esc StringEscape string
	*		string_dq
	"\n"		string_dq	recolor=-2
	
:string_bq String string
	*		string_bq
	"$"     var_inbqstring recolor=-1
	"\`"		idle
	"\\"		string_bq_esc	recolor=-1

:string_bq_esc StringEscape string
	*		string_bq
	"\n"		string_bq	recolor=-2
	
:first_digit Number
	*		idle	noeat
	"xX"		hex
	"."		float
	"0"		octal
	"1-9"		first_number

:octal Number
	*		idle	noeat
	"0-7"		octal

:hex Number
	*		idle	noeat
	"0-9A-Fa-f"	hex

:first_number Number
	*		idle	noeat
	"0-9"		first_number
	"."		float

:maybe_float Number
	*		idle	recolor=-2	noeat
	"0-9"		float		recolor=-2

:float Number
	*		idle	noeat
	"eE"		epart
	"0-9"		float

:epart Number
	*		idle	noeat
	"0-9+\-"	enum

:enum Number
	*		idle	noeat
	"0-9"		enum

:ident Idle
	*		idle		noeat strings
	"addslashes" 	builtin
	"array"		builtin
	"array_keys"	builtin
	"count"		builtin
	"date"		builtin
	"chr"		builtin
	"empty"		builtin
	"end"		builtin
	"header"	builtin
	"highlight_file"	builtin
	"htmlspecialchars"	builtin
	"isset"		builtin
	"shuffle"	builtin
	"strip_tags"	builtin
	"strlen"	builtin
	"strpos"	builtin
	"strrpos"	builtin
	"substr"	builtin
	"trim"		builtin
	"TRUE"		bool
	"FALSE"		bool
	"true"		bool
	"false"		bool
	"and"		oper
	"as"		oper
	"break"		loop
	"case"		label
	"class"		struct
	"continue"	loop
	"declare"	struct
	"default"	kw
	"die"		kw
	"do"		loop
	"echo"		stmt
	"else"		cond
	"elseif"	cond
	"eval"		kw
	"exception"	kw
	"exit"		kw
	"extends"	struct
	"for"		loop
	"foreach"	loop
	"function"	struct
	"global"	kw
	"if"		cond
	"include"	stmt
	"include_once"	stmt
	"list"		kw
	"new"		kw
	"or"		oper
	"print"		stmt
	"private"	storage
	"public"	storage
	"require"	stmt
	"require_once"	stmt
	"return"	stmt
	"static"	storage
	"switch"	cond
	"unset"		stmt
	"while"		loop
done
	"\c"	ident

:kw Keyword
	*	idle	noeat

:builtin Builtin
  * idle  noeat

:bool Boolean
  * idle  noeat

:var Variable
  * mark  noeat

:oper Operator
  * idle  noeat

:loop Loop
  * idle  noeat

:cond Conditional
  * idle  noeat

:stmt Statement
  * idle  noeat

:label Label
  * idle  noeat

:struct Structure
  * idle  noeat

:storage StorageClass
  * idle  noeat

.end
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.