Verified Commit d8e1576c authored by Camil Staps's avatar Camil Staps 🙂

Improvements to indentation tracking and rudimentary support for # (clean-cloogle/cloogle.org#179)

parent bc4e1325
......@@ -149,11 +149,12 @@ function highlightClean(func, callback, start) {
[/(\n[^\n\S]*)/, function(matches, states) {
var whitespace = matches[1];
var rest = matches[2];
var indent = whitespace.substring(1).replace('\t',' ').length;
var indent = whitespace.substring(1).replace(/\t/g,' ').length;
var cls = 'whitespace';
if (indent == 0) {
indents = [[0, 'start']];
if (!rest.match(/^[\s\n]*where/))
cls = '__reset__arguments__';
return [[cls], 'reset:start'];
......@@ -166,10 +167,8 @@ function highlightClean(func, callback, start) {
return [['whitespace']];
}
if (indent == indents[0][0]) {
indents[0][1] = states.join(';');
if (indent == indents[0][0])
return [[cls], 'reset:' + indents[0][1]];
}
indents.shift();
......@@ -217,6 +216,7 @@ function highlightClean(func, callback, start) {
[/(=>)/, ['punctuation']],
[/(")/, ['literal literal-string'], 'string'],
[/(\|)/, ['punctuation'], 'guard'],
[/(#)/, ['punctuation'], 'funcargs'],
[/(=)/, ['punctuation'], 'rhs'],
[/([^\(\){\s]+)({\|)/, ['funcname', 'punctuation'], 'genericArgs'],
[/([^\(\){[\s]+)/, ['funcname'], 'funcargs']
......@@ -225,10 +225,12 @@ function highlightClean(func, callback, start) {
[/(\S+)/, ['modulename'], 'pop']
],
funcargs: [
[/(=:)/, ['punctuation']],
[/((?::=)?=)/, ['punctuation'], 'jump:rhs'],
[/([:\[\](),{}=]+)/, ['punctuation']],
[/(\|})/, ['punctuation']],
[/(\|)/, ['punctuation'], 'jump:guard'],
[/(#)/, ['punctuation']],
[/([A-Z][^:\[\](),{}=\s]+)/, ['constructor']],
[/([^:\[\](),{}=|\s]+)/, ['argument']]
],
......@@ -336,7 +338,6 @@ function highlightClean(func, callback, start) {
],
rhs: [
[/(\n)(\|)/, ['whitespace', 'punctuation'], 'jump:guard'],
[/(\n[^\n\S]+)/, ['whitespace'], 'pop'],
[/(code\s+(?:inline\s*)?)({)/,
['keyword', 'punctuation'], 'abc'],
[/\b(if|let|in|with|case|otherwise)\b/,
......@@ -375,7 +376,7 @@ function highlightClean(func, callback, start) {
[/([^\\"]+)/, ['literal literal-string']]
],
instance: [
[/(\S+)/, ['classname'], 'jump:macro;type'],
[/(\S+)/, ['classname'], 'jump:type'],
],
className: [
[/(\()(.*)(\))(\s*)(infix[lr]?)(\s*)(\d*)(\s*)/,
......@@ -419,6 +420,7 @@ function highlightClean(func, callback, start) {
[/(\S+)/, ['label'], 'abcInstruction']
],
abcInstruction: [
[/(})/, ['punctuation'], 'pop:2'],
[/(\n)/, ['whitespace'], 'pop'],
[/(\|.*\n)/, ['comment'], 'pop'],
[/(\S+)/, ['abc-instruction'], 'jump:abcArgument']
......@@ -447,7 +449,7 @@ function highlightClean(func, callback, start) {
typeDefName: [
[/(\*)/, ['punctuation']],
[/(\(?:==)/, ['punctuation'], 'jump:typeDefSynonym'],
[/(=:?)/, ['punctuation'], 'jump:typeDefRhs'],
[/(=:?|\|)/, ['punctuation'], 'jump:typeDefRhs'],
[/([A-Z_][\w`]*)/, ['type']],
[/(\[! \])/, ['type']], // Special cases for head-strict and tail-strict lists;
[/(\[ !\])/, ['type']], // we don't want to parse whitespace there
......@@ -457,7 +459,7 @@ function highlightClean(func, callback, start) {
typeDefVars: [
[/([a-z][\w`]*)/, ['typevar']],
[/(\(?:==)/, ['punctuation'], 'jump:typeDefSynonym'],
[/(=:?)/, ['punctuation'], 'jump:typeDefRhs']
[/(=:?|\|)/, ['punctuation'], 'jump:typeDefRhs'],
],
typeDefSynonym: [
[/([a-z][a-zA-Z]*)/, ['typevar']],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment