123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714 |
- /*---------------------------------------------------------------------------------------------
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for license information.
- *--------------------------------------------------------------------------------------------*/
- import type { languages } from '../fillers/monaco-editor-core';
- export const conf: languages.LanguageConfiguration = {
- comments: {
- lineComment: '--',
- blockComment: ['/*', '*/']
- },
- brackets: [
- ['{', '}'],
- ['[', ']'],
- ['(', ')']
- ],
- autoClosingPairs: [
- { open: '{', close: '}' },
- { open: '[', close: ']' },
- { open: '(', close: ')' },
- { open: '"', close: '"' },
- { open: "'", close: "'" }
- ],
- surroundingPairs: [
- { open: '{', close: '}' },
- { open: '[', close: ']' },
- { open: '(', close: ')' },
- { open: '"', close: '"' },
- { open: "'", close: "'" }
- ]
- };
- export const language = <languages.IMonarchLanguage>{
- defaultToken: '',
- tokenPostfix: '.sql',
- ignoreCase: true,
- brackets: [
- { open: '[', close: ']', token: 'delimiter.square' },
- { open: '(', close: ')', token: 'delimiter.parenthesis' }
- ],
- keywords: [
- // This list is generated using `keywords.js`
- 'ALL',
- 'ANALYSE',
- 'ANALYZE',
- 'AND',
- 'ANY',
- 'ARRAY',
- 'AS',
- 'ASC',
- 'ASYMMETRIC',
- 'AUTHORIZATION',
- 'BINARY',
- 'BOTH',
- 'CASE',
- 'CAST',
- 'CHECK',
- 'COLLATE',
- 'COLLATION',
- 'COLUMN',
- 'CONCURRENTLY',
- 'CONSTRAINT',
- 'CREATE',
- 'CROSS',
- 'CURRENT_CATALOG',
- 'CURRENT_DATE',
- 'CURRENT_ROLE',
- 'CURRENT_SCHEMA',
- 'CURRENT_TIME',
- 'CURRENT_TIMESTAMP',
- 'CURRENT_USER',
- 'DEFAULT',
- 'DEFERRABLE',
- 'DESC',
- 'DISTINCT',
- 'DO',
- 'ELSE',
- 'END',
- 'EXCEPT',
- 'FALSE',
- 'FETCH',
- 'FOR',
- 'FOREIGN',
- 'FREEZE',
- 'FROM',
- 'FULL',
- 'GRANT',
- 'GROUP',
- 'HAVING',
- 'ILIKE',
- 'IN',
- 'INITIALLY',
- 'INNER',
- 'INTERSECT',
- 'INTO',
- 'IS',
- 'ISNULL',
- 'JOIN',
- 'LATERAL',
- 'LEADING',
- 'LEFT',
- 'LIKE',
- 'LIMIT',
- 'LOCALTIME',
- 'LOCALTIMESTAMP',
- 'NATURAL',
- 'NOT',
- 'NOTNULL',
- 'NULL',
- 'OFFSET',
- 'ON',
- 'ONLY',
- 'OR',
- 'ORDER',
- 'OUTER',
- 'OVERLAPS',
- 'PLACING',
- 'PRIMARY',
- 'REFERENCES',
- 'RETURNING',
- 'RIGHT',
- 'SELECT',
- 'SESSION_USER',
- 'SIMILAR',
- 'SOME',
- 'SYMMETRIC',
- 'TABLE',
- 'TABLESAMPLE',
- 'THEN',
- 'TO',
- 'TRAILING',
- 'TRUE',
- 'UNION',
- 'UNIQUE',
- 'USER',
- 'USING',
- 'VARIADIC',
- 'VERBOSE',
- 'WHEN',
- 'WHERE',
- 'WINDOW',
- 'WITH'
- ],
- operators: [
- 'AND',
- 'BETWEEN',
- 'IN',
- 'LIKE',
- 'NOT',
- 'OR',
- 'IS',
- 'NULL',
- 'INTERSECT',
- 'UNION',
- 'INNER',
- 'JOIN',
- 'LEFT',
- 'OUTER',
- 'RIGHT'
- ],
- builtinFunctions: [
- 'abbrev',
- 'abs',
- 'acos',
- 'acosd',
- 'age',
- 'any',
- 'area',
- 'array_agg',
- 'array_append',
- 'array_cat',
- 'array_dims',
- 'array_fill',
- 'array_length',
- 'array_lower',
- 'array_ndims',
- 'array_position',
- 'array_positions',
- 'array_prepend',
- 'array_remove',
- 'array_replace',
- 'array_to_json',
- 'array_to_string',
- 'array_to_tsvector',
- 'array_upper',
- 'ascii',
- 'asin',
- 'asind',
- 'atan',
- 'atan2',
- 'atan2d',
- 'atand',
- 'avg',
- 'bit',
- 'bit_and',
- 'bit_count',
- 'bit_length',
- 'bit_or',
- 'bit_xor',
- 'bool_and',
- 'bool_or',
- 'bound_box',
- 'box',
- 'brin_summarize_new_values',
- 'broadcast',
- 'btrim',
- 'cardinality',
- 'cbrt',
- 'ceil',
- 'ceiling',
- 'center',
- 'char_length',
- 'character_length',
- 'chr',
- 'circle',
- 'clock_timestamp',
- 'coalesce',
- 'col_description',
- 'concat',
- 'concat_ws',
- 'convert',
- 'convert_from',
- 'convert_to',
- 'corr',
- 'cos',
- 'cosd',
- 'cot',
- 'cotd',
- 'count',
- 'covar_pop',
- 'covar_samp',
- 'cume_dist',
- 'current_catalog',
- 'current_database',
- 'current_date',
- 'current_query',
- 'current_role',
- 'current_schema',
- 'current_schemas',
- 'current_setting',
- 'current_time',
- 'current_timestamp',
- 'current_user',
- 'currval',
- 'cursor_to_xml',
- 'date_bin',
- 'date_part',
- 'date_trunc',
- 'decode',
- 'degrees',
- 'dense_rank',
- 'diameter',
- 'div',
- 'encode',
- 'enum_first',
- 'enum_last',
- 'enum_range',
- 'every',
- 'exp',
- 'extract',
- 'family',
- 'first_value',
- 'floor',
- 'format',
- 'format_type',
- 'generate_series',
- 'generate_subscripts',
- 'get_bit',
- 'get_byte',
- 'get_current_ts_config',
- 'gin_clean_pending_list',
- 'greatest',
- 'grouping',
- 'has_any_column_privilege',
- 'has_column_privilege',
- 'has_database_privilege',
- 'has_foreign_data_wrapper_privilege',
- 'has_function_privilege',
- 'has_language_privilege',
- 'has_schema_privilege',
- 'has_sequence_privilege',
- 'has_server_privilege',
- 'has_table_privilege',
- 'has_tablespace_privilege',
- 'has_type_privilege',
- 'height',
- 'host',
- 'hostmask',
- 'inet_client_addr',
- 'inet_client_port',
- 'inet_merge',
- 'inet_same_family',
- 'inet_server_addr',
- 'inet_server_port',
- 'initcap',
- 'isclosed',
- 'isempty',
- 'isfinite',
- 'isopen',
- 'json_agg',
- 'json_object',
- 'json_object_agg',
- 'json_populate_record',
- 'json_populate_recordset',
- 'json_to_record',
- 'json_to_recordset',
- 'jsonb_agg',
- 'jsonb_object_agg',
- 'justify_days',
- 'justify_hours',
- 'justify_interval',
- 'lag',
- 'last_value',
- 'lastval',
- 'lead',
- 'least',
- 'left',
- 'length',
- 'line',
- 'ln',
- 'localtime',
- 'localtimestamp',
- 'log',
- 'lower',
- 'lower_inc',
- 'lower_inf',
- 'lpad',
- 'lseg',
- 'ltrim',
- 'make_date',
- 'make_interval',
- 'make_time',
- 'make_timestamp',
- 'make_timestamptz',
- 'masklen',
- 'max',
- 'md5',
- 'min',
- 'mod',
- 'mode',
- 'netmask',
- 'network',
- 'nextval',
- 'now',
- 'npoints',
- 'nth_value',
- 'ntile',
- 'nullif',
- 'num_nonnulls',
- 'num_nulls',
- 'numnode',
- 'obj_description',
- 'octet_length',
- 'overlay',
- 'parse_ident',
- 'path',
- 'pclose',
- 'percent_rank',
- 'percentile_cont',
- 'percentile_disc',
- 'pg_advisory_lock',
- 'pg_advisory_lock_shared',
- 'pg_advisory_unlock',
- 'pg_advisory_unlock_all',
- 'pg_advisory_unlock_shared',
- 'pg_advisory_xact_lock',
- 'pg_advisory_xact_lock_shared',
- 'pg_backend_pid',
- 'pg_backup_start_time',
- 'pg_blocking_pids',
- 'pg_cancel_backend',
- 'pg_client_encoding',
- 'pg_collation_is_visible',
- 'pg_column_size',
- 'pg_conf_load_time',
- 'pg_control_checkpoint',
- 'pg_control_init',
- 'pg_control_recovery',
- 'pg_control_system',
- 'pg_conversion_is_visible',
- 'pg_create_logical_replication_slot',
- 'pg_create_physical_replication_slot',
- 'pg_create_restore_point',
- 'pg_current_xlog_flush_location',
- 'pg_current_xlog_insert_location',
- 'pg_current_xlog_location',
- 'pg_database_size',
- 'pg_describe_object',
- 'pg_drop_replication_slot',
- 'pg_export_snapshot',
- 'pg_filenode_relation',
- 'pg_function_is_visible',
- 'pg_get_constraintdef',
- 'pg_get_expr',
- 'pg_get_function_arguments',
- 'pg_get_function_identity_arguments',
- 'pg_get_function_result',
- 'pg_get_functiondef',
- 'pg_get_indexdef',
- 'pg_get_keywords',
- 'pg_get_object_address',
- 'pg_get_owned_sequence',
- 'pg_get_ruledef',
- 'pg_get_serial_sequence',
- 'pg_get_triggerdef',
- 'pg_get_userbyid',
- 'pg_get_viewdef',
- 'pg_has_role',
- 'pg_identify_object',
- 'pg_identify_object_as_address',
- 'pg_index_column_has_property',
- 'pg_index_has_property',
- 'pg_indexam_has_property',
- 'pg_indexes_size',
- 'pg_is_in_backup',
- 'pg_is_in_recovery',
- 'pg_is_other_temp_schema',
- 'pg_is_xlog_replay_paused',
- 'pg_last_committed_xact',
- 'pg_last_xact_replay_timestamp',
- 'pg_last_xlog_receive_location',
- 'pg_last_xlog_replay_location',
- 'pg_listening_channels',
- 'pg_logical_emit_message',
- 'pg_logical_slot_get_binary_changes',
- 'pg_logical_slot_get_changes',
- 'pg_logical_slot_peek_binary_changes',
- 'pg_logical_slot_peek_changes',
- 'pg_ls_dir',
- 'pg_my_temp_schema',
- 'pg_notification_queue_usage',
- 'pg_opclass_is_visible',
- 'pg_operator_is_visible',
- 'pg_opfamily_is_visible',
- 'pg_options_to_table',
- 'pg_postmaster_start_time',
- 'pg_read_binary_file',
- 'pg_read_file',
- 'pg_relation_filenode',
- 'pg_relation_filepath',
- 'pg_relation_size',
- 'pg_reload_conf',
- 'pg_replication_origin_create',
- 'pg_replication_origin_drop',
- 'pg_replication_origin_oid',
- 'pg_replication_origin_progress',
- 'pg_replication_origin_session_is_setup',
- 'pg_replication_origin_session_progress',
- 'pg_replication_origin_session_reset',
- 'pg_replication_origin_session_setup',
- 'pg_replication_origin_xact_reset',
- 'pg_replication_origin_xact_setup',
- 'pg_rotate_logfile',
- 'pg_size_bytes',
- 'pg_size_pretty',
- 'pg_sleep',
- 'pg_sleep_for',
- 'pg_sleep_until',
- 'pg_start_backup',
- 'pg_stat_file',
- 'pg_stop_backup',
- 'pg_switch_xlog',
- 'pg_table_is_visible',
- 'pg_table_size',
- 'pg_tablespace_databases',
- 'pg_tablespace_location',
- 'pg_tablespace_size',
- 'pg_terminate_backend',
- 'pg_total_relation_size',
- 'pg_trigger_depth',
- 'pg_try_advisory_lock',
- 'pg_try_advisory_lock_shared',
- 'pg_try_advisory_xact_lock',
- 'pg_try_advisory_xact_lock_shared',
- 'pg_ts_config_is_visible',
- 'pg_ts_dict_is_visible',
- 'pg_ts_parser_is_visible',
- 'pg_ts_template_is_visible',
- 'pg_type_is_visible',
- 'pg_typeof',
- 'pg_xact_commit_timestamp',
- 'pg_xlog_location_diff',
- 'pg_xlog_replay_pause',
- 'pg_xlog_replay_resume',
- 'pg_xlogfile_name',
- 'pg_xlogfile_name_offset',
- 'phraseto_tsquery',
- 'pi',
- 'plainto_tsquery',
- 'point',
- 'polygon',
- 'popen',
- 'position',
- 'power',
- 'pqserverversion',
- 'query_to_xml',
- 'querytree',
- 'quote_ident',
- 'quote_literal',
- 'quote_nullable',
- 'radians',
- 'radius',
- 'random',
- 'range_merge',
- 'rank',
- 'regexp_matches',
- 'regexp_replace',
- 'regexp_split_to_array',
- 'regexp_split_to_table',
- 'regr_avgx',
- 'regr_avgy',
- 'regr_count',
- 'regr_intercept',
- 'regr_r2',
- 'regr_slope',
- 'regr_sxx',
- 'regr_sxy',
- 'regr_syy',
- 'repeat',
- 'replace',
- 'reverse',
- 'right',
- 'round',
- 'row_number',
- 'row_security_active',
- 'row_to_json',
- 'rpad',
- 'rtrim',
- 'scale',
- 'session_user',
- 'set_bit',
- 'set_byte',
- 'set_config',
- 'set_masklen',
- 'setseed',
- 'setval',
- 'setweight',
- 'shobj_description',
- 'sign',
- 'sin',
- 'sind',
- 'split_part',
- 'sprintf',
- 'sqrt',
- 'statement_timestamp',
- 'stddev',
- 'stddev_pop',
- 'stddev_samp',
- 'string_agg',
- 'string_to_array',
- 'string_to_table',
- 'strip',
- 'strpos',
- 'substr',
- 'substring',
- 'sum',
- 'table_to_xml',
- 'table_to_xml_and_xmlschema',
- 'tan',
- 'tand',
- 'text',
- 'timeofday',
- 'timezone',
- 'to_ascii',
- 'to_char',
- 'to_date',
- 'to_hex',
- 'to_json',
- 'to_number',
- 'to_regclass',
- 'to_regnamespace',
- 'to_regoper',
- 'to_regoperator',
- 'to_regproc',
- 'to_regprocedure',
- 'to_regrole',
- 'to_regtype',
- 'to_timestamp',
- 'to_tsquery',
- 'to_tsvector',
- 'transaction_timestamp',
- 'translate',
- 'trim',
- 'trim_array',
- 'trunc',
- 'ts_debug',
- 'ts_delete',
- 'ts_filter',
- 'ts_headline',
- 'ts_lexize',
- 'ts_parse',
- 'ts_rank',
- 'ts_rank_cd',
- 'ts_rewrite',
- 'ts_stat',
- 'ts_token_type',
- 'tsquery_phrase',
- 'tsvector_to_array',
- 'tsvector_update_trigger',
- 'tsvector_update_trigger_column',
- 'txid_current',
- 'txid_current_snapshot',
- 'txid_snapshot_xip',
- 'txid_snapshot_xmax',
- 'txid_snapshot_xmin',
- 'txid_visible_in_snapshot',
- 'unistr',
- 'unnest',
- 'upper',
- 'upper_inc',
- 'upper_inf',
- 'user',
- 'var_pop',
- 'var_samp',
- 'variance',
- 'version',
- 'width',
- 'width_bucket',
- 'xml_is_well_formed',
- 'xml_is_well_formed_content',
- 'xml_is_well_formed_document',
- 'xmlagg',
- 'xmlcomment',
- 'xmlconcat',
- 'xmlelement',
- 'xmlexists',
- 'xmlforest',
- 'xmlparse',
- 'xmlpi',
- 'xmlroot',
- 'xmlserialize',
- 'xpath',
- 'xpath_exists'
- ],
- builtinVariables: [
- // NOT SUPPORTED
- ],
- pseudoColumns: [
- // NOT SUPPORTED
- ],
- tokenizer: {
- root: [
- { include: '@comments' },
- { include: '@whitespace' },
- { include: '@pseudoColumns' },
- { include: '@numbers' },
- { include: '@strings' },
- { include: '@complexIdentifiers' },
- { include: '@scopes' },
- [/[;,.]/, 'delimiter'],
- [/[()]/, '@brackets'],
- [
- /[\w@#$]+/,
- {
- cases: {
- '@operators': 'operator',
- '@builtinVariables': 'predefined',
- '@builtinFunctions': 'predefined',
- '@keywords': 'keyword',
- '@default': 'identifier'
- }
- }
- ],
- [/[<>=!%&+\-*/|~^]/, 'operator']
- ],
- whitespace: [[/\s+/, 'white']],
- comments: [
- [/--+.*/, 'comment'],
- [/\/\*/, { token: 'comment.quote', next: '@comment' }]
- ],
- comment: [
- [/[^*/]+/, 'comment'],
- // Not supporting nested comments, as nested comments seem to not be standard?
- // i.e. http://stackoverflow.com/questions/728172/are-there-multiline-comment-delimiters-in-sql-that-are-vendor-agnostic
- // [/\/\*/, { token: 'comment.quote', next: '@push' }], // nested comment not allowed :-(
- [/\*\//, { token: 'comment.quote', next: '@pop' }],
- [/./, 'comment']
- ],
- pseudoColumns: [
- [
- /[$][A-Za-z_][\w@#$]*/,
- {
- cases: {
- '@pseudoColumns': 'predefined',
- '@default': 'identifier'
- }
- }
- ]
- ],
- numbers: [
- [/0[xX][0-9a-fA-F]*/, 'number'],
- [/[$][+-]*\d*(\.\d*)?/, 'number'],
- [/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
- ],
- strings: [[/'/, { token: 'string', next: '@string' }]],
- string: [
- [/[^']+/, 'string'],
- [/''/, 'string'],
- [/'/, { token: 'string', next: '@pop' }]
- ],
- complexIdentifiers: [[/"/, { token: 'identifier.quote', next: '@quotedIdentifier' }]],
- quotedIdentifier: [
- [/[^"]+/, 'identifier'],
- [/""/, 'identifier'],
- [/"/, { token: 'identifier.quote', next: '@pop' }]
- ],
- scopes: [
- // NOT SUPPORTED
- ]
- }
- };
|