Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1c #4132

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

1c #4132

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
778 changes: 778 additions & 0 deletions demo/kitchen-sink/docs/_1c.1c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/ace/ext/modelist.js
Expand Up @@ -43,6 +43,7 @@ Mode.prototype.supportsFile = function(filename) {

// todo firstlinematch
var supportedModes = {
_1C: ["1c"],
ABAP: ["abap"],
ABC: ["abc"],
ActionScript:["as"],
Expand Down Expand Up @@ -206,6 +207,7 @@ var supportedModes = {
};

var nameOverrides = {
_1C: "1C 7.7,8.x",
ObjectiveC: "Objective-C",
CSharp: "C#",
golang: "Go",
Expand Down
58 changes: 58 additions & 0 deletions lib/ace/mode/_1c.js
@@ -0,0 +1,58 @@
/* ***** 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 BY mode.tmpl.js
*/

define(function (require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var _1CHighlightRules = require("./_1c_highlight_rules")._1CHighlightRules;
var _1CFoldMode = require("./folding/1c").FoldMode;

var Mode = function () {
this.HighlightRules = _1CHighlightRules;
this.foldingRules = new _1CFoldMode();
this.$behaviour = this.$defaultBehaviour;
};
oop.inherits(Mode, TextMode);

(function () {
this.lineCommentStart = "//";
// this.blockComment = {start: ""/*"", end: ""*/""};
// Extra logic goes here.
this.$id = "ace/mode/1c";
}).call(Mode.prototype);

exports.Mode = Mode;
});
123 changes: 123 additions & 0 deletions lib/ace/mode/_1c_highlight_rules.js
@@ -0,0 +1,123 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, 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 TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var _1CHighlightRules = function() {

var keywords = (
"процедура|функция|конецпроцедуры|конецфункции|для|пока|по|цикл|конеццикла|если|тогда|иначе|иначеесли|конецесли|попытка|исключение|конецпопытки|каждого|" +
"перем|знач|и|или|не|новый|прервать|продолжить|возврат|экспорт|массив|структура|соответствие|массив|вызватьисключение" +
"procedure|function|endprocedure|endfunction|for|while|to|do|enddo|if|then|else|elseif|endif|try|catch|endtry|each|" +
"var|val|and|or|not|new|break|continue|return|export|array|structure|map|rise"
);
var builtinConstants = (
"истина|ложь|неопределено|true|false"
);
var builtinFunctions = (
"лев|сред|прав|цел|окр|минимум|максимум|число|строка|дата|формат|сокрлп|сокрл|символ|кодсимвола|" +
"врег|нрег|трег|найти|стрнайти|стрчисловхождений|пустаястрока|стрзаменить|стрчислострок|стрполучитьстроку|" +
"стрразделить|стрсоединить|год|месяц|день|час|минута|секунда|началогода|началоквартала|началомесяца|началонедели|" +
"началодня|началочаса|началоминуты|конецгода|конецквартала|конецмесяца|конецнедели|конецдня|конецчаса|конецминуты|" +
"тип|типзнч|показатьвопрос|вопрос|предупреждение|сообщить"
);
var dataTypes = (
"константы|справочники|документы|журналыдокументов|перечисления|регистрысведений|регистрынакопления|отчеты|обработки" +
"планывидовхарактеристик|планыобмена|параметрысеанса|роли|общиереквизиты|общиеформы|общиемакеты|критерииотбора"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants,
"types": dataTypes
}, "identifier", true);

this.$rules = {
"start" : [ {
token : "comment",
regex : "\/\/.*"
},
{
token: keywordMapper,
regex: "[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*"
},
{
token : "label",
regex : "~(\u0020|\t)*[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*(\u0020|\t)*:"
},
{
token : "string", // ' string
regex : "\"{1,1}[^\"]*\"{1,1}"
},
{
token : "identifier", // ' identifier
regex : "[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*"
},
{
token : "doubleoperator", // ' doubleoperator
regex : "<=|<>|>="
},
{
token : "singleoperator", // ' singleoperator
regex : "[\\+\\-\\*/%&<>=]"
},
{
token : "number", // ' number
regex : "[0-9]*(\.[0-9])+"
},
{
token : "paren.lparen",
regex : "[\\(]"
},
{
token : "paren.rparen",
regex : "[\\)]"
},
{
token : "paren.lsqare",
regex : "[\\[]"
},
{
token : "paren.rsqare",
regex : "[\\]]"
}
]
};
this.normalizeRules();
};

oop.inherits(_1CHighlightRules, TextHighlightRules);

exports._1CHighlightRules = _1CHighlightRules;
});
183 changes: 183 additions & 0 deletions lib/ace/mode/folding/1c.js
@@ -0,0 +1,183 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, 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 Range = require("../../range").Range;
var CFoldMode = require("./cstyle").FoldMode;

var FoldMode = exports.FoldMode = function(commentRegex) {
if (commentRegex) {
this.foldingStartMarker = new RegExp(
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
);
this.foldingStopMarker = new RegExp(
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
);
}
};
oop.inherits(FoldMode, CFoldMode);

(function() {
this.procRe = /^\s*процедура|procedure\s*/i;
this.funcRe = /^\s*функция|function\s*/i;

this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
this.getFoldWidgetBase = this.getFoldWidget;

this.getFoldWidget = function(session, foldStyle, row) {
var fw = this.getFoldWidgetBase(session, foldStyle, row);
if (!fw) {
var line = session.getLine(row);
if (this.procRe.test(line) || this.funcRe.test(line)) {
return "start";
}
}
return fw;
};

this.getFoldWidgetRange = function(session, foldStyle, row) {
var range = this.getFoldWidgetRangeBase(session, foldStyle, row);
if (range)
return range;

var line = session.getLine(row);
if (this.procRe.test(line))
return this.getProcStatementBlock(session, line, row);
if (this.funcRe.test(line))
return this.getFuncStatementBlock(session, line, row);
};

this.getProcStatementBlock = function(session, line, row) {
var startColumn = line.match(this.procRe)[0].length + 1;
var openBrackets = 0;
var closeBrackets = 0;
var foundStart = false;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;

var cLine = session.getLine(row);
for (var currentPos = startColumn; currentPos < cLine.length; currentPos++ ) {
if (currentPos > 0 && cLine[currentPos-1] === '/' && cLine[currentPos] === '/') {
break; // comment
}
if (cLine[currentPos] === '(') openBrackets++;
else if (cLine[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startColumn = cLine.length;
foundStart = true;
break;
}
}
var re = /^\s*конецпроцедуры|endprocedure\s*/i;

while (++row < maxRow) {
line = session.getLine(row);
if (!foundStart) {
for (var currentPos = 0; currentPos < line.length; currentPos++ ) {
if (currentPos > 0 && line[currentPos-1] === '/' && line[currentPos] === '/') {
break; // comment
}
if (line[currentPos] === '(') openBrackets++;
else if (line[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startRow = row;
startColumn = line.length;
foundStart = true;
break;
}
}
}
if (re.test(line))
break;
endRow = row+1;
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);
}
};
this.getFuncStatementBlock = function(session, line, row) {
var startColumn = line.match(this.funcRe)[0].length;
var openBrackets = 0;
var closeBrackets = 0;
var foundStart = false;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;

var cLine = session.getLine(row);
for (var currentPos = startColumn; currentPos < cLine.length; currentPos++ ) {
if (currentPos > 0 && cLine[currentPos-1] === '/' && cLine[currentPos] === '/') {
break; // comment
}
if (cLine[currentPos] === '(') openBrackets++;
else if (cLine[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startColumn = cLine.length;
foundStart = true;
break;
}
}
var re = /^\s*конецфункции|endfunction\s*/i;
while (++row < maxRow) {
line = session.getLine(row);

if (!foundStart) {
for (var currentPos = 0; currentPos < line.length; currentPos++ ) {
if (currentPos > 0 && line[currentPos-1] === '/' && line[currentPos] === '/') {
break; // comment
}
if (line[currentPos] === '(') openBrackets++;
else if (line[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startRow = row;
startColumn = line.length;
foundStart = true;
break;
}
}
}
if (re.test(line))
break;
endRow = row+1;
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);
}
};

}).call(FoldMode.prototype);

});
7 changes: 7 additions & 0 deletions lib/ace/snippets/_1c.js
@@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";

exports.snippetText = require("../requirejs/text!./_1c.snippets");
exports.scope = "_1c";

});
Empty file added lib/ace/snippets/_1c.snippets
Empty file.