Open GoogleCodeExporter opened 8 years ago
// lang-php.js
PR.registerLangHandler(
PR.createSimpleLexer(
[
// Whitespace is made up of spaces, tabs and newline characters.
[PR.PR_PLAIN, /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'],
[PR.PR_STRING,
/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,
null, '"\'']
],
[
[PR.PR_KEYWORD,
/^\b(and|or|xor|__FILE__|exception|__LINE__|array|as|break|case|class|const|cont
inue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|
endif|endswitch|endwhild|eval|exit|extends|for|foreach|function|global|if|includ
e|include_once|isset|list|new|print|require|require_once|return|static|switch|un
set|use|var|while|__FUNCTION__|__CLASS__|__METHOD__|final|php_user_filter|interf
ace|implements|instanceof|public|private|protected|abstract|clone|try|catch|thro
w|cfunction|old_function|this|final|__NAMESPACE__|namespace|goto|__DIR__|true|fa
lse|null|TRUE|FALSE|NULL)\b/i,
null],
[PR.PR_COMMENT, /^\/\/[^\r\n]*/, null],
[PR.PR_COMMENT, /^\/\*[\s\S]*?(?:\*\/|$)/, null],
[PR.PR_LITERAL,
new RegExp(
'^(?:'
// A hex number
+ '0x[a-f0-9]+'
// or an octal or decimal number,
+ '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)'
// possibly in scientific notation
+ '(?:e[+\\-]?\\d+)?'
+ ')'
// with an optional modifier like UL for unsigned long
+ '[a-z]*', 'i'),
null, '0123456789'],
[PR.PR_VARIABLE, /^(?:\$+\w+)/i]
]
),
['php', 'phtml', 'php5', 'php4']
);
EOF
I realize there is no "PR_VARIABLE" - I hacked the JS/CSS to add it... which I
realize is counter to the point of using an external lang file >_>
This lang file is probably not perfect, but it's held out for me pretty well so
far.
Original comment by bent...@gmail.com
on 30 Sep 2009 at 5:41
Original comment by mikesamuel@gmail.com
on 2 Oct 2009 at 5:37
This language handler gives a silent error on some of my pages and stopps
prettify from starting. The console is empty so i can't give a proper error
report. If you wish i can provide a link to the problematic pages, but i won't
post them here for security reasons. You can reach me by mail: f1r3fl3x ]@[
gmail.com
Original comment by F1r3F...@gmail.com
on 2 Oct 2010 at 9:21
hm! I stopped developing this patch a long time ago, and am not particularly
interested in working on it further. sorry :| but if anyone else wants to
modify or add to it, they should definitely feel free to do so.
if my code is neither insignificant enough to be uncopyrightable, nor, as being
a patch for the google-code-prettify project, is not already under the Apache
License 2.0, then I'd like to release it to the public domain under the CC0 1.0
Universal
Public Domain Dedication license:
http://creativecommons.org/publicdomain/zero/1.0/
Original comment by bent...@gmail.com
on 29 Dec 2010 at 5:02
Original issue reported on code.google.com by
keith.ga...@gmail.com
on 14 Jan 2008 at 4:38Attachments: