Raised CodeMirror to version 0.9.3
authorSteffen Kamper <info@sk-typo3.de>
Wed, 9 Feb 2011 11:51:06 +0000 (11:51 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 9 Feb 2011 11:51:06 +0000 (11:51 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10427 709f56b5-9817-0410-a4d7-c38de5d9e867

13 files changed:
typo3/contrib/codemirror/contrib/csharp/index.html
typo3/contrib/codemirror/contrib/csharp/js/parsecsharp.js
typo3/contrib/codemirror/contrib/ometa/index.html
typo3/contrib/codemirror/contrib/php/js/parsephp.js
typo3/contrib/codemirror/contrib/php/js/tokenizephp.js
typo3/contrib/codemirror/contrib/plsql/index.html
typo3/contrib/codemirror/contrib/python/js/parsepython.js
typo3/contrib/codemirror/contrib/scheme/index.html
typo3/contrib/codemirror/contrib/scheme/js/parsescheme.js [new file with mode: 0644]
typo3/contrib/codemirror/contrib/scheme/js/tokenizescheme.js [new file with mode: 0644]
typo3/contrib/codemirror/contrib/sql/css/sqlcolors.css
typo3/contrib/codemirror/contrib/sql/index.html
typo3/contrib/codemirror/contrib/sql/js/parsesql.js

index 3b128f3..e846f02 100644 (file)
@@ -11,7 +11,7 @@
 <p>Written by <a href="http://skilltesting.com/">Boris Gaber and Christopher Buchino</a> (<a
 href="http://skilltesting.com/codemirror-parser-license/">license</a>).</p>
 
-<div class="border">
+<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
 <textarea id="code" cols="120" rows="50">
 using System;
 
index 10dcb41..2145711 100644 (file)
@@ -283,6 +283,7 @@ var JSParser = Editor.Parser = (function() {
     // For loops.
     function forspec1(type){
       if (type == "var") cont(vardef1, forspec2);
+      else if (type == "keyword d") cont(vardef1, forspec2);
       else if (type == ";") pass(forspec2);
       else if (type == "variable") cont(formaybein);
       else pass(forspec2);
index 7bf59fd..bd25d6a 100644 (file)
@@ -12,7 +12,7 @@
 <p>Adapted from the official Javascript parser by Eric KEDJI
   &lt;<a href="mailto:eric.kedji@gmail.com">eric.kedji@gmail.com</a>&gt;.</p>
 
-<div class="border">
+<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
 <textarea id="code" cols="120" rows="30">
 // Source: http://www.tinlizzie.org/ometa-js/#Lisp
 // Inspired by McCarthy's meta-circular lisp
index 9823195..7d0ad1f 100644 (file)
@@ -221,7 +221,8 @@ var PHPParser = Editor.Parser = (function() {
     }
     // Pop off the current lexical context.
     function poplex(){
-      lexical = lexical.prev;
+      if (lexical.prev)
+        lexical = lexical.prev;
     }
     poplex.lex = true;
     // The 'lex' flag on these actions is used by the 'next' function
@@ -252,9 +253,8 @@ var PHPParser = Editor.Parser = (function() {
         else
           ok = wanted.indexOf(type);
         if (ok >= 0) {
-          if (execute && typeof(execute[ok]) == "function")
-            execute[ok](token);
-            cont();  // just consume the token
+          if (execute && typeof(execute[ok]) == "function") pass(execute[ok]);
+          else cont();
         }
         else {
           if (!marked) mark(token.style);
@@ -272,7 +272,7 @@ var PHPParser = Editor.Parser = (function() {
     function statement(token){
       var type = token.type;
       if (type == "keyword a") cont(pushlex("form"), expression, altsyntax, statement, poplex);
-      else if (type == "keyword b") cont(pushlex("form"), statement, poplex);
+      else if (type == "keyword b") cont(pushlex("form"), altsyntax, statement, poplex);
       else if (type == "{") cont(pushlex("}"), block, poplex);
       else if (type == "function") funcdef();
       // technically, "class implode {...}" is correct, but we'll flag that as an error because it overrides a predefined function
@@ -280,7 +280,8 @@ var PHPParser = Editor.Parser = (function() {
       else if (type == "foreach") cont(pushlex("form"), require("("), pushlex(")"), expression, require("as"), require("variable"), /* => $value */ expect(")"), altsyntax, poplex, statement, poplex);
       else if (type == "for") cont(pushlex("form"), require("("), pushlex(")"), expression, require(";"), expression, require(";"), expression, require(")"), altsyntax, poplex, statement, poplex);
       // public final function foo(), protected static $bar;
-      else if (type == "modifier") cont(require(["modifier", "variable", "function", "abstract"], [null, null, funcdef, absfun]));
+      else if (type == "modifier") cont(require(["modifier", "variable", "function", "abstract"],
+                                                [null, commasep(require("variable")), funcdef, absfun]));
       else if (type == "abstract") abs();
       else if (type == "switch") cont(pushlex("form"), require("("), expression, require(")"), pushlex("}", "switch"), require([":", "{"]), block, poplex, poplex);
       else if (type == "case") cont(expression, require(":"));
index 8b14458..39041dc 100644 (file)
@@ -463,7 +463,127 @@ var tokenizePHP = (function() {
       "xdebug_get_collected_errors", "xdebug_start_code_coverage",
       "xdebug_stop_code_coverage", "xdebug_get_code_coverage",
       "xdebug_get_function_count", "xdebug_dump_superglobals",
-      "_" // alias for gettext()
+      "_", /* alias for gettext()*/ 
+      "get_called_class","class_alias","gc_collect_cycles","gc_enabled","gc_enable",
+      "gc_disable","date_create_from_format","date_parse_from_format",
+      "date_get_last_errors","date_add","date_sub","date_diff","date_timestamp_set",
+      "date_timestamp_get","timezone_location_get","timezone_version_get",
+      "date_interval_create_from_date_string","date_interval_format",
+      "libxml_disable_entity_loader","openssl_pkey_free","openssl_pkey_new",
+      "openssl_pkey_export","openssl_pkey_export_to_file","openssl_pkey_get_private",
+      "openssl_pkey_get_public","openssl_pkey_get_details","openssl_free_key",
+      "openssl_get_privatekey","openssl_get_publickey","openssl_x509_read",
+      "openssl_x509_free","openssl_x509_parse","openssl_x509_checkpurpose",
+      "openssl_x509_check_private_key","openssl_x509_export","openssl_x509_export_to_file",
+      "openssl_pkcs12_export","openssl_pkcs12_export_to_file","openssl_pkcs12_read",
+      "openssl_csr_new","openssl_csr_export","openssl_csr_export_to_file",
+      "openssl_csr_sign","openssl_csr_get_subject","openssl_csr_get_public_key",
+      "openssl_digest","openssl_encrypt","openssl_decrypt","openssl_cipher_iv_length",
+      "openssl_sign","openssl_verify","openssl_seal","openssl_open","openssl_pkcs7_verify",
+      "openssl_pkcs7_decrypt","openssl_pkcs7_sign","openssl_pkcs7_encrypt",
+      "openssl_private_encrypt","openssl_private_decrypt","openssl_public_encrypt",
+      "openssl_public_decrypt","openssl_get_md_methods","openssl_get_cipher_methods",
+      "openssl_dh_compute_key","openssl_random_pseudo_bytes","openssl_error_string",
+      "preg_filter","bzopen","bzread","bzwrite","bzflush","bzclose","bzerrno",
+      "bzerrstr","bzerror","bzcompress","bzdecompress","curl_init","curl_copy_handle",
+      "curl_version","curl_setopt","curl_setopt_array","curl_exec","curl_getinfo",
+      "curl_error","curl_errno","curl_close","curl_multi_init","curl_multi_add_handle",
+      "curl_multi_remove_handle","curl_multi_select","curl_multi_exec","curl_multi_getcontent",
+      "curl_multi_info_read","curl_multi_close","exif_read_data","read_exif_data",
+      "exif_tagname","exif_thumbnail","exif_imagetype","ftp_ssl_connect",
+      "imagecolorclosesthwb","imagecreatefromxpm","textdomain","gettext","dgettext",
+      "dcgettext","bindtextdomain","ngettext","dngettext","dcngettext",
+      "bind_textdomain_codeset","hash_copy","imap_open","imap_reopen","imap_close",
+      "imap_num_msg","imap_num_recent","imap_headers","imap_headerinfo",
+      "imap_rfc822_parse_headers","imap_rfc822_write_address","imap_rfc822_parse_adrlist",
+      "imap_body","imap_bodystruct","imap_fetchbody","imap_savebody","imap_fetchheader",
+      "imap_fetchstructure","imap_gc","imap_expunge","imap_delete","imap_undelete",
+      "imap_check","imap_listscan","imap_mail_copy","imap_mail_move","imap_mail_compose",
+      "imap_createmailbox","imap_renamemailbox","imap_deletemailbox","imap_subscribe",
+      "imap_unsubscribe","imap_append","imap_ping","imap_base64","imap_qprint","imap_8bit",
+      "imap_binary","imap_utf8","imap_status","imap_mailboxmsginfo","imap_setflag_full",
+      "imap_clearflag_full","imap_sort","imap_uid","imap_msgno","imap_list","imap_lsub",
+      "imap_fetch_overview","imap_alerts","imap_errors","imap_last_error","imap_search",
+      "imap_utf7_decode","imap_utf7_encode","imap_mime_header_decode","imap_thread",
+      "imap_timeout","imap_get_quota","imap_get_quotaroot","imap_set_quota","imap_setacl",
+      "imap_getacl","imap_mail","imap_header","imap_listmailbox","imap_getmailboxes",
+      "imap_scanmailbox","imap_listsubscribed","imap_getsubscribed","imap_fetchtext",
+      "imap_scan","imap_create","imap_rename","json_last_error","mb_encoding_aliases",
+      "mcrypt_ecb","mcrypt_cbc","mcrypt_cfb","mcrypt_ofb","mcrypt_get_key_size",
+      "mcrypt_get_block_size","mcrypt_get_cipher_name","mcrypt_create_iv","mcrypt_list_algorithms",
+      "mcrypt_list_modes","mcrypt_get_iv_size","mcrypt_encrypt","mcrypt_decrypt",
+      "mcrypt_module_open","mcrypt_generic_init","mcrypt_generic","mdecrypt_generic",
+      "mcrypt_generic_end","mcrypt_generic_deinit","mcrypt_enc_self_test",
+      "mcrypt_enc_is_block_algorithm_mode","mcrypt_enc_is_block_algorithm",
+      "mcrypt_enc_is_block_mode","mcrypt_enc_get_block_size","mcrypt_enc_get_key_size",
+      "mcrypt_enc_get_supported_key_sizes","mcrypt_enc_get_iv_size",
+      "mcrypt_enc_get_algorithms_name","mcrypt_enc_get_modes_name","mcrypt_module_self_test",
+      "mcrypt_module_is_block_algorithm_mode","mcrypt_module_is_block_algorithm",
+      "mcrypt_module_is_block_mode","mcrypt_module_get_algo_block_size",
+      "mcrypt_module_get_algo_key_size","mcrypt_module_get_supported_key_sizes",
+      "mcrypt_module_close","mysqli_refresh","posix_kill","posix_getpid","posix_getppid",
+      "posix_getuid","posix_setuid","posix_geteuid","posix_seteuid","posix_getgid",
+      "posix_setgid","posix_getegid","posix_setegid","posix_getgroups","posix_getlogin",
+      "posix_getpgrp","posix_setsid","posix_setpgid","posix_getpgid","posix_getsid",
+      "posix_uname","posix_times","posix_ctermid","posix_ttyname","posix_isatty",
+      "posix_getcwd","posix_mkfifo","posix_mknod","posix_access","posix_getgrnam",
+      "posix_getgrgid","posix_getpwnam","posix_getpwuid","posix_getrlimit",
+      "posix_get_last_error","posix_errno","posix_strerror","posix_initgroups",
+      "pspell_new","pspell_new_personal","pspell_new_config","pspell_check",
+      "pspell_suggest","pspell_store_replacement","pspell_add_to_personal",
+      "pspell_add_to_session","pspell_clear_session","pspell_save_wordlist",
+      "pspell_config_create","pspell_config_runtogether","pspell_config_mode",
+      "pspell_config_ignore","pspell_config_personal","pspell_config_dict_dir",
+      "pspell_config_data_dir","pspell_config_repl","pspell_config_save_repl",
+      "snmpget","snmpgetnext","snmpwalk","snmprealwalk","snmpwalkoid",
+      "snmp_get_quick_print","snmp_set_quick_print","snmp_set_enum_print",
+      "snmp_set_oid_output_format","snmp_set_oid_numeric_print","snmpset",
+      "snmp2_get","snmp2_getnext","snmp2_walk","snmp2_real_walk","snmp2_set",
+      "snmp3_get","snmp3_getnext","snmp3_walk","snmp3_real_walk","snmp3_set",
+      "snmp_set_valueretrieval","snmp_get_valueretrieval","snmp_read_mib",
+      "use_soap_error_handler","is_soap_fault","socket_create_pair","time_nanosleep",
+      "time_sleep_until","strptime","php_ini_loaded_file","money_format","lcfirst",
+      "nl_langinfo","str_getcsv","readlink","linkinfo","symlink","link","proc_nice",
+      "atanh","asinh","acosh","expm1","log1p","inet_ntop","inet_pton","getopt",
+      "sys_getloadavg","getrusage","quoted_printable_encode","forward_static_call",
+      "forward_static_call_array","header_remove","parse_ini_string","gethostname",
+      "dns_check_record","checkdnsrr","dns_get_mx","getmxrr","dns_get_record",
+      "stream_context_get_params","stream_context_set_default","stream_socket_pair",
+      "stream_supports_lock","stream_set_read_buffer","stream_resolve_include_path",
+      "stream_is_local","fnmatch","chroot","lchown","lchgrp","realpath_cache_size",
+      "realpath_cache_get","array_replace","array_replace_recursive","ftok","xmlrpc_encode",
+      "xmlrpc_decode","xmlrpc_decode_request","xmlrpc_encode_request","xmlrpc_get_type",
+      "xmlrpc_set_type","xmlrpc_is_fault","xmlrpc_server_create","xmlrpc_server_destroy",
+      "xmlrpc_server_register_method","xmlrpc_server_call_method",
+      "xmlrpc_parse_method_descriptions","xmlrpc_server_add_introspection_data",
+      "xmlrpc_server_register_introspection_callback","zip_open","zip_close",
+      "zip_read","zip_entry_open","zip_entry_close","zip_entry_read","zip_entry_filesize",
+      "zip_entry_name","zip_entry_compressedsize","zip_entry_compressionmethod",
+      "svn_checkout","svn_cat","svn_ls","svn_log","svn_auth_set_parameter",
+      "svn_auth_get_parameter","svn_client_version","svn_config_ensure","svn_diff",
+      "svn_cleanup","svn_revert","svn_resolved","svn_commit","svn_lock","svn_unlock",
+      "svn_add","svn_status","svn_update","svn_import","svn_info","svn_export",
+      "svn_copy","svn_switch","svn_blame","svn_delete","svn_mkdir","svn_move",
+      "svn_proplist","svn_propget","svn_repos_create","svn_repos_recover",
+      "svn_repos_hotcopy","svn_repos_open","svn_repos_fs",
+      "svn_repos_fs_begin_txn_for_commit","svn_repos_fs_commit_txn",
+      "svn_fs_revision_root","svn_fs_check_path","svn_fs_revision_prop",
+      "svn_fs_dir_entries","svn_fs_node_created_rev","svn_fs_youngest_rev",
+      "svn_fs_file_contents","svn_fs_file_length","svn_fs_txn_root","svn_fs_make_file",
+      "svn_fs_make_dir","svn_fs_apply_text","svn_fs_copy","svn_fs_delete",
+      "svn_fs_begin_txn2","svn_fs_is_dir","svn_fs_is_file","svn_fs_node_prop",
+      "svn_fs_change_node_prop","svn_fs_contents_changed","svn_fs_props_changed",
+      "svn_fs_abort_txn","sqlite_open","sqlite_popen","sqlite_close","sqlite_query",
+      "sqlite_exec","sqlite_array_query","sqlite_single_query","sqlite_fetch_array",
+      "sqlite_fetch_object","sqlite_fetch_single","sqlite_fetch_string",
+      "sqlite_fetch_all","sqlite_current","sqlite_column","sqlite_libversion",
+      "sqlite_libencoding","sqlite_changes","sqlite_last_insert_rowid",
+      "sqlite_num_rows","sqlite_num_fields","sqlite_field_name","sqlite_seek",
+      "sqlite_rewind","sqlite_next","sqlite_prev","sqlite_valid","sqlite_has_more",
+      "sqlite_has_prev","sqlite_escape_string","sqlite_busy_timeout","sqlite_last_error",
+      "sqlite_error_string","sqlite_unbuffered_query","sqlite_create_aggregate",
+      "sqlite_create_function","sqlite_factory","sqlite_udf_encode_binary",
+      "sqlite_udf_decode_binary","sqlite_fetch_column_types"
     ].forEach(function(element, index, array) {
       result[element] = token("t_string", "php-predefined-function");
     });
@@ -720,10 +840,85 @@ var tokenizePHP = (function() {
       "EACCELERATOR_SHM_AND_DISK", "EACCELERATOR_SHM", "EACCELERATOR_SHM_ONLY",
       "EACCELERATOR_DISK_ONLY", "EACCELERATOR_NONE", "XDEBUG_TRACE_APPEND",
       "XDEBUG_TRACE_COMPUTERIZED", "XDEBUG_TRACE_HTML", "XDEBUG_CC_UNUSED",
-      "XDEBUG_CC_DEAD_CODE", "STDIN", "STDOUT", "STDERR"
-    ].forEach(function(element, index, array) {
-      result[element] = token("atom", "php-predefined-constant");
-    });
+      "XDEBUG_CC_DEAD_CODE", "STDIN", "STDOUT", "STDERR", "DNS_HINFO", 
+      "DNS_PTR", "SQLITE_EMPTY", "SVN_SHOW_UPDATES", "SVN_NO_IGNORE", "MSG_EOF",
+      "DNS_MX", "GD_EXTRA_VERSION", "PHP_VERSION_ID", "SQLITE_OK", 
+      "LIBXML_LOADED_VERSION", "RADIXCHAR", "OPENSSL_VERSION_TEXT",  "OPENSSL_VERSION_NUMBER",
+      "PCRE_VERSION", "CURLOPT_FILE", "CURLOPT_INFILE", "CURLOPT_URL", "CURLOPT_PROXY",
+      "CURLE_FUNCTION_NOT_FOUND", "SOCKET_ENOMSG", "CURLOPT_HTTPHEADER", "SOCKET_EIDRM",
+      "CURLOPT_PROGRESSFUNCTION", "SOCKET_ECHRNG", "SOCKET_EL2NSYNC", "SOCKET_EL3HLT",
+      "SOCKET_EL3RST", "SOCKET_ELNRNG", "SOCKET_ENOCSI", "SOCKET_EL2HLT", "SOCKET_EBADE",
+      "SOCKET_EXFULL", "CURLOPT_USERPWD",  "CURLOPT_PROXYUSERPWD", "CURLOPT_RANGE",
+      "CURLOPT_TIMEOUT_MS",  "CURLOPT_POSTFIELDS",  "CURLOPT_REFERER", "CURLOPT_USERAGENT",
+      "CURLOPT_FTPPORT", "SOCKET_ERESTART", "SQLITE_CONSTRAINT", "SQLITE_MISMATCH",
+      "SQLITE_MISUSE", "CURLOPT_COOKIE", "CURLE_SSL_CERTPROBLEM", "CURLOPT_SSLCERT",
+      "CURLOPT_KEYPASSWD", "CURLOPT_WRITEHEADER", "CURLOPT_SSL_VERIFYHOST",
+      "CURLOPT_COOKIEFILE", "CURLE_HTTP_RANGE_ERROR", "CURLE_HTTP_POST_ERROR",
+      "CURLOPT_CUSTOMREQUEST", "CURLOPT_STDERR", "SOCKET_EBADR", "CURLOPT_RETURNTRANSFER",
+      "CURLOPT_QUOTE", "CURLOPT_POSTQUOTE", "CURLOPT_INTERFACE", "CURLOPT_KRB4LEVEL",
+      "SOCKET_ENODATA", "SOCKET_ESRMNT",  "CURLOPT_WRITEFUNCTION", "CURLOPT_READFUNCTION",
+      "CURLOPT_HEADERFUNCTION", "SOCKET_EADV", "SOCKET_EPROTO", "SOCKET_EMULTIHOP",
+      "SOCKET_EBADMSG",  "CURLOPT_FORBID_REUSE", "CURLOPT_RANDOM_FILE", "CURLOPT_EGDSOCKET",
+      "SOCKET_EREMCHG", "CURLOPT_CONNECTTIMEOUT_MS", "CURLOPT_CAINFO", "CURLOPT_CAPATH",
+      "CURLOPT_COOKIEJAR", "CURLOPT_SSL_CIPHER_LIST", "CURLOPT_BINARYTRANSFER",
+      "SQLITE_DONE", "CURLOPT_HTTP_VERSION", "CURLOPT_SSLKEY", "CURLOPT_SSLKEYTYPE",
+      "CURLOPT_SSLENGINE", "CURLOPT_SSLCERTTYPE", "CURLE_OUT_OF_MEMORY", "CURLOPT_ENCODING",
+      "CURLE_SSL_CIPHER", "SOCKET_EREMOTEIO", "CURLOPT_HTTP200ALIASES", "CURLAUTH_ANY",
+      "CURLAUTH_ANYSAFE", "CURLOPT_PRIVATE", "CURLINFO_EFFECTIVE_URL", "CURLINFO_HTTP_CODE",
+      "CURLINFO_HEADER_SIZE", "CURLINFO_REQUEST_SIZE", "CURLINFO_TOTAL_TIME",
+      "CURLINFO_NAMELOOKUP_TIME", "CURLINFO_CONNECT_TIME", "CURLINFO_PRETRANSFER_TIME",
+      "CURLINFO_SIZE_UPLOAD", "CURLINFO_SIZE_DOWNLOAD", "CURLINFO_SPEED_DOWNLOAD",
+      "CURLINFO_SPEED_UPLOAD", "CURLINFO_FILETIME", "CURLINFO_SSL_VERIFYRESULT",
+      "CURLINFO_CONTENT_LENGTH_DOWNLOAD", "CURLINFO_CONTENT_LENGTH_UPLOAD",
+      "CURLINFO_STARTTRANSFER_TIME", "CURLINFO_CONTENT_TYPE", "CURLINFO_REDIRECT_TIME",
+      "CURLINFO_REDIRECT_COUNT", "CURLINFO_PRIVATE", "CURLINFO_CERTINFO",
+      "SQLITE_PROTOCOL", "SQLITE_SCHEMA", "SQLITE_TOOBIG", "SQLITE_NOLFS", 
+      "SQLITE_AUTH", "SQLITE_FORMAT", "SOCKET_ENOTTY", "SQLITE_NOTADB",
+      "SOCKET_ENOSPC", "SOCKET_ESPIPE", "SOCKET_EROFS", "SOCKET_EMLINK", "GD_RELEASE_VERSION",
+      "SOCKET_ENOLCK", "SOCKET_ENOSYS", "SOCKET_EUNATCH", "SOCKET_ENOANO", "SOCKET_EBADRQC",
+      "SOCKET_EBADSLT", "SOCKET_ENOSTR", "SOCKET_ETIME", "SOCKET_ENOSR", "SVN_REVISION_HEAD",
+      "XSD_ENTITY", "XSD_NOTATION", "CURLOPT_CERTINFO", "CURLOPT_POSTREDIR", "CURLOPT_SSH_AUTH_TYPES",
+      "CURLOPT_SSH_PUBLIC_KEYFILE", "CURLOPT_SSH_PRIVATE_KEYFILE", "CURLOPT_SSH_HOST_PUBLIC_KEY_MD5",
+      "CURLE_SSH", "CURLOPT_REDIR_PROTOCOLS", "CURLOPT_PROTOCOLS", "XSD_NONNEGATIVEINTEGER",
+      "XSD_BYTE","DNS_SRV","DNS_A6", "DNS_NAPTR", "DNS_AAAA", "FILTER_SANITIZE_FULL_SPECIAL_CHARS",
+      "ABDAY_1", "SVN_REVISION_UNSPECIFIED", "SVN_REVISION_BASE", "SVN_REVISION_COMMITTED",
+      "SVN_REVISION_PREV", "GD_VERSION", "MCRYPT_TRIPLEDES", "MCRYPT_ARCFOUR_IV", "MCRYPT_ARCFOUR",
+      "MCRYPT_BLOWFISH", "MCRYPT_BLOWFISH_COMPAT", "MCRYPT_CAST_128", "MCRYPT_CAST_256",
+      "MCRYPT_ENIGNA", "MCRYPT_DES", "MCRYPT_GOST", "MCRYPT_LOKI97", "MCRYPT_PANAMA",
+      "MCRYPT_RC2", "MCRYPT_RIJNDAEL_128", "MCRYPT_RIJNDAEL_192", "MCRYPT_RIJNDAEL_256",
+      "MCRYPT_SAFER64", "MCRYPT_SAFER128","MCRYPT_SAFERPLUS", "MCRYPT_SERPENT", "MCRYPT_THREEWAY",
+      "MCRYPT_TWOFISH", "MCRYPT_WAKE", "MCRYPT_XTEA", "MCRYPT_IDEA", "MCRYPT_MARS",
+      "MCRYPT_RC6", "MCRYPT_SKIPJACK", "MCRYPT_MODE_CBC", "MCRYPT_MODE_CFB", "MCRYPT_MODE_ECB",
+      "MCRYPT_MODE_NOFB", "MCRYPT_MODE_OFB", "MCRYPT_MODE_STREAM", "CL_EXPUNGE",
+      "SQLITE_ROW", "POSIX_S_IFBLK", "POSIX_S_IFSOCK",  "XSD_IDREF", "ABDAY_2",
+      "ABDAY_3", "ABDAY_4", "ABDAY_5", "ABDAY_6", "ABDAY_7", "DAY_1", "DAY_2",
+      "DAY_3", "DAY_4", "DAY_5", "DAY_6", "DAY_7", "ABMON_1", "ABMON_2", "ABMON_3",
+      "ABMON_4", "ABMON_5", "ABMON_6", "ABMON_7","ABMON_8", "ABMON_9", "ABMON_10",
+      "ABMON_11",  "ABMON_12", "MON_1", "MON_2", "MON_3", "MON_4", "MON_5",  "MON_6",
+      "MON_7",  "MON_8", "MON_9", "MON_10", "MON_11", "MON_12", "AM_STR", "PM_STR",
+      "D_T_FMT",  "D_FMT", "T_FMT", "T_FMT_AMPM", "ERA", "ERA_D_T_FMT", "ERA_D_FMT",
+      "ERA_T_FMT", "ALT_DIGITS", "CRNCYSTR", "THOUSEP",  "YESEXPR", "NOEXPR",
+      "SOCKET_ENOMEDIUM", "GLOB_AVAILABLE_FLAGS", "XSD_SHORT", "XSD_NMTOKENS",
+      "LOG_LOCAL3", "LOG_LOCAL4", "LOG_LOCAL5", "LOG_LOCAL6", "LOG_LOCAL7",
+      "DNS_ANY", "DNS_ALL", "SOCKET_ENOLINK",  "SOCKET_ECOMM", "SOAP_FUNCTIONS_ALL",
+      "UNKNOWN_TYPE", "XSD_BASE64BINARY", "XSD_ANYURI", "XSD_QNAME", "SOCKET_EISNAM",
+      "SOCKET_EMEDIUMTYPE", "XSD_NCNAME", "XSD_ID", "XSD_ENTITIES", "XSD_INTEGER",
+      "XSD_NONPOSITIVEINTEGER", "XSD_NEGATIVEINTEGER", "XSD_LONG", "XSD_INT",
+      "XSD_UNSIGNEDLONG", "XSD_UNSIGNEDINT", "XSD_UNSIGNEDSHORT", "XSD_UNSIGNEDBYTE",
+      "XSD_POSITIVEINTEGER", "XSD_ANYTYPE", "XSD_ANYXML", "APACHE_MAP", "XSD_1999_TIMEINSTANT",
+      "XSD_NAMESPACE", "XSD_1999_NAMESPACE", "SOCKET_ENOTUNIQ", "SOCKET_EBADFD",
+      "SOCKET_ESTRPIPE", "T_GOTO", "T_NAMESPACE", "T_NS_C", "T_DIR", "T_NS_SEPARATOR",
+      "LIBXSLT_VERSION","LIBEXSLT_DOTTED_VERSION", "LIBEXSLT_VERSION",  "SVN_AUTH_PARAM_DEFAULT_USERNAME",
+      "SVN_AUTH_PARAM_DEFAULT_PASSWORD", "SVN_AUTH_PARAM_NON_INTERACTIVE",
+      "SVN_AUTH_PARAM_DONT_STORE_PASSWORDS", "SVN_AUTH_PARAM_NO_AUTH_CACHE",
+      "SVN_AUTH_PARAM_SSL_SERVER_FAILURES", "SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO",
+      "SVN_AUTH_PARAM_CONFIG", "SVN_AUTH_PARAM_SERVER_GROUP",
+      "SVN_AUTH_PARAM_CONFIG_DIR", "PHP_SVN_AUTH_PARAM_IGNORE_SSL_VERIFY_ERRORS",
+      "SVN_FS_CONFIG_FS_TYPE", "SVN_FS_TYPE_BDB", "SVN_FS_TYPE_FSFS", "SVN_PROP_REVISION_DATE",
+      "SVN_PROP_REVISION_ORIG_DATE", "SVN_PROP_REVISION_AUTHOR", "SVN_PROP_REVISION_LOG"
+      ].forEach(function(element, index, array) {
+         result[element] = token("atom", "php-predefined-constant");
+      });
 
     // PHP declared classes - output of get_declared_classes(). Differs from http://php.net/manual/en/reserved.classes.php
     [  "stdClass", "Exception", "ErrorException", "COMPersistHelper", "com_exception",
@@ -754,7 +949,13 @@ var tokenizePHP = (function() {
       "UnderflowException", "UnexpectedValueException", "SplObjectStorage",
       "XMLReader", "XMLWriter", "mysqli_sql_exception", "mysqli_driver", "mysqli",
       "mysqli_warning", "mysqli_result", "mysqli_stmt", "PDOException", "PDO",
-      "PDOStatement", "PDORow"
+      "PDOStatement", "PDORow","Closure", "DateInterval", "DatePeriod", "FilesystemIterator",
+      "GlobIterator", "MultipleIterator", "RecursiveTreeIterator", "SoapClient",
+      "SoapFault", "SoapHeader", "SoapParam", "SoapServer", "SoapVar", "SplDoublyLinkedList",
+      "SplFixedArray", "SplHeap", "SplMaxHeap", "SplMinHeap", "SplPriorityQueue",
+      "SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase",
+      "SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc",
+      "SvnWcSchedule", "XSLTProcessor", "ZipArchive",
     ].forEach(function(element, index, array) {
       result[element] = token("t_string", "php-predefined-class");
     });
@@ -764,7 +965,7 @@ var tokenizePHP = (function() {
   }();
 
   // Helper regexps
-  var isOperatorChar = /[+*&%\/=<>!?.|-]/;
+  var isOperatorChar = /[+*&%\/=<>!?.|^@-]/;
   var isHexDigit = /[0-9A-Fa-f]/;
   var isWordChar = /[\w\$_\\]/;
 
@@ -968,7 +1169,7 @@ var tokenizePHP = (function() {
     else if (ch == ":" && source.equals(":")) {
       source.next();
       // the T_DOUBLE_COLON can only follow a T_STRING (class name)
-      return {type: "t_double_colon", style: "php-operator"}
+      return {type: "t_double_colon", style: "php-operator"};
     }
     // with punctuation, the type of the token is the symbol itself
     else if (/[\[\]{}\(\),;:]/.test(ch)) {
index 28919e8..4c3548a 100644 (file)
@@ -12,7 +12,7 @@ highlighter.</p>
 <p>Written by Peter Raganitsch (<a href="LICENSE">license</a>), based
 on John Benediktsson <a href="../sql/index.html">SQL parser</a>.</p>
 
-<div class="border">
+<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
 <textarea id="code" cols="120" rows="50">
 PROCEDURE generateResult
   ( pRoutineType   IN VARCHAR2
index 0bd6d5c..787703d 100644 (file)
@@ -292,7 +292,6 @@ var PythonParser = Editor.Parser = (function() {
                             break;
                         }
                         ch = source.next();
-                        ch = source.next();
                     }
                     if (ch == terminator.charAt(0)) {
                         matches.push(terminator);
index ae00974..e488376 100644 (file)
@@ -15,6 +15,7 @@
         font-size: 10pt;
         font-family: monospace;
         padding-top: .4em;
+        line-height: normal;
       }
     </style>
   </head>
@@ -23,7 +24,7 @@
 <p>This page demonstrates <a href="index.html">CodeMirror</a>'s
 Scheme parser. (<a href="LICENSE">license</a>)</p>
 
-<div class="border">
+<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
 <textarea id="code" cols="120" rows="30">
 (define (factorial x)
   (cond
diff --git a/typo3/contrib/codemirror/contrib/scheme/js/parsescheme.js b/typo3/contrib/codemirror/contrib/scheme/js/parsescheme.js
new file mode 100644 (file)
index 0000000..6b1ffba
--- /dev/null
@@ -0,0 +1,428 @@
+var SchemeParser = Editor.Parser = (function() {
+
+
+    // isLparen: char -> boolean
+    var isLparen = function(ch) {
+       return ch === '(' || ch === '[' || ch === '{';
+    };
+
+    // isRparen: char -> boolean
+    var isRparen = function(ch) {
+       return ch === ')' || ch === ']' || ch === '}';
+    };
+
+    // isMatchingParens: char char -> boolean
+    var isMatchingParens = function(lparen, rparen) {
+       return ((lparen === '(' && rparen === ')') ||
+               (lparen === '[' && rparen === ']') ||
+               (lparen === '{' && rparen === '}'));
+    };
+
+
+    // Compute the indentation context enclosing the end of the token
+    // sequence tokens.
+    // The context is the token sequence of the enclosing s-expression,
+    // augmented with column information.
+    var getIndentationContext = function(tokenStack) {
+       var EMPTY_CONTEXT = [];
+
+       var pendingParens = [], i = 0, j, line, column, context;
+       var tokens = [];
+
+       // Scan for the start of the indentation context, accumulating tokens.
+       while (! isEmptyPair(tokenStack)) {
+           i++;
+           tokens.push(pairFirst(tokenStack));
+           if (isLparen(pairFirst(tokenStack).type)) {
+               if (pendingParens.length === 0) {
+                   break;
+               } else {
+                   if (isMatchingParens(pairFirst(tokenStack).value,
+                                        pendingParens[pendingParens.length - 1])) {
+                       pendingParens.pop();
+                   } else {
+                       // Error condition: we see mismatching parens,
+                       // so we exit with no known indentation context.
+                       return EMPTY_CONTEXT;
+                   }
+               }
+           } else if (isRparen(pairFirst(tokenStack).type))  {
+               pendingParens.push(pairFirst(tokenStack).type);
+           }
+           tokenStack = pairRest(tokenStack);
+       }
+
+       // If we scanned backward too far, we couldn't find a context.  Just
+       // return the empty context.
+       if (isEmptyPair(tokenStack)) { 
+           return EMPTY_CONTEXT; 
+       }
+
+       // Position tokenStack to the next token beyond.
+       tokenStack = pairRest(tokenStack);
+
+       // We now scan backwards to closest newline to figure out the column
+       // number:
+       while (! isEmptyPair(tokenStack)) {
+           if(pairFirst(tokenStack).type === 'whitespace' && 
+              pairFirst(tokenStack).value === '\n') {
+               break;
+           }
+           tokens.push(pairFirst(tokenStack));
+           tokenStack = pairRest(tokenStack);
+       }
+
+       line = 0;
+       column = 0;
+       context = [];
+       // Start generating the context, walking forward.
+       for (j = tokens.length-1; j >= 0; j--) {
+           if (j < i) {
+               context.push({ type: tokens[j].type,
+                              value: tokens[j].value,
+                              line: line,
+                              column: column });
+           }
+
+           if (tokens[j].type === 'whitespace' && 
+               tokens[j].value === '\n') {
+               column = 0;
+               line++;
+           } else {
+               column += tokens[j].value.length;
+           }
+       }
+       return context;
+
+
+    };
+
+
+
+
+
+    // calculateIndentationFromContext: indentation-context number -> number
+    var calculateIndentationFromContext = function(context, currentIndentation) {
+       if (context.length === 0) {
+           return 0;
+       }
+       if (isBeginLikeContext(context)) {
+           return beginLikeIndentation(context);
+       }
+       if (isDefineLikeContext(context)) {
+           return defineLikeIndentation(context);
+       }
+       if (isLambdaLikeContext(context)) {
+           return lambdaLikeIndentation(context);
+       }
+       return beginLikeIndentation(context, 0);
+    };
+
+
+
+    // findContextElement: indentation-context number -> index or -1
+    var findContextElement = function(context, index) {
+       var depth = 0;
+       for(var i = 0; i < context.length; i++) {
+           if (context[i].type !== 'whitespace' && depth === 1) {
+               if (index === 0)
+                   return i;
+               else
+                   index--;
+           }
+
+           if (isLparen(context[i].type)) {
+               depth++;
+           }
+           if (isRparen(context[i].type)) {
+               depth = Math.max(depth - 1, 0);
+           }
+       }
+       return -1;
+    };
+
+    // contextElement: context -> (arrayof index)
+    var contextElements = function(context) {
+       var i = 0, index, results = [];
+       
+       while ((index = findContextElement(context, i++)) != -1) {
+           results.push(index);
+       }
+       return results;
+    };
+
+
+
+    //////////////////////////////////////////////////////////////////////
+
+    var BEGIN_LIKE_KEYWORDS = ["case-lambda", 
+                              "compound-unit",
+                              "compound-unit/sig",
+                              "cond",
+                              "delay",
+                              "inherit",
+                              "match-lambda",
+                              "match-lambda*",
+                              "override",
+                              "private",
+                              "public",
+                              "sequence",
+                              "unit"];
+
+    var isBeginLikeContext = function(context) {
+       var j = findContextElement(context, 0);
+       if (j === -1) { return false; }
+       return (/^begin/.test(context[j].value) ||
+               isMember(context[j].value, BEGIN_LIKE_KEYWORDS));
+    };
+
+
+    // Begin: if there's no elements within the begin context,
+    // the indentation is that of the begin keyword's column + offset.
+    // Otherwise, find the leading element on the last line.
+    // Also used for default indentation.
+    var beginLikeIndentation = function(context, offset) {
+       if (typeof(offset) === 'undefined') { offset = 1; }
+
+       var indices = contextElements(context), j;
+       if (indices.length === 0) {
+           return context[0].column + 1;
+       } else if (indices.length === 1) {
+           // if we only see the begin keyword, indentation is based
+           // off the keyword.
+           return context[indices[0]].column + offset;
+       } else {
+           // Otherwise, we scan for the contextElement of the last line
+           for (j = indices.length -1; j > 1; j--) {
+               if (context[indices[j]].line !==
+                   context[indices[j-1]].line) {
+                   return context[indices[j]].column;
+               }
+           }
+           return context[indices[j]].column;
+       }
+    };
+
+
+
+    //////////////////////////////////////////////////////////////////////
+
+
+    var DEFINE_LIKE_KEYWORDS = ["local"];
+
+    var isDefineLikeContext = function(context) {
+       var j = findContextElement(context, 0);
+       if (j === -1) { return false; }
+       return (/^def/.test(context[j].value) ||
+               isMember(context[j].value, DEFINE_LIKE_KEYWORDS));
+    };
+
+
+    var defineLikeIndentation = function(context) {
+       var i = findContextElement(context, 0);
+       if (i === -1) { return 0; }
+       return context[i].column +1; 
+    };
+
+    //////////////////////////////////////////////////////////////////////
+
+    var LAMBDA_LIKE_KEYWORDS = ["cases",
+                               "instantiate",
+                               "super-instantiate",
+                               "syntax/loc",
+                               "quasisyntax/loc",
+                               "lambda",
+                               "let",
+                               "let*",
+                               "letrec",
+                               "recur",
+                               "lambda/kw",
+                               "letrec-values",
+                               "with-syntax",
+                               "with-continuation-mark",
+                               "module",
+                               "match",
+                               "match-let",
+                               "match-let*",
+                               "match-letrec",
+                               "let/cc",
+                               "let/ec",
+                               "letcc",
+                               "catch",
+                               "let-syntax",
+                               "letrec-syntax",
+                               "fluid-let-syntax",
+                               "letrec-syntaxes+values",
+                               "for",
+                               "for/list",
+                               "for/hash",
+                               "for/hasheq",
+                               "for/and",
+                               "for/or",
+                               "for/lists",
+                               "for/first",
+                               "for/last",
+                               "for/fold",
+                               "for*",
+                               "for*/list",
+                               "for*/hash",
+                               "for*/hasheq",
+                               "for*/and",
+                               "for*/or",
+                               "for*/lists",
+                               "for*/first",
+                               "for*/last",
+                               "for*/fold",
+                               "kernel-syntax-case",
+                               "syntax-case",
+                               "syntax-case*",
+                               "syntax-rules",
+                               "syntax-id-rules",
+                               "let-signature",
+                               "fluid-let",
+                               "let-struct",
+                               "let-macro",
+                               "let-values",
+                               "let*-values",
+                               "case",
+                               "when",
+                               "unless",
+                               "let-enumerate",
+                               "class",
+                               "class*",
+                               "class-asi",
+                               "class-asi*",
+                               "class*/names",
+                               "class100",
+                               "class100*",
+                               "class100-asi",
+                               "class100-asi*",
+                               "class100*/names",
+                               "rec",
+                               "make-object",
+                               "mixin",
+                               "define-some",
+                               "do",
+                               "opt-lambda",
+                               "send*",
+                               "with-method",
+                               "define-record",
+                               "catch",
+                               "shared",
+                               "unit/sig",
+                               "unit/lang",
+                               "with-handlers",
+                               "interface",
+                               "parameterize",
+                               "call-with-input-file",
+                               "call-with-input-file*",
+                               "with-input-from-file",
+                               "with-input-from-port",
+                               "call-with-output-file",
+                               "with-output-to-file",
+                               "with-output-to-port",
+                               "for-all"];
+
+
+    var isLambdaLikeContext = function(context) {
+       var j = findContextElement(context, 0);
+       if (j === -1) { return false; }
+       return (isMember(context[j].value, LAMBDA_LIKE_KEYWORDS));
+    };
+
+
+    var lambdaLikeIndentation = function(context) {
+       var i = findContextElement(context, 0);
+       if (i === -1) { return 0; }
+       var j = findContextElement(context, 1);
+       if (j === -1) { 
+           return context[i].column + 4; 
+       } else {
+           return context[i].column + 1;
+       }
+    };
+
+
+
+
+    //////////////////////////////////////////////////////////////////////
+    // Helpers
+    var isMember = function(x, l) {
+       for (var i = 0; i < l.length; i++) {
+           if (x === l[i]) { return true; }
+       }
+       return false;
+    };
+
+
+
+    //////////////////////////////////////////////////////////////////////
+
+    var pair = function(x, y) {
+       return [x,y];
+    };
+    var EMPTY_PAIR = [];
+    var pairFirst = function(p) { return p[0]; }
+    var pairRest = function(p) { return p[1]; }
+    var isEmptyPair = function(p) { return p === EMPTY_PAIR; }
+    var pairLength = function(p) {
+       var l = 0;
+       while (! isEmptyPair(p)) {
+           p = pairRest(p);
+       }
+       return l;
+    };
+
+    //////////////////////////////////////////////////////////////////////
+
+
+
+
+    var indentTo = function(tokenStack) {
+       return function(tokenText, currentIndentation, direction) {
+
+           // If we're in the middle of an unclosed token,
+           // do not change indentation.
+           if ((! isEmptyPair(tokenStack)) &&
+               (! isEmptyPair(pairRest(tokenStack))) &&
+               (pairFirst(pairRest(tokenStack)).isUnclosed)) {
+               return currentIndentation;
+           }
+
+           var indentationContext = 
+               getIndentationContext(tokenStack);
+           return calculateIndentationFromContext(indentationContext,
+                                                  currentIndentation);         
+       };
+    };
+
+
+    var startParse = function(source) {
+       source = tokenizeScheme(source);        
+       var tokenStack = EMPTY_PAIR;
+       var iter = {
+           next: function() {
+               var tok = source.next();
+               tokenStack = pair(tok, tokenStack);
+               if (tok.type === "whitespace") {
+                   if (tok.value === "\n") {
+                       tok.indentation = indentTo(tokenStack);
+                   }
+               }
+               return tok;
+           },
+
+           copy: function() {
+               var _tokenStack = tokenStack;
+               var _tokenState = source.state;
+               return function(_source) {
+                   tokenStack = _tokenStack;
+                   source = tokenizeScheme(_source, _tokenState);
+                   return iter;
+               };
+           }
+       };
+       return iter;
+    };
+    return { make: startParse };
+})();
diff --git a/typo3/contrib/codemirror/contrib/scheme/js/tokenizescheme.js b/typo3/contrib/codemirror/contrib/scheme/js/tokenizescheme.js
new file mode 100644 (file)
index 0000000..37df0bb
--- /dev/null
@@ -0,0 +1,241 @@
+/* Tokenizer for Scheme code */
+
+
+
+
+/**
+  TODO: follow the definitions in:
+
+      http://docs.racket-lang.org/reference/reader.html
+
+  to the letter; at the moment, we've just done something quick-and-dirty.
+
+*/
+
+
+var tokenizeScheme = (function() {
+    var isWhiteSpace = function(ch) {
+       // The messy regexp is because IE's regexp matcher is of the
+       // opinion that non-breaking spaces are no whitespace.
+       return ch != "\n" && /^[\s\u00a0]*$/.test(ch);
+    };
+
+
+    // scanUntilUnescaped: string-stream char -> boolean
+    // Advances the stream until the given character (not preceded by a
+    // backslash) is encountered.
+    // Returns true if we hit end of line without closing.
+    // Returns false otherwise.
+    var scanUntilUnescaped = function(source, end) {
+       var escaped = false;
+       while (true) {
+           if (source.endOfLine()) {
+               return true;
+           }
+           var next = source.next();
+           if (next == end && !escaped)
+               return false;
+           escaped = !escaped && next == "\\";
+       }
+       return false;
+    }
+    
+
+    // Advance the stream until endline.
+    var scanUntilEndline = function(source, end) {
+       while (!source.endOfLine()) {
+           source.next();
+       }
+    }
+
+    
+    // Some helper regexps
+    var isHexDigit = /[0-9A-Fa-f]/;
+    
+
+    var whitespaceChar = new RegExp("[\\s\\u00a0]");
+    
+    var isDelimiterChar = 
+       new RegExp("[\\s\\\(\\\)\\\[\\\]\\\{\\\}\\\"\\\,\\\'\\\`\\\;]");
+
+    var isNotDelimiterChar = 
+       new RegExp("[^\\s\\\(\\\)\\\[\\\]\\\{\\\}\\\"\\\,\\\'\\\`\\\;]");
+
+
+    var numberHeader = ("(?:(?:\\d+\\/\\d+)|"+
+                       (  "(?:(?:\\d+\\.\\d+|\\d+\\.|\\.\\d+)(?:[eE][+\\-]?\\d+)?)|")+
+                       (  "(?:\\d+(?:[eE][+\\-]?\\d+)?))"));
+    var numberPatterns = [
+       // complex numbers
+       new RegExp("^((?:(?:\\#[ei])?[+\\-]?" + numberHeader +")?"
+                  + "(?:[+\\-]" + numberHeader + ")i$)"),
+           /^((?:\#[ei])?[+-]inf.0)$/,
+           /^((?:\#[ei])?[+-]nan.0)$/,
+       new RegExp("^((?:\\#[ei])?[+\\-]?" + numberHeader + "$)"),
+       new RegExp("^0[xX][0-9A-Fa-f]+$")];
+   
+
+    // looksLikeNumber: string -> boolean
+    // Returns true if string s looks like a number.
+    var looksLikeNumber = function(s) {
+       for (var i = 0; i < numberPatterns.length; i++) {
+           if (numberPatterns[i].test(s)) {
+               return true;
+           }
+       }
+       return false;
+    };
+
+
+
+    var UNCLOSED_STRING = function(source, setState) {
+       var readNewline = function() {
+           var content = source.get();
+           return { type:'whitespace', style:'whitespace', content: content };
+       };
+
+       var ch = source.peek();
+       if (ch === '\n') {
+           source.next();
+           return readNewline();
+       } else {
+           var isUnclosedString = scanUntilUnescaped(source, '"');
+           if (isUnclosedString) {
+               setState(UNCLOSED_STRING);
+           } else {
+               setState(START);
+           }
+           var content = source.get();
+           return {type: "string", style: "scheme-string", content: content,
+                   isUnclosed: isUnclosedString};
+       }
+    };
+
+
+
+    var START = function(source, setState) {
+       // Read a word, look it up in keywords. If not found, it is a
+       // variable, otherwise it is a keyword of the type found.
+       var readWordOrNumber = function() {
+           source.nextWhileMatches(isNotDelimiterChar);
+           var word = source.get();
+           if (looksLikeNumber(word)) {
+               return {type: "number", style: "scheme-number", content: word};
+           } else {
+               return {type: "variable", style: "scheme-symbol", content: word};
+           }
+       };
+
+
+       var readString = function(quote) {
+           var isUnclosedString = scanUntilUnescaped(source, quote);
+           if (isUnclosedString) {
+               setState(UNCLOSED_STRING);
+           }
+           var word = source.get();
+           return {type: "string", style: "scheme-string", content: word,
+                   isUnclosed: isUnclosedString};
+       };
+
+
+       var readPound = function() {
+           var text;
+           // FIXME: handle special things here
+           if (source.equals(";")) {
+               source.next();
+               text = source.get();
+               return {type: text, 
+                       style:"scheme-symbol",
+                       content: text};
+           } else {
+               text = source.get();
+
+               return {type : "symbol",
+                       style: "scheme-symbol",
+                       content: text};
+           }
+
+       };
+       
+       var readLineComment = function() {
+           scanUntilEndline(source);
+           var text = source.get();
+           return { type: "comment", style: "scheme-comment", content: text};  
+       };
+
+
+       var readWhitespace = function() {
+           source.nextWhile(isWhiteSpace);
+           var content = source.get();
+           return { type: 'whitespace', style:'whitespace', content: content };
+       };
+
+       var readNewline = function() {
+           var content = source.get();
+           return { type:'whitespace', style:'whitespace', content: content };
+       };
+
+
+       // Fetch the next token. Dispatches on first character in the
+       // stream, or first two characters when the first is a slash.
+       var ch = source.next();
+       if (ch === '\n') {
+           return readNewline();
+       } else if (whitespaceChar.test(ch)) {
+           return readWhitespace();
+       } else if (ch === "#") {
+           return readPound();
+       } else if (ch ===';') {
+           return readLineComment();
+       } else if (ch === "\"") {
+           return readString(ch);
+       } else if (isDelimiterChar.test(ch)) {
+           return {type: ch, style: "scheme-punctuation"};
+       } else {
+           return readWordOrNumber();
+       }
+    }
+
+
+
+
+
+
+
+    var makeTokenizer = function(source, state) {
+       // Newlines are always a separate token.
+
+       var tokenizer = {
+           state: state,
+
+           take: function(type) {
+               if (typeof(type) == "string")
+                   type = {style: type, type: type};
+
+               type.content = (type.content || "") + source.get();
+               type.value = type.content;
+               return type;
+           },
+
+           next: function () {
+               if (!source.more()) throw StopIteration;
+
+               var type;
+               while (!type) {
+                   type = tokenizer.state(source, function(s) {
+                       tokenizer.state = s;
+                   });
+               }
+               var result = this.take(type);
+               return result;              
+           }
+       };
+       return tokenizer;
+    };
+
+
+    // The external interface to the tokenizer.
+    return function(source, startState) {
+       return makeTokenizer(source, startState || START);
+    };
+})();
index d9a6add..9584252 100644 (file)
@@ -38,6 +38,10 @@ span.sql-word {
   color: black;
 }
 
+span.sql-quoted-word {
+  color: #680;
+}
+
 span.sql-function {
   color: darkorange;
 }
@@ -53,5 +57,3 @@ span.sql-separator {
 span.sql-number {
   color: darkcyan;
 }
-
-
index 20f4f42..3cea8ed 100644 (file)
@@ -11,7 +11,7 @@ highlighter.</p>
 
 <p>Written by John Benediktsson (<a href="LICENSE">license</a>).</p>
 
-<div class="border">
+<div style="border-top: 1px solid black; border-bottom: 1px solid black;">
 <textarea id="code" cols="120" rows="50">
 create table if not exists table1(
   a  bigint(13) not null primary key,
index 9e381e0..9b05d60 100644 (file)
@@ -38,7 +38,9 @@ var SqlParser = Editor.Parser = (function() {
     "or", "in", "not", "xor", "like", "using", "on", "order", "group", "by",
     "asc", "desc", "limit", "offset", "union", "all", "as", "distinct", "set",
     "commit", "rollback", "replace", "view", "database", "separator", "if",
-    "exists", "null", "truncate", "status", "show", "lock", "unique", "having"
+    "exists", "null", "truncate", "status", "show", "lock", "unique", "having",
+    "drop", "procedure", "begin", "end", "delimiter", "call", "else", "leave", 
+    "declare", "temporary", "then"
   ]);
 
   var types = wordRegexp([
@@ -56,6 +58,8 @@ var SqlParser = Editor.Parser = (function() {
 
   var operatorChars = /[*+\-<>=&|:\/]/;
 
+  var CFG = {};
+
   var tokenizeSql = (function() {
     function normal(source, setState) {
       var ch = source.next();
@@ -74,6 +78,10 @@ var SqlParser = Editor.Parser = (function() {
       else if (ch == "," || ch == ";") {
         return "sql-separator"
       }
+      else if (ch == '#') {
+        while (!source.endOfLine()) source.next();
+        return "sql-comment";
+      }
       else if (ch == '-') {
         if (source.peek() == "-") {
           while (!source.endOfLine()) source.next();
@@ -91,8 +99,16 @@ var SqlParser = Editor.Parser = (function() {
           return "sql-operator";
       }
       else if (operatorChars.test(ch)) {
-        source.nextWhileMatches(operatorChars);
-        return "sql-operator";
+
+        if(ch == "/" && source.peek() == "*"){
+          setState(inBlock("sql-comment", "*/"));
+          return null;
+        }
+        else{
+          source.nextWhileMatches(operatorChars);
+          return "sql-operator";
+        }
+        
       }
       else if (/\d/.test(ch)) {
         source.nextWhileMatches(/\d/);
@@ -144,9 +160,24 @@ var SqlParser = Editor.Parser = (function() {
             setState(normal);
             break;
           }
-          escaped = !escaped && ch == "\\";
+          escaped = CFG.extension == 'T-SQL' ?
+                                  !escaped && quote == ch && source.equals(quote) :
+                                  !escaped && ch == "\\";
+        }        
+        return quote == "`" ? "sql-quoted-word" : "sql-literal";
+      };
+    }
+
+    function inBlock(style, terminator) {
+      return function(source, setState) {
+        while (!source.endOfLine()) {
+          if (source.lookAhead(terminator, true)) {
+            setState(normal);
+            break;
+          }
+          source.next();
         }
-        return quote == "`" ? "sql-word" : "sql-literal";
+        return style;
       };
     }
 
@@ -224,5 +255,13 @@ var SqlParser = Editor.Parser = (function() {
     return iter;
   }
 
-  return {make: parseSql, electricChars: ")"};
+  function configure (parserConfig) {
+    for (var p in parserConfig) {
+      if (parserConfig.hasOwnProperty(p)) {
+        CFG[p] = parserConfig[p];
+      }
+    }
+  }
+
+  return {make: parseSql, electricChars: ")", configure: configure};
 })();