php.js

来自「在线编辑器」· JavaScript 代码 · 共 580 行 · 第 1/2 页

JS
580
字号
		'pg_connection_busy pg_connection_reset ' +
		'pg_connection_status pg_convert pg_copy_from ' +
		'pg_copy_to pg_dbname pg_delete ' +
		'pg_end_copy pg_errormessage pg_escape_bytea ' +
		'pg_escape_string pg_exec pg_fetch_all ' +
		'pg_fetch_array pg_fetch_assoc ' +
		'pg_fetch_object pg_fetch_result pg_fetch_row ' +
		'pg_fieldisnull pg_fieldname pg_fieldnum ' +
		'pg_fieldprtlen pg_fieldsize pg_fieldtype ' +
		'pg_field_is_null pg_field_name pg_field_num ' +
		'pg_field_prtlen pg_field_size pg_field_type ' +
		'pg_freeresult pg_free_result pg_getlastoid ' +
		'pg_get_notify pg_get_pid pg_get_result ' +
		'pg_host pg_insert pg_last_error ' +
		'pg_last_notice pg_last_oid pg_loclose ' +
		'pg_locreate pg_loexport pg_loimport ' +
		'pg_loopen pg_loread pg_loreadall ' +
		'pg_lounlink pg_lowrite pg_lo_close ' +
		'pg_lo_create pg_lo_export pg_lo_import ' +
		'pg_lo_open pg_lo_read pg_lo_read_all ' +
		'pg_lo_seek pg_lo_tell pg_lo_unlink ' +
		'pg_lo_write pg_meta_data pg_numfields ' +
		'pg_numrows pg_num_fields pg_num_rows ' +
		'pg_options pg_pconnect pg_ping pg_port ' +
		'pg_put_line pg_query pg_result ' +
		'pg_result_error pg_result_seek ' +
		'pg_result_status pg_select pg_send_query ' +
		'pg_setclientencoding pg_set_client_encoding ' +
		'pg_trace pg_tty pg_unescape_bytea ' +
		'pg_untrace pg_update phpcredits phpinfo ' +
		'phpversion php_ini_scanned_files ' +
		'php_logo_guid php_sapi_name php_uname pi ' +
		'popen pos posix_ctermid posix_errno ' +
		'posix_getcwd posix_getegid posix_geteuid ' +
		'posix_getgid posix_getgrgid posix_getgrnam ' +
		'posix_getgroups posix_getlogin posix_getpgid ' +
		'posix_getpgrp posix_getpid posix_getppid ' +
		'posix_getpwnam posix_getpwuid ' +
		'posix_getrlimit posix_getsid posix_getuid ' +
		'posix_get_last_error posix_isatty posix_kill ' +
		'posix_mkfifo posix_setegid posix_seteuid ' +
		'posix_setgid posix_setpgid posix_setsid ' +
		'posix_setuid posix_strerror posix_times ' +
		'posix_ttyname posix_uname pow preg_grep ' +
		'preg_match preg_match_all preg_quote ' +
		'preg_replace preg_replace_callback ' +
		'preg_split prev print printf print_r ' +
		'proc_close proc_open putenv ' +
		'quoted_printable_decode quotemeta rad2deg ' +
		'rand range rawurldecode rawurlencode ' +
		'readdir readfile readgzfile readlink ' +
		'read_exif_data realpath ' +
		'register_shutdown_function ' +
		'register_tick_function rename reset ' +
		'restore_error_handler restore_include_path ' +
		'rewind rewinddir rmdir round rsort ' +
		'rtrim sem_acquire sem_get sem_release ' +
		'sem_remove serialize session_cache_expire ' +
		'session_cache_limiter session_decode ' +
		'session_destroy session_encode ' +
		'session_get_cookie_params session_id ' +
		'session_is_registered session_module_name ' +
		'session_name session_regenerate_id ' +
		'session_register session_save_path ' +
		'session_set_cookie_params ' +
		'session_set_save_handler session_start ' +
		'session_unregister session_unset ' +
		'session_write_close setcookie setlocale ' +
		'settype set_error_handler set_file_buffer ' +
		'set_include_path set_magic_quotes_runtime ' +
		'set_socket_blocking set_time_limit sha1 ' +
		'sha1_file shell_exec shmop_close ' +
		'shmop_delete shmop_open shmop_read ' +
		'shmop_size shmop_write shm_attach ' +
		'shm_detach shm_get_var shm_put_var ' +
		'shm_remove shm_remove_var show_source ' +
		'shuffle similar_text sin sinh sizeof ' +
		'sleep socket_accept socket_bind ' +
		'socket_clear_error socket_close ' +
		'socket_connect socket_create ' +
		'socket_create_listen socket_create_pair ' +
		'socket_getopt socket_getpeername ' +
		'socket_getsockname socket_get_option ' +
		'socket_get_status socket_iovec_add ' +
		'socket_iovec_alloc socket_iovec_delete ' +
		'socket_iovec_fetch socket_iovec_free ' +
		'socket_iovec_set socket_last_error ' +
		'socket_listen socket_read socket_readv ' +
		'socket_recv socket_recvfrom socket_recvmsg ' +
		'socket_select socket_send socket_sendmsg ' +
		'socket_sendto socket_setopt socket_set_block ' +
		'socket_set_blocking socket_set_nonblock ' +
		'socket_set_option socket_set_timeout ' +
		'socket_shutdown socket_strerror socket_write ' +
		'socket_writev sort soundex split ' +
		'spliti sprintf sql_regcase sqrt srand ' +
		'sscanf stat static strcasecmp strchr ' +
		'strcmp strcoll strcspn ' +
		'stream_context_create ' +
		'stream_context_get_options ' +
		'stream_context_set_option ' +
		'stream_context_set_params stream_filter_append ' +
		'stream_filter_prepend stream_get_meta_data ' +
		'stream_register_wrapper stream_select ' +
		'stream_set_blocking stream_set_timeout ' +
		'stream_set_write_buffer stream_wrapper_register ' +
		'strftime stripcslashes stripslashes ' +
		'strip_tags stristr strlen strnatcasecmp ' +
		'strnatcmp strncasecmp strncmp strpos ' +
		'strrchr strrev strrpos strspn strstr ' +
		'strtok strtolower strtotime strtoupper ' +
		'strtr strval str_pad str_repeat ' +
		'str_replace str_rot13 str_shuffle ' +
		'str_word_count substr substr_count ' +
		'substr_replace symlink syslog system ' +
		'tan tanh tempnam textdomain time ' +
		'tmpfile token_get_all token_name touch ' +
		'trigger_error trim uasort ucfirst ' +
		'ucwords uksort umask uniqid unixtojd ' +
		'unlink unpack unregister_tick_function ' +
		'unserialize unset urldecode urlencode ' +
		'user_error usleep usort utf8_decode ' +
		'utf8_encode var_dump var_export ' +
		'version_compare virtual vprintf vsprintf ' +
		'wddx_add_vars wddx_deserialize ' +
		'wddx_packet_end wddx_packet_start ' +
		'wddx_serialize_value wddx_serialize_vars ' +
		'wordwrap xml_error_string ' +
		'xml_get_current_byte_index ' +
		'xml_get_current_column_number ' +
		'xml_get_current_line_number xml_get_error_code ' +
		'xml_parse xml_parser_create ' +
		'xml_parser_create_ns xml_parser_free ' +
		'xml_parser_get_option xml_parser_set_option ' +
		'xml_parse_into_struct ' +
		'xml_set_character_data_handler ' +
		'xml_set_default_handler xml_set_element_handler ' +
		'xml_set_end_namespace_decl_handler ' +
		'xml_set_external_entity_ref_handler ' +
		'xml_set_notation_decl_handler xml_set_object ' +
		'xml_set_processing_instruction_handler ' +
		'xml_set_start_namespace_decl_handler ' +
		'xml_set_unparsed_entity_decl_handler yp_all ' +
		'yp_cat yp_errno yp_err_string yp_first ' +
		'yp_get_default_domain yp_master yp_match ' +
		'yp_next yp_order zend_logo_guid ' +
		'zend_version zlib_get_coding_type'.split(" "),

    punctuation: '{ } ?> <?= <?php > < / + - % * . , ; ( ) ? : = " \''.split(" "),

    highlight: function(line, meta) {           
        if (!meta) meta = {};

        var K = bespin.syntax.PHPConstants;    // aliasing the constants for shorter reference ;-)

        var regions = {};                               // contains the individual style types as keys, with array of start/stop positions as value

        // current state, maintained as we parse through each character in the line; values at any time should be consistent
        var currentStyle = (meta.inMultilineComment) ? K.C_STYLE_COMMENT : undefined;
        var currentRegion = {}; // should always have a start property for a non-blank buffer
        var buffer = "";

        // these properties are related to the parser state above but are special cases
        var stringChar = "";    // the character used to start the current string
        var multiline = meta.inMultilineComment;

        for (var i = 0; i < line.length; i++) {
            var c = line.charAt(i);

            // check if we're in a comment and whether this character ends the comment
            if (currentStyle == K.C_STYLE_COMMENT) {
                if (c == "/" && /\*$/.test(buffer)) { // has the c-style comment just ended?
                    currentRegion.stop = i + 1;
                    this.addRegion(regions, currentStyle, currentRegion);
                    currentRegion = {};
                    currentStyle = undefined;
                    multiline = false;
                    buffer = "";
                } else {
                    if (buffer == "") currentRegion = { start: i };
                    buffer += c;
                }

                continue;
            }

            if (this.isWhiteSpaceOrPunctuation(c)) {
                // check if we're in a string
                if (currentStyle == K.STRING) {
                    // if this is not an unescaped end quote (either a single quote or double quote to match how the string started) then keep going
                    if ( ! (c == stringChar && !/\\$/.test(buffer))) { 
                        if (buffer == "") currentRegion = { start: i };
                        buffer += c;
                        continue;
                    }
                }

                // if the buffer is full, add it to the regions
                if (buffer != "") {
                    currentRegion.stop = i;

                    if (currentStyle != K.STRING) {   // if this is a string, we're all set to add it; if not, figure out if its a keyword
                        if (this.keywords.indexOf(buffer) != -1) {
                            // the buffer contains a keyword
                            currentStyle = K.KEYWORD;
                        } else {
                            currentStyle = K.OTHER;
                        }
                    }
                    this.addRegion(regions, currentStyle, currentRegion);
                    currentRegion = {};
                    stringChar = "";
                    buffer = "";
                    // i don't clear the current style here so I can check if it was a string below
                }

                if (this.isPunctuation(c)) {
                    if (c == "*" && i > 0 && (line.charAt(i - 1) == "/")) {
                        // remove the previous region in the punctuation bucket, which is a forward slash
                        regions[K.PUNCTUATION].pop();

                        // we are in a c-style comment
                        multiline = true;
                        currentStyle = K.C_STYLE_COMMENT;
                        currentRegion = { start: i - 1 };
                        buffer = "/*";
                        continue;
                    }

                    // check for a line comment; this ends the parsing for the rest of the line
                    if (c == '/' && i > 0 && (line.charAt(i - 1) == '/')) {
                        currentRegion = { start: i - 1, stop: line.length };
                        currentStyle = K.LINE_COMMENT;
                        this.addRegion(regions, currentStyle, currentRegion);
                        buffer = "";
                        currentStyle = undefined;
                        currentRegion = {};
                        break;      // once we get a line comment, we're done!
                    }

                    // add an ad-hoc region for just this one punctuation character
                    this.addRegion(regions, K.PUNCTUATION, { start: i, stop: i + 1 });
                }

                // find out if the current quote is the end or the beginning of the string
                if ((c == "'" || c == '"') && (currentStyle != K.STRING)) {
                    currentStyle = K.STRING;
                    stringChar = c;
                } else {
                    currentStyle = undefined;
                }

                continue;
            }

            if (buffer == "") currentRegion = { start: i };
            buffer += c;
        }

        // check for a trailing character inside of a string or a comment
        if (buffer != "") {
            if (!currentStyle) currentStyle = K.OTHER;
            currentRegion.stop = line.length;
            this.addRegion(regions, currentStyle, currentRegion);
        }

        return { regions: regions, meta: { inMultilineComment: multiline } };
    },

    addRegion: function(regions, type, data) {
        if (!regions[type]) regions[type] = [];
        regions[type].push(data);
    },

    isWhiteSpaceOrPunctuation: function(ch) {
        return this.isPunctuation(ch) || this.isWhiteSpace(ch);
    },

    isPunctuation: function(ch) {
        return this.punctuation.indexOf(ch) != -1;
    },

    isWhiteSpace: function(ch) {
        return ch == " ";
    }
});

// Register
bespin.syntax.EngineResolver.register(new bespin.syntax.PHPSyntaxEngine(), ['php', 'php3', 'php4', 'php5']);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?