MATLAB: Make strings greedy + handle line feeds better
This commit is contained in:
parent
ea380c6c6c
commit
4cd4f01b87
|
@ -1,10 +1,12 @@
|
|||
Prism.languages.matlab = {
|
||||
// We put string before comment, because of printf() patterns that contain "%"
|
||||
'string': /\B'(?:''|[^'\n])*'/,
|
||||
'comment': [
|
||||
/%\{[\s\S]*?\}%/,
|
||||
/%.+/
|
||||
],
|
||||
'string': {
|
||||
pattern: /\B'(?:''|[^'\r\n])*'/,
|
||||
greedy: true
|
||||
},
|
||||
// FIXME We could handle imaginary numbers as a whole
|
||||
'number': /\b-?(?:\d*\.?\d+(?:[eE][+-]?\d+)?(?:[ij])?|[ij])\b/,
|
||||
'keyword': /\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Prism.languages.matlab={string:/\B'(?:''|[^'\n])*'/,comment:[/%\{[\s\S]*?\}%/,/%.+/],number:/\b-?(?:\d*\.?\d+(?:[eE][+-]?\d+)?(?:[ij])?|[ij])\b/,keyword:/\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,"function":/(?!\d)\w+(?=\s*\()/,operator:/\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,punctuation:/\.{3}|[.,;\[\](){}!]/};
|
||||
Prism.languages.matlab={comment:[/%\{[\s\S]*?\}%/,/%.+/],string:{pattern:/\B'(?:''|[^'\r\n])*'/,greedy:!0},number:/\b-?(?:\d*\.?\d+(?:[eE][+-]?\d+)?(?:[ij])?|[ij])\b/,keyword:/\b(?:break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while)\b/,"function":/(?!\d)\w+(?=\s*\()/,operator:/\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?/,punctuation:/\.{3}|[.,;\[\](){}!]/};
|
|
@ -2,13 +2,17 @@
|
|||
%{}%
|
||||
%{ foo
|
||||
bar }%
|
||||
% 'test'
|
||||
%{ 'test' }%
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["comment", "% foobar"],
|
||||
["comment", "%{}%"],
|
||||
["comment", "%{ foo\r\nbar }%"]
|
||||
["comment", "%{ foo\r\nbar }%"],
|
||||
["comment", "% 'test'"],
|
||||
["comment", "%{ 'test' }%"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
''
|
||||
'foo''bar'
|
||||
'%s'
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
[
|
||||
["string", "''"],
|
||||
["string", "'foo''bar'"]
|
||||
["string", "'foo''bar'"],
|
||||
["string", "'%s'"]
|
||||
]
|
||||
|
||||
----------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue