fixeria has uploaded this change for review. (
https://gerrit.osmocom.org/c/docker-playground/+/37968?usp=email )
Change subject: gerrit: add syntax highlighting plugin for TTCN-3
......................................................................
gerrit: add syntax highlighting plugin for TTCN-3
Change-Id: I41c1021219967adf1e47187f082be50599c79d70
Related: OS#5514
---
M gerrit/Dockerfile
A gerrit/highlightjs-plugin.js
A gerrit/highlightjs-ttcn3.js
3 files changed, 354 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/68/37968/1
diff --git a/gerrit/Dockerfile b/gerrit/Dockerfile
index 2e27e3b..dedddd0 100644
--- a/gerrit/Dockerfile
+++ b/gerrit/Dockerfile
@@ -8,6 +8,8 @@
ARG libopenid="WEB-INF/lib/com_google_gerrit_httpd_auth_openid_libopenid.jar"
ARG loginform="com/google/gerrit/httpd/auth/openid/LoginForm.html"
+WORKDIR /root/
+
RUN \
unzip "$gerritwar" "$libopenid" && \
unzip "$libopenid" "$loginform"
@@ -15,6 +17,9 @@
COPY add_osmocom.diff /tmp
RUN patch -p0 < /tmp/add_osmocom.diff
+COPY highlightjs-plugin.js /root/WEB-INF/plugins
+COPY highlightjs-ttcn3.js /root/WEB-INF/plugins
+
RUN \
zip -u "$libopenid" "$loginform" && \
zip -u "$gerritwar" "$libopenid"
diff --git a/gerrit/highlightjs-plugin.js b/gerrit/highlightjs-plugin.js
new file mode 100644
index 0000000..08d517f
--- /dev/null
+++ b/gerrit/highlightjs-plugin.js
@@ -0,0 +1,9 @@
+import ttcn3 from 'highlightjs-ttcn3.js'
+
+Gerrit.install(plugin => {
+ plugin.on('highlightjs-loaded', hljs => {
+ hljs.registerLanguage('ttcn3', ttcn3);
+ })
+});
+
+// vim:set ts=2 sw=2 et:
diff --git a/gerrit/highlightjs-ttcn3.js b/gerrit/highlightjs-ttcn3.js
new file mode 100644
index 0000000..1f539f9
--- /dev/null
+++ b/gerrit/highlightjs-ttcn3.js
@@ -0,0 +1,340 @@
+/* vim:set ts=2 sw=2 et: */
+
+/*
+Language: TTCN-3
+Description: TTCN-3 is a domain specific programming language used particularly (but not
only) in the telecom domain.
+Website:
http://www.ttcn-3.org/
+Category: common, protocols
+Spec: ETSI ES 201 873-1 V4.15.1
+Author: Vadim Yanitskiy <vyanitskiy(a)sysmocom.de>
+*/
+
+export default function(hljs) {
+ const IDENT_RE = /[a-zA-Z][a-zA-Z0-9_]*/; /* section A.1.3 */
+ const RESERVED_WORDS = [ /* table A.3 */
+ 'action',
+ 'activate',
+ 'address',
+ 'alive',
+ 'all',
+ 'alt',
+ 'altstep',
+ 'and',
+ 'and4b',
+ 'any',
+ 'anytype',
+ 'bitstring',
+ 'boolean',
+ 'break',
+ 'case',
+ 'call',
+ 'catch',
+ 'char',
+ 'charstring',
+ 'check',
+ 'clear',
+ 'complement',
+ 'component',
+ 'connect',
+ 'const',
+ 'continue',
+ 'control',
+ 'create',
+ 'deactivate',
+ 'decmatch',
+ 'default',
+ 'disconnect',
+ 'display',
+ 'do',
+ 'done',
+ 'else',
+ 'encode',
+ 'enumerated',
+ 'error',
+ 'except',
+ 'exception',
+ 'execute',
+ 'extends',
+ 'extension',
+ 'external',
+ 'fail',
+ 'false',
+ 'float',
+ 'for',
+ 'friend',
+ 'from',
+ 'function',
+ 'getverdict',
+ 'getcall',
+ 'getreply',
+ 'goto',
+ 'group',
+ 'halt',
+ 'hexstring',
+ 'if',
+ 'ifpresent',
+ 'import',
+ 'in',
+ 'inconc',
+ 'infinity',
+ 'inout',
+ 'integer',
+ 'interleave',
+ 'isbound',
+ 'ischosen',
+ 'ispresent',
+ 'isvalue',
+ 'kill',
+ 'killed',
+ 'label',
+ 'language',
+ 'length',
+ 'log',
+ 'map',
+ 'match',
+ 'message',
+ 'mixed',
+ 'mod',
+ 'modifies',
+ 'module',
+ 'modulepar',
+ 'mtc',
+ 'noblock',
+ 'none',
+ 'not',
+ 'not_a_number',
+ 'not4b',
+ 'nowait',
+ 'null',
+ 'octetstring',
+ 'of',
+ 'omit',
+ 'on',
+ 'optional',
+ 'or',
+ 'or4b',
+ 'out',
+ 'override',
+ 'param',
+ 'pass',
+ 'pattern',
+ 'permutation',
+ 'port',
+ 'present',
+ 'private',
+ 'procedure',
+ 'public',
+ 'raise',
+ 'read',
+ 'receive',
+ 'record',
+ 'recursive',
+ 'rem',
+ 'repeat',
+ 'reply',
+ 'return',
+ 'running',
+ 'runs',
+ 'select',
+ 'self',
+ 'send',
+ 'sender',
+ 'set',
+ 'setencode',
+ 'setverdict',
+ 'signature',
+ 'start',
+ 'stop',
+ 'subset',
+ 'superset',
+ 'system',
+ 'template',
+ 'testcase',
+ 'timeout',
+ 'timer',
+ 'to',
+ 'trigger',
+ 'true',
+ 'type',
+ 'union',
+ 'universal',
+ 'unmap',
+ 'value',
+ 'valueof',
+ 'var',
+ 'variant',
+ 'verdicttype',
+ 'while',
+ 'with',
+ 'xor',
+ 'xor4b',
+ ];
+
+ const BUILT_INS = [
+ 'action',
+ 'activate',
+ 'any2unistr',
+ 'bit2hex',
+ 'bit2int',
+ 'bit2oct',
+ 'bit2str',
+ 'call',
+ 'catch',
+ 'char2int',
+ 'char2oct',
+ 'check',
+ 'clear',
+ 'complement',
+ 'connect',
+ 'create',
+ 'deactivate',
+ 'decmatch',
+ 'decvalue',
+ 'decvalue_o',
+ 'decvalue_unichar',
+ 'disconnect',
+ 'encode',
+ 'encvalue',
+ 'encvalue_o',
+ 'encvalue_unichar',
+ 'enum2int',
+ 'execute',
+ 'float2int',
+ 'get_stringencoding',
+ 'getcall',
+ 'getreply',
+ 'getverdict',
+ 'halt',
+ 'hex2bit',
+ 'hex2int',
+ 'hex2oct',
+ 'hex2str',
+ 'hostid',
+ 'int2bit',
+ 'int2char',
+ 'int2enum',
+ 'int2float',
+ 'int2hex',
+ 'int2oct',
+ 'int2str',
+ 'int2unichar',
+ 'isbound',
+ 'ischosen',
+ 'ispresent',
+ 'istemplatekind',
+ 'isvalue',
+ 'kill',
+ 'killed',
+ 'length',
+ 'lengthof',
+ 'log',
+ 'map',
+ 'match',
+ 'oct2bit',
+ 'oct2char',
+ 'oct2hex',
+ 'oct2int',
+ 'oct2str',
+ 'oct2unichar',
+ 'raise',
+ 'receive',
+ 'record',
+ 'regexp',
+ 'remove_bom',
+ 'replace',
+ 'reply',
+ 'rnd',
+ 'running',
+ 'send',
+ 'setencode',
+ 'setverdict',
+ 'sizeof',
+ 'start',
+ 'stop',
+ 'str2float',
+ 'str2hex',
+ 'str2int',
+ 'str2oct',
+ 'substr',
+ 'testcasename',
+ 'timeout',
+ 'trigger',
+ 'unichar2int',
+ 'unichar2oct',
+ 'unmap',
+ 'value',
+ 'valueof',
+ ];
+
+ const LITERALS = [
+ 'error',
+ 'fail',
+ 'false',
+ 'inconc',
+ 'infinity',
+ 'none',
+ 'null',
+ 'omit',
+ 'pass',
+ 'true',
+ ];
+
+ const TYPES = [
+ 'address',
+ 'anytype',
+ 'bitstring',
+ 'boolean',
+ 'charstring',
+ 'default',
+ 'float',
+ 'hexstring',
+ 'integer',
+ 'octetstring',
+ 'universal',
+ 'universal charstring',
+ 'verdicttype',
+ ];
+
+ const KEYWORDS = {
+ keyword: RESERVED_WORDS,
+ built_in: BUILT_INS,
+ literal: LITERALS,
+ type: TYPES,
+ };
+
+ const STRING = {
+ className: 'string',
+ variants: [
+ { /* octstring */
+ match: /'([a-fA-F0-9]{2}|\?|\*)*'O/,
+ relevance: 10,
+ },
+ { /* hexstring */
+ match: /'[a-fA-F0-9\?\*]*'H/,
+ relevance: 10,
+ },
+ { /* bitstring */
+ match: /'[01\?\*]*'B/,
+ relevance: 10,
+ },
+ hljs.APOS_STRING_MODE,
+ hljs.QUOTE_STRING_MODE,
+ ],
+ };
+
+ return {
+ name: 'TTCN-3',
+ aliases: [
+ 'ttcn',
+ 'ttcn3',
+ 'ttcnpp',
+ ],
+ keywords: KEYWORDS,
+ illegal: '(\\*=|\\+=|-=)',
+ contains: [
+ hljs.C_BLOCK_COMMENT_MODE,
+ hljs.C_LINE_COMMENT_MODE,
+ STRING,
+ ]
+ };
+}
--
To view, visit
https://gerrit.osmocom.org/c/docker-playground/+/37968?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I41c1021219967adf1e47187f082be50599c79d70
Gerrit-Change-Number: 37968
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>