add highlighting for LogicBlox
This commit is contained in:
parent
bc7d8a2ab2
commit
2fc8ffcc38
5 changed files with 204 additions and 0 deletions
55
lib/ace/mode/logicblox.js
Normal file
55
lib/ace/mode/logicblox.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var LogicBloxHighlightRules = require("./logicblox_highlight_rules").LogicBloxHighlightRules;
|
||||
// TODO: pick appropriate fold mode
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
|
||||
var Mode = function() {
|
||||
var highlighter = new LogicBloxHighlightRules();
|
||||
this.foldingRules = new FoldMode();
|
||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
// Extra logic goes here.
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
131
lib/ace/mode/logicblox_highlight_rules.js
Normal file
131
lib/ace/mode/logicblox_highlight_rules.js
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* THIS FILE WAS AUTOGENERATED FROM tool\LogicBlox.tmbundle\Syntaxes\LogicBlox.tmLanguage (UUID: 59bf5022-e261-453f-b1cb-9f9fa0712413) */
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var LogicBloxHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token: 'comment.block',
|
||||
regex: '/\\*',
|
||||
push:
|
||||
[ { token: 'comment.block', regex: '\\*/', next: 'pop' },
|
||||
{ defaultToken: 'comment.block' } ],
|
||||
//A block comment.
|
||||
},
|
||||
{ token: 'comment.single',
|
||||
regex: '//.*',
|
||||
//A single line comment.
|
||||
},
|
||||
{ token: 'constant.numeric',
|
||||
regex: '\\d+',
|
||||
//An integer constant.
|
||||
},
|
||||
{ token: 'constant.numeric',
|
||||
regex: '\\d+(.\\d+){,1}[eE][+-]{,1}\\d+',
|
||||
//Real numbers.
|
||||
},
|
||||
{ token: 'string',
|
||||
regex: '"',
|
||||
push:
|
||||
[ { token: 'string', regex: '"', next: 'pop' },
|
||||
{ defaultToken: 'string' } ],
|
||||
//Strings
|
||||
},
|
||||
{ token: 'constant.language',
|
||||
regex: '\\b(true|false)\\b',
|
||||
//Boolean values.
|
||||
},
|
||||
{ token: 'entity.name.type.logicblox',
|
||||
regex: '`[a-zA-Z_:]+(\\d|\\a)*\\b',
|
||||
//LogicBlox Symbol
|
||||
},
|
||||
{ token: 'keyword.other', regex: '->', comment: 'Constraint' },
|
||||
{ token: 'keyword.other',
|
||||
regex: '-->',
|
||||
//Level 1 Constraint
|
||||
},
|
||||
{ token: 'keyword.other', regex: '<-', comment: 'Rule' },
|
||||
{ token: 'keyword.other', regex: '<--', comment: 'Level 1 Rule' },
|
||||
{ token: 'keyword.other', regex: '\\.', comment: 'Terminator' },
|
||||
{ token: 'keyword.other', regex: '!', comment: 'Negation' },
|
||||
{ token: 'keyword.other', regex: ',', comment: 'Conjunction' },
|
||||
{ token: 'keyword.other', regex: ';', comment: 'Disjunction' },
|
||||
{ token: 'keyword.operator',
|
||||
regex: '<=|>=|!=|<|>',
|
||||
//Equality
|
||||
},
|
||||
{ token: 'keyword.other', regex: '@', comment: 'Equality' },
|
||||
{ token: 'keyword.operator',
|
||||
regex: '\\+|-|\\*|/',
|
||||
//Arithmetic operations
|
||||
},
|
||||
{ token: 'keyword', regex: '::', comment: 'Colon colon' },
|
||||
{ token: 'support.function',
|
||||
regex: '\\b(agg\\s*<<)',
|
||||
push:
|
||||
[ { include: '$self' },
|
||||
{ token: 'support.function',
|
||||
regex: '>>',
|
||||
next: 'pop' } ],
|
||||
//Aggregations
|
||||
},
|
||||
{ token: 'storage.modifier',
|
||||
regex: '\\b(lang:[\\w:]*)',
|
||||
//All the lang system predicates
|
||||
},
|
||||
{ token: [ 'storage.type', 'text' ],
|
||||
regex: '(export|sealed|clauses|block|alias)\\s*\\((?=`)',
|
||||
//Module keywords
|
||||
},
|
||||
{ token: 'entity.name',
|
||||
regex: '[a-zA-Z_][a-zA-Z_0-9:]*(@prev|@init|@final)?(?=(\\(|\\[))',
|
||||
//A predicate name.
|
||||
},
|
||||
{ token: 'variable.parameter',
|
||||
regex: '([a-zA-Z][a-zA-Z_0-9]*|_)\\s*(?=(,|\\.|<-|->|\\)|\\]|=))',
|
||||
//A variable to a functional predicate.
|
||||
} ] }
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
oop.inherits(LogicBloxHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.LogicBloxHighlightRules = LogicBloxHighlightRules;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue