Skip to content

Commit

Permalink
Merge pull request #25 from davidhcefx/php-tidy
Browse files Browse the repository at this point in the history
enh(php): Tidy up regex rules
  • Loading branch information
galenguyer authored Apr 5, 2024
2 parents 05c339f + aaa9d6c commit c31b782
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions php.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,28 @@ syntax "PHP" "\.php[2345s~]?$|\.module$"
header "^#!.*php"
magic "PHP script"
comment "//"

# Default
color white start="<\?(php|=)?" end="\?>"
# Constructs
color brightblue "(class|extends|goto) ([a-zA-Z0-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}"
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)\>"
color brightblue "[a-zA-Z0-9_]+:"
# Variables
color green "\$[a-zA-Z_0-9$]*|[=!<>]"
color green "\->[a-zA-Z_0-9$]*|[=!<>]"
#color green "\$[a-zA-Z_0-9$]*|[=!<>]"
#color green "\->[a-zA-Z_0-9$]*|[=!<>]"
color green "\$[a-zA-Z_0-9]*"
color green "\->[a-zA-Z_0-9]*"
# Functions
color brightblue "([a-zA-Z0-9_-]*)\("
# Special values
color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)$"
color brightmagenta "[^a-z0-9_-]{1}(true|false|null|TRUE|FALSE|NULL)[^A-Za-z0-9_-]{1}"
color brightmagenta "\<(true|false|null|TRUE|FALSE|NULL)\>"
# Special Characters
color yellow "[.,{}();]"
color cyan "\["
color cyan "\]"
# Numbers
color magenta "[+-]*([0-9]\.)*[0-9]+([eE][+-]?([0-9]\.)*[0-9])*"
color magenta "\<[+-]?([0-9]*\.)?[0-9]+([eE][+-]?[0-9]+)?\>"
color magenta "0x[0-9a-zA-Z]*"
# Special Variables
color brightblue "(\$this|parent::|self::|\$this->)"
Expand All @@ -30,26 +33,25 @@ color magenta ";"
color yellow "(<|>)"
# Assignment operator
color brightblue "="
# Bitwise Operations
# Bitwise operators
color magenta "(&|\||\^)"
color magenta "(<<|>>)"
# Comparison operators
color yellow "(==|===|!=|<>|!==|<=|>=|<=>)"
# Logical Operators
color yellow "( and | or | xor |!|&&|\|\|)"
# And/Or/SRO/etc
color cyan "(\;\;|\|\||::|=>|->)"
color yellow "\<(and|or|xor)\>" "(!|&&|\|\|)"
# SRO and other operators
color cyan "(\;\;|::|=>|->)"
# Double quoted STRINGS!
color red "(\"[^\"]*\")"
color red "\"([^"\]|\\.)*\""
# Single quoted string
color red "'([^'\]|\\.)*'"
# Heredoc (typically ends with a semicolon).
color red start="<<<['\"]?[A-Z][A-Z0-9_]*['\"]?" end="^[A-Z][A-Z0-9_]*;"
color red start="<<<[\"]?[A-Z][A-Z0-9_]*[\"]?" end="^[A-Z][A-Z0-9_]*;"
# Inline Variables
color white "\{\$[^}]*\}"
# Single quoted string
color red "('[^']*')"
# Online Comments
color brightyellow "^(#.*|//.*)$"
color brightyellow "[ | ](#.*|//.*)$"
color brightyellow "(^|[[:blank:]])(#.*|//.*)$"
# PHP Tags
color red "(<\?(php)?|\?>)"
# General HTML
Expand Down

0 comments on commit c31b782

Please sign in to comment.