summaryrefslogtreecommitdiff
path: root/sheets/php.ssh
blob: edf85fa9384969e2edd777e499d6b83e4c195acd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Style sheet for PHP
# Copyright (c) 2000 Hartmut Holzgraefe
# $Id: php.ssh,v 1.1.2.2 2007/12/29 01:58:31 mhatta Exp $ 
#

#
# This file is part of a2ps.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

style PHP is
requires a2ps 4.12

written by "Hartmut Holzgraefe <hartmut@six.de>"
version is 0.1
documentation is
"This is a a2ps stylesheet for PHP syntax highlighting "
"(just the PHP part, HTML is left 'as is'). "
"This is my first try on a2ps stylesheets. "
"It works OK for me. If it doesn't come up to "
"your expectatios, then please tell me."
end documentation

first alphabet is
   "abcdefghijklmnopqrstuvwxyz_"
second alphabet is
   "0123456789abcdefghijklmnopqrstuvwxyz_"
case insensitive

keywords in Keyword are
  class, extends, include, require, new
end keywords

keywords in Keyword_strong are
   true, false, 
   return, continue, for, 
   switch, do
   "case", default, break, if, while, else, elseif, 
   endif, endfor, endwhile, endswitch,
   print, echo
end keywords

optional operators are
   -> \rightarrow,
   && \wedge,
   || \vee,
   != \neq,
   == \equiv,
   # We need to protect these, so that <= is not replaced in <<=
   <= \leq,
   >= \geq,
   ! \not
end operators

# Function declaration
operators in Plain are
  # variables
  /\\$[a-z_][a-z_0-9]*/ Label_strong,
  # Functions calls
  /\\(&[[:alnum:]_]+\\)/ Label_strong,
  # Function defs.
  (/^\\([ \t]*\\)\\(function\\)\\([ \t]*\\)\\([a-z_][a-z_0-9]*\\)\\([ \t]*\\)/
        \1 Plain , \2 Label_strong , \3 Plain , \4 Label_strong  , \5 Plain , "(" Plain)
end operators


operators in Keyword_strong are
  "<?", "<?php", "<?=", "?>",
  "<%", "%>",
  (/<\\([^>]*\\)>/ "<", \1, ">")
end operators

sequences are
    "/*" Comment "*/",
    "//" Comment,
    "#" Comment,
    "<!--" Comment "-->",
    C-string,
    C-char,
    "case " Keyword_strong Label : Plain
	exceptions are
	  "':'"
	end exceptions,
  # Tags with arguments (E.g., <a>, <img>, <table>...)
  (/<\\([[:alpha:]]+\\) / "<" Keyword_strong, \1 Keyword_strong, " " Plain) Keyword ">" Keyword_strong
    # Exceptions are double-quoted strings inside tags
    exceptions are
        (/"\\(\\([^"]\\|\\\\.\\)*\\)"/ "\"" Plain, \1 String, "\"" Plain)
    end exceptions
end sequences

end style