-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add highlighting support for Single-Assignment C
- Loading branch information
Showing
4 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<steps; k++) { | ||
A = onestep(A); | ||
} | ||
|
||
return(A); | ||
} | ||
|
||
int main () | ||
{ | ||
A = with { | ||
( . <= x <= . ) : 0.0d; | ||
} : genarray( [SIZE1,SIZE2] ); | ||
|
||
A = modarray(A, [0,1], 500.0d); | ||
A = relax( A, LOOP); | ||
|
||
z = with { | ||
( 0*shape(A) <= x < shape(A) ) : A[x]; | ||
} : fold( +, 0d ); | ||
|
||
#if 0 | ||
printf("%.10g\n", z); | ||
return(0); | ||
#else | ||
print( z); | ||
return( 0); | ||
#endif | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
define(function(require, exports, module) { | ||
"use strict"; | ||
|
||
var oop = require("../lib/oop"); | ||
var TextMode = require("./text").Mode; | ||
var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules; | ||
var FoldMode = require("./folding/cstyle").FoldMode; | ||
|
||
var Mode = function() { | ||
this.HighlightRules = SaCHighlightRules; | ||
this.foldingRules = new FoldMode(); | ||
this.$behaviour = this.$defaultBehaviour; | ||
}; | ||
oop.inherits(Mode, TextMode); | ||
|
||
(function() { | ||
this.lineCommentStart = "//"; | ||
this.blockComment = {start: "/*", end: "*/"}; | ||
this.$id = "ace/mode/sac"; | ||
}).call(Mode.prototype); | ||
|
||
exports.Mode = Mode; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
define(function(require, exports, module) { | ||
"use strict"; | ||
|
||
var oop = require("../lib/oop"); | ||
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; | ||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; | ||
|
||
var sacHighlightRules = function() { | ||
|
||
var keywordControls = ( | ||
"break|continue|do|else|for|if|" + | ||
"return|with|while|use|class|all|void" | ||
); | ||
|
||
var storageType = ( | ||
"bool|char|complex|double|float|" + | ||
"byte|int|short|long|longlong|" + | ||
"ubyte|uint|ushort|ulong|ulonglong|" + | ||
"struct|typedef" | ||
); | ||
|
||
var storageModifiers = ( | ||
"inline|external|specialize" | ||
); | ||
|
||
var keywordOperators = ( | ||
"step|width" | ||
); | ||
|
||
var builtinConstants = ( | ||
"true|false" | ||
); | ||
|
||
var keywordMapper = this.$keywords = this.createKeywordMapper({ | ||
"keyword.control" : keywordControls, | ||
"storage.type" : storageType, | ||
"storage.modifier" : storageModifiers, | ||
"keyword.operator" : keywordOperators, | ||
"constant.language": builtinConstants | ||
}, "identifier"); | ||
|
||
var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b"; | ||
var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source; | ||
var formatRe = "%" | ||
+ /(\d+\$)?/.source // field (argument #) | ||
+ /[#0\- +']*/.source // flags | ||
+ /[,;:_]?/.source // separator character (AltiVec) | ||
+ /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width | ||
+ /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision | ||
+ /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier | ||
+ /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type | ||
|
||
// regexp must not have capturing parentheses. Use (?:) instead. | ||
// regexps are ordered -> 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; | ||
}); |