From 354aba630160055efd02a692b5d67258c011b8ca Mon Sep 17 00:00:00 2001 From: Hans-Nikolai Viessmann Date: Mon, 31 Jan 2022 23:26:27 +0100 Subject: [PATCH] add highlighting support for Single-Assignment C --- demo/kitchen-sink/docs/sac.sac | 75 +++++++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/sac.js | 23 ++++ lib/ace/mode/sac_highlight_rules.js | 193 ++++++++++++++++++++++++++++ 4 files changed, 292 insertions(+) create mode 100644 demo/kitchen-sink/docs/sac.sac create mode 100644 lib/ace/mode/sac.js create mode 100644 lib/ace/mode/sac_highlight_rules.js diff --git a/demo/kitchen-sink/docs/sac.sac b/demo/kitchen-sink/docs/sac.sac new file mode 100644 index 00000000000..75887980727 --- /dev/null +++ b/demo/kitchen-sink/docs/sac.sac @@ -0,0 +1,75 @@ +/***************************************************************************** + * + * SAC demo program + * + * This SAC demo program implements 2-dimensional relaxation on double + * precision floating point numbers applying a 4-point stencil and fixed + * boundary conditions. + * + * The vertical (SIZE1) and the horizontal (SIZE2) array size as well as + * the number of iterations to be performed (LOOP) may be set at compile + * time. + * + *****************************************************************************/ + +#ifndef LOOP +#define LOOP 100 +#endif + +#ifndef SIZE1 +#define SIZE1 1000 +#endif + +#ifndef SIZE2 +#define SIZE2 1000 +#endif + +use Array: all; +use StdIO: all; + +inline +double[+] onestep(double[+] B) +{ + A = with { + ( . < x < . ) : 0.25*(B[x+[1,0]] + + B[x-[1,0]] + + B[x+[0,1]] + + B[x-[0,1]]); + } : modarray( B ); + + return(A); +} + +inline +double[+] relax(double[+] A, int steps) +{ + for (k=0; k the first match is used + + this.$rules = { + "start" : [ + { + token : "comment", + regex : "//$", + next : "start" + }, { + token : "comment", + regex : "//", + next : "singleLineComment" + }, + DocCommentHighlightRules.getStartRule("doc-start"), + { + token : "comment", // multi line comment + regex : "\\/\\*", + next : "comment" + }, { + token : "string", // character + regex : "'(?:" + escapeRe + "|.)?'" + }, { + token : "string.start", + regex : '"', + stateName: "qqstring", + next: [ + { token: "string", regex: /\\\s*$/, next: "qqstring" }, + { token: "constant.language.escape", regex: escapeRe }, + { token: "constant.language.escape", regex: formatRe }, + { token: "string.end", regex: '"|$', next: "start" }, + { defaultToken: "string"} + ] + }, { + token : "string.start", + regex : 'R"\\(', + stateName: "rawString", + next: [ + { token: "string.end", regex: '\\)"', next: "start" }, + { defaultToken: "string"} + ] + }, { + token : "constant.numeric", // hex + regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b" + }, { + token : "keyword", // pre-compiler directives + regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b", + next : "directive" + }, { + token : "keyword", // special case pre-compiler directive + regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b" + }, { + token : "support.function", + regex : "fold|foldfix|genarray|modarray|propagate" + }, { + token : keywordMapper, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*" + }, { + token : "keyword.operator", + regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/ + }, { + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\." + }, { + token : "paren.lparen", + regex : "[[({]" + }, { + token : "paren.rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } + ], + "comment" : [ + { + token : "comment", // closing comment + regex : "\\*\\/", + next : "start" + }, { + defaultToken : "comment" + } + ], + "singleLineComment" : [ + { + token : "comment", + regex : /\\$/, + next : "singleLineComment" + }, { + token : "comment", + regex : /$/, + next : "start" + }, { + defaultToken: "comment" + } + ], + "directive" : [ + { + token : "constant.other.multiline", + regex : /\\/ + }, + { + token : "constant.other.multiline", + regex : /.*\\/ + }, + { + token : "constant.other", + regex : "\\s*<.+?>", + next : "start" + }, + { + token : "constant.other", // single line + regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]', + next : "start" + }, + { + token : "constant.other", // single line + regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']", + next : "start" + }, + // "\" implies multiline, while "/" implies comment + { + token : "constant.other", + regex : /[^\\\/]+/, + next : "start" + } + ] + }; + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); + this.normalizeRules(); +}; + +oop.inherits(sacHighlightRules, TextHighlightRules); + +exports.sacHighlightRules = sacHighlightRules; +});