Skip to content

Commit 45bce85

Browse files
committed
[Tolk] Syntax highlighting via Prism.js
1 parent e1f7951 commit 45bce85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+654
-69
lines changed

extra.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,55 @@ table {
7575
div[data-component-part="callout-content"]>.code-block:last-child {
7676
margin-bottom: 0;
7777
}
78+
79+
/*
80+
A temporary solution syntax highlighting of Tolk snippets: invoke Prism.js on a client-side.
81+
See `snippets/tolk-highlight.jsx`.
82+
*/
83+
84+
:root {
85+
--tolk-token-comment: #808080;
86+
--tolk-token-type-hint: #D500EC;
87+
--tolk-token-keyword: #0000FF;
88+
--tolk-token-struct: #007EA2;
89+
--tolk-token-variable: #444444;
90+
--tolk-token-attr-name: #808000;
91+
--tolk-token-function: #A82D2D;
92+
--tolk-token-number: #0B9000;
93+
--tolk-token-string: #008000;
94+
--tolk-token-string-bg: #FAF9EF;
95+
--tolk-token-operator: #A0A000;
96+
--tolk-token-punctuation: #808000;
97+
--tolk-token-three-dots: #999999;
98+
}
99+
100+
.token.comment { color: var(--tolk-token-comment); font-style: italic; }
101+
.token.type-hint { color: var(--tolk-token-type-hint); }
102+
.token.boolean { color: var(--tolk-token-keyword); }
103+
.token.keyword { color: var(--tolk-token-keyword); }
104+
.token.self { color: var(--tolk-token-variable); font-weight: bold; }
105+
.token.attr-name { color: var(--tolk-token-attr-name); }
106+
.token.function { color: var(--tolk-token-function); }
107+
.token.number { color: var(--tolk-token-number); }
108+
.token.string { color: var(--tolk-token-string); background-color: var(--tolk-token-string-bg); }
109+
.token.operator { color: var(--tolk-token-operator); }
110+
.token.punctuation { color: var(--tolk-token-punctuation); }
111+
.token.three-dots { color: var(--tolk-token-three-dots); }
112+
.token.struct { color: var(--tolk-token-struct); }
113+
.token.variable { color: var(--tolk-token-variable); }
114+
115+
html.dark {
116+
--tolk-token-comment: #808080;
117+
--tolk-token-type-hint: #DF90F8;
118+
--tolk-token-keyword: #D75F02;
119+
--tolk-token-struct: #56C1FF;
120+
--tolk-token-variable: #C5D2E0;
121+
--tolk-token-attr-name: #808000;
122+
--tolk-token-function: #F9B900;
123+
--tolk-token-number: #33A033;
124+
--tolk-token-string: #33A033;
125+
--tolk-token-string-bg: #1B1C1E;
126+
--tolk-token-operator: #A0A000;
127+
--tolk-token-punctuation: #85B2A0;
128+
--tolk-token-three-dots: #777777;
129+
}

languages/tolk/basic-syntax.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ title: "Tolk basic syntax"
33
sidebarTitle: "Basic syntax"
44
---
55

6-
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
79

810
Syntax of Tolk is similar to TypeScript, Rust, and Kotlin. It is designed to be straightforward to read and write.
911

languages/tolk/features/asm-functions.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Assembler functions"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Functions in Tolk may be defined using assembler code.
811
It's a low-level feature that requires deep understanding of stack layout, [Fift](/languages/fift/overview), and [TVM](/tvm/overview).

languages/tolk/features/auto-serialization.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
title: "Automatic serialization"
33
---
44

5+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
6+
7+
<TolkHighlight />
8+
59
All data in TON (messages, storage, etc.) is represented with **cells**.
610
Tolk type system is designed to express cell contents,
711
enabling auto-serialization via `fromCell` and `toCell`:

languages/tolk/features/compiler-optimizations.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Compiler optimizations"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Tolk compiler is smart enough to generate optimal bytecode from a clear, idiomatic code.
811
The ideal target is "zero overhead": extracting variables and simple methods should not increase gas consumption.

languages/tolk/features/contract-getters.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Contract getters"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Contract getters (or "get methods") are declared using `get fun xxx()`.
811
They typically return data extracted from [storage](/languages/tolk/features/contract-storage).

languages/tolk/features/contract-storage.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Contract storage"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Contract storage is not "something special".
811
It is a regular `struct`, serialized into persistent blockchain data.

languages/tolk/features/lazy-loading.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Lazy loading"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Tolk language has a magic feature — the `lazy` keyword.
811
The compiler tracks exactly which fields are accessed, and automatically loads only those, skipping the rest.

languages/tolk/features/message-handling.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
title: "Handling messages"
33
---
44

5+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
6+
7+
<TolkHighlight />
8+
59
Each Tolk contract has specials **entrypoints** — reserved functions to handle various types of messages.
610
From the language perspective, handling an incoming message is just ordinary code.
711

languages/tolk/features/message-sending.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ title: "Sending messages"
33
---
44

55
import { Aside } from '/snippets/aside.jsx';
6+
import { TolkHighlight } from "/snippets/tolk-highlight.jsx";
7+
8+
<TolkHighlight />
69

710
Tolk provides a high-level function `createMessage`. In practice, it's immediately followed by `send`:
811

0 commit comments

Comments
 (0)