Skip to content

Commit c31b782

Browse files
authored
Merge pull request #25 from davidhcefx/php-tidy
enh(php): Tidy up regex rules
2 parents 05c339f + aaa9d6c commit c31b782

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

php.nanorc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,28 @@ syntax "PHP" "\.php[2345s~]?$|\.module$"
33
header "^#!.*php"
44
magic "PHP script"
55
comment "//"
6+
7+
# Default
68
color white start="<\?(php|=)?" end="\?>"
79
# Constructs
810
color brightblue "(class|extends|goto) ([a-zA-Z0-9_]*)"
9-
color brightblue "[^a-z0-9_-]{1}(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|endif|foreach|endforeach|@|while|public|private|protected|return|const|static|extends|as|array|require|include|require_once|include_once|define|do|continue|declare|goto|print|in|namespace|use)[^a-z0-9_-]{1}"
11+
color brightblue "\<(var|class|function|echo|case|break|default|exit|switch|if|else|elseif|endif|foreach|endforeach|@|while|public|private|protected|return|const|static|extends|as|array|require|include|require_once|include_once|define|do|continue|declare|goto|print|in|namespace|use)\>"
1012
color brightblue "[a-zA-Z0-9_]+:"
1113
# Variables
12-
color green "\$[a-zA-Z_0-9$]*|[=!<>]"
13-
color green "\->[a-zA-Z_0-9$]*|[=!<>]"
14+
#color green "\$[a-zA-Z_0-9$]*|[=!<>]"
15+
#color green "\->[a-zA-Z_0-9$]*|[=!<>]"
16+
color green "\$[a-zA-Z_0-9]*"
17+
color green "\->[a-zA-Z_0-9]*"
1418
# Functions
1519
color brightblue "([a-zA-Z0-9_-]*)\("
1620
# Special values
17-
color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)$"
18-
color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)[^A-Za-z0-9_-]{1}"
21+
color brightmagenta "\<(true|false|null|TRUE|FALSE|NULL)\>"
1922
# Special Characters
2023
color yellow "[.,{}();]"
2124
color cyan "\["
2225
color cyan "\]"
2326
# Numbers
24-
color magenta "[+-]*([0-9]\.)*[0-9]+([eE][+-]?([0-9]\.)*[0-9])*"
27+
color magenta "\<[+-]?([0-9]*\.)?[0-9]+([eE][+-]?[0-9]+)?\>"
2528
color magenta "0x[0-9a-zA-Z]*"
2629
# Special Variables
2730
color brightblue "(\$this|parent::|self::|\$this->)"
@@ -30,26 +33,25 @@ color magenta ";"
3033
color yellow "(<|>)"
3134
# Assignment operator
3235
color brightblue "="
33-
# Bitwise Operations
36+
# Bitwise operators
3437
color magenta "(&|\||\^)"
3538
color magenta "(<<|>>)"
3639
# Comparison operators
3740
color yellow "(==|===|!=|<>|!==|<=|>=|<=>)"
3841
# Logical Operators
39-
color yellow "( and | or | xor |!|&&|\|\|)"
40-
# And/Or/SRO/etc
41-
color cyan "(\;\;|\|\||::|=>|->)"
42+
color yellow "\<(and|or|xor)\>" "(!|&&|\|\|)"
43+
# SRO and other operators
44+
color cyan "(\;\;|::|=>|->)"
4245
# Double quoted STRINGS!
43-
color red "(\"[^\"]*\")"
46+
color red "\"([^"\]|\\.)*\""
47+
# Single quoted string
48+
color red "'([^'\]|\\.)*'"
4449
# Heredoc (typically ends with a semicolon).
45-
color red start="<<<['\"]?[A-Z][A-Z0-9_]*['\"]?" end="^[A-Z][A-Z0-9_]*;"
50+
color red start="<<<[\"]?[A-Z][A-Z0-9_]*[\"]?" end="^[A-Z][A-Z0-9_]*;"
4651
# Inline Variables
4752
color white "\{\$[^}]*\}"
48-
# Single quoted string
49-
color red "('[^']*')"
5053
# Online Comments
51-
color brightyellow "^(#.*|//.*)$"
52-
color brightyellow "[ | ](#.*|//.*)$"
54+
color brightyellow "(^|[[:blank:]])(#.*|//.*)$"
5355
# PHP Tags
5456
color red "(<\?(php)?|\?>)"
5557
# General HTML

0 commit comments

Comments
 (0)