Skip to content

Commit 02951ce

Browse files
authored
Implement 1S:Enterprise (#545)
1 parent 4436c49 commit 02951ce

File tree

5 files changed

+225
-1
lines changed

5 files changed

+225
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ K | Kotlin
5050
L | Lighttpd configuration file, LLVM, Lua
5151
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
5252
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
53-
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
53+
O | Objective-C, OCaml, Octave, OnesEnterprise, OpenSCAD, Org Mode
5454
P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, PromQL, Protocol Buffer, Puppet, Python 2, Python
5555
Q | QBasic
5656
R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust

Diff for: lexers/o/onesenterprise.go

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package o
2+
3+
import (
4+
. "github.com/alecthomas/chroma" // nolint
5+
"github.com/alecthomas/chroma/lexers/internal"
6+
)
7+
8+
// 1S:Enterprise lexer.
9+
var OnesEnterprise = internal.Register(MustNewLazyLexer(
10+
&Config{
11+
Name: "OnesEnterprise",
12+
Aliases: []string{"ones", "onesenterprise", "1S", "1S:Enterprise"},
13+
Filenames: []string{"*.EPF", "*.epf", "*.ERF", "*.erf"},
14+
MimeTypes: []string{"application/octet-stream"},
15+
CaseInsensitive: true,
16+
},
17+
onesRules,
18+
))
19+
20+
func onesRules() Rules {
21+
return Rules{
22+
"root": {
23+
{`\n`, Text, nil},
24+
{`\s+`, Text, nil},
25+
{`\\\n`, Text, nil},
26+
{`[^\S\n]+`, Text, nil},
27+
{`//(.*?)\n`, Comment, nil},
28+
{`(#область|#region|#конецобласти|#endregion|#если|#if|#иначе|#else|#конецесли|#endif).*`, CommentPreproc, nil},
29+
{`(&наклиенте|&atclient|&насервере|&atserver|&насерверебезконтекста|&atservernocontext|&наклиентенасерверебезконтекста|&atclientatservernocontext).*`, CommentPreproc, nil},
30+
{`(>=|<=|<>|\+|-|=|>|<|\*|/|%)`, Operator, nil},
31+
{`(;|,|\)|\(|\.)`, Punctuation, nil},
32+
{Words(``, `\b`, `истина`, `true`, `ложь`, `false`, `и`, `and`, `или`, `or`, `не`, `not`), Operator, nil},
33+
{Words(``, `\b`, `если`, `if`, `тогда`, `then`, `иначе`, `else`, `иначеесли`, `elsif`, `конецесли`, `endif`), Operator, nil},
34+
{Words(``, `\b`, `для`, `for`, `каждого`, `each`, `из`, `in`, `цикл`, `do`, `пока`, `while`, `конеццикла`, `enddo`, `по`, `to`), Operator, nil},
35+
{Words(``, `\b`, `прервать`, `break`, `продолжить`, `continue`, `возврат`, `return`, `перейти`, `goto`), Operator, nil},
36+
{Words(``, `\b`, `процедура`, `procedure`, `конецпроцедуры`, `endprocedure`, `функция`, `function`, `конецфункции`, `endfunction`), Keyword, nil},
37+
{Words(``, `\b`, `новый`, `new`, `знач`, `val`, `экспорт`, `export`, `перем`, `var`), Keyword, nil},
38+
{Words(``, `\b`, `попытка`, `try`, `исключение`, `except`, `вызватьисключение`, `raise`, `конецпопытки`, `endtry`), Keyword, nil},
39+
{Words(``, `\b`, `выполнить`, `execute`, `вычислить`, `eval`), Keyword, nil},
40+
{`"`, LiteralString, Push("string")},
41+
{`[_а-яА-Я0-9][а-яА-Я0-9]*`, Name, nil},
42+
{`[_\w][\w]*`, Name, nil},
43+
},
44+
"string": {
45+
{`""`, LiteralString, nil},
46+
{`"C?`, LiteralString, Pop(1)},
47+
{`[^"]+`, LiteralString, nil},
48+
},
49+
}
50+
}

Diff for: lexers/testdata/onesenterprise.actual

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Область СлужебныйПрограммныйИнтерфейс
2+
3+
&НаСервере
4+
Функция Создать(ИмяФайла) Экспорт
5+
6+
//Создает новый архив
7+
8+
Инфо = Новый Файл(ИмяФайла);
9+
Если Инфо.Существует() Тогда
10+
УдалитьФайлы(ИмяФайла);
11+
КонецЕсли;
12+
13+
Архив = Новый Структура;
14+
Архив.Вставить("Поток", ФайловыеПотоки.ОткрытьДляЗаписи(ИмяФайла));
15+
Архив.Вставить("Файлы", Новый Массив);
16+
Архив.Вставить("РазмерКаталога", 0);
17+
18+
Если Архив.РазмерКаталога > 0 Или Архив.Файлы.Количество() <> 0 Тогда
19+
Возврат Неопределено;
20+
КонецЕсли;
21+
22+
Возврат Архив;
23+
24+
КонецФункции
25+
26+
#КонецОбласти

Diff for: lexers/testdata/onesenterprise.expected

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
[
2+
{"type":"CommentPreproc","value":"#Область СлужебныйПрограммныйИнтерфейс"},
3+
{"type":"Text","value":"\n\n"},
4+
{"type":"CommentPreproc","value":"\u0026НаСервере"},
5+
{"type":"Text","value":"\n"},
6+
{"type":"Keyword","value":"Функция"},
7+
{"type":"Text","value":" "},
8+
{"type":"Name","value":"Создать"},
9+
{"type":"Punctuation","value":"("},
10+
{"type":"Name","value":"ИмяФайла"},
11+
{"type":"Punctuation","value":")"},
12+
{"type":"Text","value":" "},
13+
{"type":"Keyword","value":"Экспорт"},
14+
{"type":"Text","value":"\n\t\n\t"},
15+
{"type":"Comment","value":"//Создает новый архив\n"},
16+
{"type":"Text","value":"\n\t"},
17+
{"type":"Name","value":"Инфо"},
18+
{"type":"Text","value":" "},
19+
{"type":"Operator","value":"="},
20+
{"type":"Text","value":" "},
21+
{"type":"Keyword","value":"Новый"},
22+
{"type":"Text","value":" "},
23+
{"type":"Name","value":"Файл"},
24+
{"type":"Punctuation","value":"("},
25+
{"type":"Name","value":"ИмяФайла"},
26+
{"type":"Punctuation","value":");"},
27+
{"type":"Text","value":"\n\t"},
28+
{"type":"Operator","value":"Если"},
29+
{"type":"Text","value":" "},
30+
{"type":"Name","value":"Инфо"},
31+
{"type":"Punctuation","value":"."},
32+
{"type":"Name","value":"Существует"},
33+
{"type":"Punctuation","value":"()"},
34+
{"type":"Text","value":" "},
35+
{"type":"Operator","value":"Тогда"},
36+
{"type":"Text","value":"\n\t\t"},
37+
{"type":"Name","value":"УдалитьФайлы"},
38+
{"type":"Punctuation","value":"("},
39+
{"type":"Name","value":"ИмяФайла"},
40+
{"type":"Punctuation","value":");"},
41+
{"type":"Text","value":"\n\t"},
42+
{"type":"Operator","value":"КонецЕсли"},
43+
{"type":"Punctuation","value":";"},
44+
{"type":"Text","value":"\n\t\n\t"},
45+
{"type":"Name","value":"Архив"},
46+
{"type":"Text","value":" "},
47+
{"type":"Operator","value":"="},
48+
{"type":"Text","value":" "},
49+
{"type":"Keyword","value":"Новый"},
50+
{"type":"Text","value":" "},
51+
{"type":"Name","value":"Структура"},
52+
{"type":"Punctuation","value":";"},
53+
{"type":"Text","value":"\n\t"},
54+
{"type":"Name","value":"Архив"},
55+
{"type":"Punctuation","value":"."},
56+
{"type":"Name","value":"Вставить"},
57+
{"type":"Punctuation","value":"("},
58+
{"type":"LiteralString","value":"\"Поток\""},
59+
{"type":"Punctuation","value":","},
60+
{"type":"Text","value":" "},
61+
{"type":"Name","value":"ФайловыеПотоки"},
62+
{"type":"Punctuation","value":"."},
63+
{"type":"Name","value":"ОткрытьДляЗаписи"},
64+
{"type":"Punctuation","value":"("},
65+
{"type":"Name","value":"ИмяФайла"},
66+
{"type":"Punctuation","value":"));"},
67+
{"type":"Text","value":"\n\t"},
68+
{"type":"Name","value":"Архив"},
69+
{"type":"Punctuation","value":"."},
70+
{"type":"Name","value":"Вставить"},
71+
{"type":"Punctuation","value":"("},
72+
{"type":"LiteralString","value":"\"Файлы\""},
73+
{"type":"Punctuation","value":","},
74+
{"type":"Text","value":" "},
75+
{"type":"Keyword","value":"Новый"},
76+
{"type":"Text","value":" "},
77+
{"type":"Name","value":"Массив"},
78+
{"type":"Punctuation","value":");"},
79+
{"type":"Text","value":"\n\t"},
80+
{"type":"Name","value":"Архив"},
81+
{"type":"Punctuation","value":"."},
82+
{"type":"Name","value":"Вставить"},
83+
{"type":"Punctuation","value":"("},
84+
{"type":"LiteralString","value":"\"РазмерКаталога\""},
85+
{"type":"Punctuation","value":","},
86+
{"type":"Text","value":" "},
87+
{"type":"Name","value":"0"},
88+
{"type":"Punctuation","value":");"},
89+
{"type":"Text","value":"\n\n\t"},
90+
{"type":"Operator","value":"Если"},
91+
{"type":"Text","value":" "},
92+
{"type":"Name","value":"Архив"},
93+
{"type":"Punctuation","value":"."},
94+
{"type":"Name","value":"РазмерКаталога"},
95+
{"type":"Text","value":" "},
96+
{"type":"Operator","value":"\u003e"},
97+
{"type":"Text","value":" "},
98+
{"type":"Name","value":"0"},
99+
{"type":"Text","value":" "},
100+
{"type":"Operator","value":"Или"},
101+
{"type":"Text","value":" "},
102+
{"type":"Name","value":"Архив"},
103+
{"type":"Punctuation","value":"."},
104+
{"type":"Name","value":"Файлы"},
105+
{"type":"Punctuation","value":"."},
106+
{"type":"Name","value":"Количество"},
107+
{"type":"Punctuation","value":"()"},
108+
{"type":"Text","value":" "},
109+
{"type":"Operator","value":"\u003c\u003e"},
110+
{"type":"Text","value":" "},
111+
{"type":"Name","value":"0"},
112+
{"type":"Text","value":" "},
113+
{"type":"Operator","value":"Тогда"},
114+
{"type":"Text","value":"\n\t\t"},
115+
{"type":"Operator","value":"Возврат"},
116+
{"type":"Text","value":" "},
117+
{"type":"Name","value":"Неопределено"},
118+
{"type":"Punctuation","value":";"},
119+
{"type":"Text","value":"\n\t"},
120+
{"type":"Operator","value":"КонецЕсли"},
121+
{"type":"Punctuation","value":";"},
122+
{"type":"Text","value":"\n\t\n\t"},
123+
{"type":"Operator","value":"Возврат"},
124+
{"type":"Text","value":" "},
125+
{"type":"Name","value":"Архив"},
126+
{"type":"Punctuation","value":";"},
127+
{"type":"Text","value":"\n\t\n"},
128+
{"type":"Keyword","value":"КонецФункции"},
129+
{"type":"Text","value":"\n\n"},
130+
{"type":"CommentPreproc","value":"#КонецОбласти"}
131+
]

Diff for: styles/onesenterprise.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package styles
2+
3+
import (
4+
"github.com/alecthomas/chroma"
5+
)
6+
7+
// 1S:Designer color palette
8+
var OnesEnterprise = Register(chroma.MustNewStyle("onesenterprise", chroma.StyleEntries{
9+
chroma.Text: "#000000",
10+
chroma.Comment: "#008000",
11+
chroma.CommentPreproc: "#963200",
12+
chroma.Operator: "#FF0000",
13+
chroma.Keyword: "#FF0000",
14+
chroma.Punctuation: "#FF0000",
15+
chroma.LiteralString: "#000000",
16+
chroma.Name: "#0000FF",
17+
}))

0 commit comments

Comments
 (0)