imanex / nanosyntax

Automatically exported from code.google.com/p/nanosyntax
0 stars 0 forks source link

better PHP config #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I found the php.nanorc's out there lacking, so here's mine. Still working
on it but it's fairly good for daily use, at least for me.

Thanks.

BEGIN--------------------

syntax "php" "\.php[2345s~]?$"

## HTML (assume everything is HTML until proven otherwise)
color white,blue "^.+$"

## PHP
color white,black start="<\?php" end="\?>"

## strings, part 1
#malformed
color magenta,yellow "('|")"
#override not malformed
color brightmagenta start="['"]" end="[^\\]['"]"

## functions
icolor white start="[a-z_0-9]+\(" end=")[\);,$]*"

## variables
icolor brightred "\$[a-z_0-9]+"
color brightred start="\$\{" end="\}"

## types
color green "([^\$]|^)\<(var|float|global|double|bool|char|int|enum|const)\>"

## constants (assume constants are ALL_CAPS)
color red "\<[A-Z_0-9]*\>"

## numbers
#decimal
color yellow "\<\-?[0-9\.]+\>"
#hex
icolor yellow,blue "\<0x[0-9a-f]+\>"
#octal
color yellow,green "\<0[0-7]+\>"
#boolean
icolor cyan "([^\$]|^)\<(true|false)\>"

## structure
#note, $class is a variable, class is not.
color brightyellow
"([^\$]|^)\<(class|new|private|public|function|for|foreach|if|while|do|else|else
if|case|default|switch)\>"

## control flow
color brightblue "([^\$]|^)\<(goto|continue|break|return)\>"

## operators
color green
"(\^|\&|\||=|==|===|&&|\|\||\!==?|>|<|\.=?|->|::|\+|\-|\*|\/|\!|\!=|\!==|%=|\*=|
\+=|\-=|\/=)"

## braces
color white "(\{|\(|\)|\})"

##sad wee end brackets etc
color white "^[[:blank:]]*([\)\}][,;]?[[:blank:]]*)*$"

## strings
color brightmagenta "'([^']*\\')*[^']*'"
color brightmagenta ""(\.|[^"])*""

#kind of a hack here since backrefs don't work with start and end apparently
color brightmagenta start="<<<(.*)" end=";$"

## control flow
color brightblue "([^\$]|^)\<(goto|continue|break|return)\>"

# vars in strings
icolor brightred "\$[a-z0-9_]*"

## comments
color blue "[^:]//.*"
color blue "^//.*"
color blue "(^|[^'"]+)#.*"
color blue start="/\*" end="\*/"

##HTML again
color white,blue start="\?>" end="<\?php"
color white,blue start="" end="<\?php"
color white,blue start="\?>" end=".$"
#color brightred,blue "&[^&]"
icolor cyan,blue "&[a-z0-9#]{2,8};"

## Trailing whitespace
color ,white "[[:blank:]]+$"

## php markings
color brightgreen "(<\?(php)?|\?>)"

Original issue reported on code.google.com by rod.mcfa...@gmail.com on 16 Oct 2009 at 5:16