%YAML 1.2 --- # http://www.sublimetext.com/docs/3/syntax.html name: MATLAB file_extensions: - matlab scope: source.matlab contexts: main: - match: |- (?x) (?=function\b) # borrowed from ruby bundle (?<=^|\s)(function)\s+ # the function keyword (?>\[(.*)\])?\t# match various different combination of output arguments ((?>[a-zA-Z_]\w*))? (?>\s*=\s*)? ((?>[a-zA-Z_]\w*(?>[?!]|=(?!>))? )) # the function name (?=[ \t]*[^\s%|#]) # make sure arguments and not a comment follow \s*(\() # the opening parenthesis for arguments captures: 1: storage.type.matlab 2: variable.parameter.output.function.matlab 3: variable.parameter.output.function.matlab 4: entity.name.function.matlab push: - meta_scope: meta.function.with-arguments.matlab - meta_content_scope: variable.parameter.input.function.matlab - match: \) scope: punctuation.definition.parameters.matlab pop: true - match: |- (?x) (?=function\b) # borrowed from ruby bundle (?<=^|\s)(function)\s+ # the function keyword (?>\[(.*)\])? # match various different combination of output arguments ((?>[a-zA-Z_]\w*))? (?>\s*=\s*)? ((?>[a-zA-Z_]\w*(?>[?!]|=(?!>))? )) # the function name scope: meta.function.without-arguments.matlab captures: 1: storage.type.matlab 2: variable.parameter.output.function.matlab 3: variable.parameter.output.function.matlab 4: entity.name.function.matlab - include: constants_override - include: brackets - include: curlybrackets - include: parens - include: string - include: transpose - include: double_quote - include: operators - include: all_matlab_keywords - include: all_matlab_comments - include: number - include: variable - include: variable_invalid - include: not_equal_invalid - include: variable_assignment all_matlab_comments: - match: (%%).*$\n? scope: comment.double.percentage.matlab captures: 1: punctuation.definition.comment.matlab - match: '(%\{)\s*\n' captures: 1: punctuation.definition.comment.matlab push: - meta_scope: comment.block.percentage.matlab - match: '(%\})\s*\n' captures: 1: punctuation.definition.comment.matlab pop: true - match: (%).*$\n? scope: comment.line.percentage.matlab captures: 1: punctuation.definition.comment.matlab all_matlab_keywords: - include: matlab_keyword_control - include: matlab_keyword_operator - include: matlab_keyword_other - include: matlab_oop - include: matlab_storage_type - include: matlab_storage_modifier - include: matlab_constant_language - include: matlab_variable_function - include: matlab_keyword_desktop - include: matlab_keyword_mathematics - include: matlab_keyword_analysis - include: matlab_storage_control - include: matlab_support_graphics - include: matlab_support_function - include: matlab_support_external - include: matlab_support_toolbox_aerospace - include: matlab_support_toolbox_bioinformatics - include: matlab_support_toolbox_communications - include: matlab_support_toolbox_control_systems - include: matlab_support_toolbox_curve_fitting - include: matlab_support_toolbox_data_acquisition - include: matlab_support_toolbox_database - include: matlab_support_toolbox_datafeed - include: matlab_support_toolbox_design - include: matlab_support_toolbox_excel_link - include: matlab_support_toolbox_filter_design_hdl_coder - include: matlab_support_toolbox_financial_derivatives - include: matlab_support_toolbox_financial - include: matlab_support_toolbox_fixed_income - include: matlab_support_toolbox_fixed_point - include: matlab_support_toolbox_fuzzy_logic - include: matlab_support_toolbox_garch - include: matlab_support_toolbox_genetic_algorithms - include: matlab_support_toolbox_image_acquisition - include: matlab_support_toolbox_image_processing - include: matlab_support_toolbox_instrument_control - include: matlab_support_toolbox_mapping - include: matlab_support_toolbox_model_predictive_control - include: matlab_support_toolbox_model_based_calibration - include: matlab_support_toolbox_neural_network - include: matlab_support_toolbox_opc - include: matlab_support_toolbox_optimization - include: matlab_support_toolbox_rf - include: matlab_support_toolbox_robust_control - include: matlab_support_toolbox_signal_processing - include: matlab_support_toolbox_spline - include: matlab_support_toolbox_statistics - include: matlab_support_toolbox_symbolic_math - include: matlab_support_toolbox_system_identification - include: matlab_support_toolbox_virtual_reality - include: matlab_support_toolbox_wavelet allofem: - include: parens - include: curlybrackets - include: end_in_parens - include: brackets - include: string - include: transpose - include: double_quote - include: all_matlab_keywords - include: all_matlab_comments - include: variable - include: variable_invalid - include: number - include: operators - match: \.\.\. scope: punctuation.separator.continuation.matlab brackets: - match: '\[' scope: punctuation.section.brackets.begin.matlab push: - meta_scope: meta.brackets.matlab - match: '\]' scope: punctuation.section.brackets.end.matlab pop: true - include: allofem constants_override: - match: '(^|\;)\s*(ans|i|j|inf|Inf|nan|NaN|eps|end)\s*=[^=]' comment: The user is trying to override MATLAB constants and functions. scope: meta.inappropriate.matlab curlybrackets: - match: '\{' scope: meta.brackets.curly.matlab push: - meta_content_scope: meta.brackets.curly.matlab - match: '\}' scope: meta.brackets.curly.matlab pop: true - include: allofem - include: end_in_parens double_quote: - match: '"' scope: invalid.illegal.invalid-quote.matlab end_in_parens: - match: \bend\b comment: end as operator symbol scope: keyword.operator.symbols.matlab escaped_quote: - match: "''" scope: constant.character.escape.matlab matlab_constant_language: - match: (?|>=|<|<=|=|&|&&|:|\||\|\||\+|-|\*|\.\*|/|\./|\\|\.\\|\^|\.\^)\s* comment: Operator symbols scope: keyword.operator.symbols.matlab parens: - match: \( scope: punctuation.section.parens.begin.matlab push: - meta_scope: meta.parens.matlab - match: \) scope: punctuation.section.parens.end.matlab pop: true - include: allofem - include: end_in_parens special_characters: - match: '((\%([\+\-0]?\d{0,3}(\.\d{1,3})?)(c|d|e|E|f|g|G|s|((b|t)?(o|u|x|X))))|\%\%|\\(b|f|n|r|t|\\))' comment: Operator symbols scope: constant.character.escape.matlab string: - match: '((?<=(\[|\(|\{|=|\s|;|:|,))|^)''' scope: punctuation.definition.string.begin.matlab push: - meta_scope: string.quoted.single.matlab - match: '''(?=(\]|\)|\}|=|~|<|>|&|\||-|\+|\*|\.|\^|\||\s|;|:|,))' scope: punctuation.definition.string.end.matlab pop: true - include: escaped_quote - include: unescaped_quote - include: special_characters transpose: - match: '((\w+)|(?<=\])|(?<=\)))\.?''' scope: keyword.operator.transpose.matlab unescaped_quote: - match: "'(?=.)" scope: invalid.illegal.unescaped-quote.matlab variable: - match: '\b[a-zA-Z]\w*\b' comment: Valid variable. Added meta to disable hilightinh scope: meta.variable.other.valid.matlab variable_assignment: - match: '=\s*\.{0,2}\s*;?\s*$\n?' comment: Incomplete variable assignment. scope: invalid.illegal.incomplete-variable-assignment.matlab variable_invalid: - match: '\b(_\w|\d+[_a-df-zA-DF-Z])\w*\b' comment: No variables or function names can start with a number or an underscore. scope: invalid.illegal.invalid-variable-name.matlab