eric6/ThirdParty/Pygments/pygments/lexers/matlab.py

changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
equal deleted inserted replaced
7982:48d210e41c65 7983:54c5cfbb1e29
3 pygments.lexers.matlab 3 pygments.lexers.matlab
4 ~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for Matlab and related languages. 6 Lexers for Matlab and related languages.
7 7
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
135 (r'^\s*%\}', Comment.Multiline, '#pop'), 135 (r'^\s*%\}', Comment.Multiline, '#pop'),
136 (r'^.*\n', Comment.Multiline), 136 (r'^.*\n', Comment.Multiline),
137 (r'.', Comment.Multiline), 137 (r'.', Comment.Multiline),
138 ], 138 ],
139 'deffunc': [ 139 'deffunc': [
140 (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)', 140 (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
141 bygroups(Whitespace, Text, Whitespace, Punctuation, 141 bygroups(Whitespace, Text, Whitespace, Punctuation,
142 Whitespace, Name.Function, Punctuation, Text, 142 Whitespace, Name.Function, Punctuation, Text,
143 Punctuation, Whitespace), '#pop'), 143 Punctuation, Whitespace), '#pop'),
144 # function with no args 144 # function with no args
145 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), 145 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'),
636 ], 636 ],
637 'string': [ 637 'string': [
638 (r"[^']*'", String, '#pop'), 638 (r"[^']*'", String, '#pop'),
639 ], 639 ],
640 'deffunc': [ 640 'deffunc': [
641 (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)', 641 (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
642 bygroups(Whitespace, Text, Whitespace, Punctuation, 642 bygroups(Whitespace, Text, Whitespace, Punctuation,
643 Whitespace, Name.Function, Punctuation, Text, 643 Whitespace, Name.Function, Punctuation, Text,
644 Punctuation, Whitespace), '#pop'), 644 Punctuation, Whitespace), '#pop'),
645 # function with no args 645 # function with no args
646 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), 646 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'),
647 ], 647 ],
648 } 648 }
649
650 def analyse_text(text):
651 """Octave is quite hard to spot, and it looks like Matlab as well."""
652 return 0
649 653
650 654
651 class ScilabLexer(RegexLexer): 655 class ScilabLexer(RegexLexer):
652 """ 656 """
653 For Scilab source code. 657 For Scilab source code.
704 'string': [ 708 'string': [
705 (r"[^']*'", String, '#pop'), 709 (r"[^']*'", String, '#pop'),
706 (r'.', String, '#pop'), 710 (r'.', String, '#pop'),
707 ], 711 ],
708 'deffunc': [ 712 'deffunc': [
709 (r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)', 713 (r'(\s*)(?:(\S+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
710 bygroups(Whitespace, Text, Whitespace, Punctuation, 714 bygroups(Whitespace, Text, Whitespace, Punctuation,
711 Whitespace, Name.Function, Punctuation, Text, 715 Whitespace, Name.Function, Punctuation, Text,
712 Punctuation, Whitespace), '#pop'), 716 Punctuation, Whitespace), '#pop'),
713 # function with no args 717 # function with no args
714 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), 718 (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'),

eric ide

mercurial