GNUAspell / aspell

http://aspell.net
GNU Lesser General Public License v2.1
236 stars 50 forks source link

Context filter for MATLAB / GNU Octave codes #621

Open grisuthedragon opened 2 years ago

grisuthedragon commented 2 years ago

I am integrating aspell it into my GNU Octave/Matlab development and release workflow in order to check comments and string literals for errors. Therefore, I define the following mode file

MODE octave

ASPELL >=0.60.1

MAGIC /<noregex>/m

DESCRIPTION mode for checking MATLAB/Octave comments and string literals

FILTER url
FILTER context
OPTION clear-context-delimiters
OPTION add-context-delimiters % \0
OPTION add-context-delimiters ' '
OPTION add-context-delimiters " "
OPTION disable-context-visible-first

In general this works fine, but I ran into trouble with the following MATLAB/GNU Octave file:

% This is a comment, which works fine.
% Even with an ' inside this is not a problem.

str = 'erors in strings are not a problem as well'

A = QBE'*X; % But this eror is a problem.

In the last case ' denotes the transpose of an object (which is a part of the MATLAB/GNU Octave language), but not the beginning of a valid context. How can a context be constructed, such that the last case works properly as well.