From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ePtuNn6SLWfD8AAAe85BDQ:P1 (envelope-from ) for ; Fri, 08 Nov 2024 05:24:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id ePtuNn6SLWfD8AAAe85BDQ (envelope-from ) for ; Fri, 08 Nov 2024 05:24:31 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b="ZxAJ7b/2"; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b="mOIA/FL/"; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Seal: i=2; s=key1; d=johnnyrichard.com; t=1731039870; a=rsa-sha256; cv=pass; b=BRtziEIwMbzdp0n9POOAwT6f3a/nzCIHmAxpC5aNAEpLsBdVlp/krtJ69XmT518iZRaYvQ ekDFq3KiomK+/My5bKaLSYgZ4jlliJBQDUWtDvZvocMqJdSDDkEGyHlBCMPMMfJohRkify NJQD/oEN/EP+7bqLTNlUBJq3wkSSPqNLA/3eGcs7sIg2mP0cDMu6xKjOpLvahpDb1+92sB MiDTThWsnfxOFIXT8MGzHXeoHCt5k8FsYQVf3TQiBgm9xagt0oZBuSBYHIk6LAQ/H19dxT kqDUzbu+rXIEnWoKn57LyIYOhozuJmIs2qQZ+hXJ+f0E9JapRt2KcCa8Z6DReg== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b="ZxAJ7b/2"; dkim=pass header.d=maniero.me header.s=hostingermail1 header.b="mOIA/FL/"; dmarc=pass (policy=none) header.from=maniero.me; arc=pass ("mailchannels.net:s=arc-2022:i=1"); spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1731039870; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=G1q/bCwk3hB5/VpDUx5+WzD8a9gYS6wipjgspzZauq4=; b=1woraeTIcnRi6gAubFt0e6Glfb+FoJhSfZjmehfgROEYDoA4jnMVmenoDDTusDveJzHknp XDRd4BUp2A2fd7MBzN4gO7CsjJTiixvqtLn6fEs1ITM7ByYp1eYDnFWK9sR3T1HPwHWCo6 5REG0MdRNtmnmM4sdYt0EaTi0aWGv2E7mx6ziffa6uxY71nfTBnUto+j1V1W+yRzM2Jt2h qWJm/aqNn2iYgVc8zBNtlIqAO/EQzC1iXRqD9/1gWSxgOHDY/1YUj8jv3hdssJJF5sfYJ4 xXpnIXSJJ1n8/cmcoCwyv6DMNnSeedCj4x5lg3dPX6/SsIoO9S3orFQehqx2BA== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 346B677573 for ; Fri, 08 Nov 2024 05:24:27 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=sNaTZ9PUX5iNTdTLQuAE6dsP0gcafObDPayRy9tzQgg=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1731039866; v=1; b=ZxAJ7b/26Qd6aZqUTRjS8OUm5ykCohDrnvuYkPcyHzHv44uqoo+Ld3S4Cy8NkZapuDVjX62H hb/17Nl/Kw/zTcVO+2WvgDXQnb5CYQ5O3KjJlB9t7i5dqlfWXA1vxHGuueR4hzw5CMDIAYZHtgb p2SKyuKKcUxsZIW73SGIaqrDe6pV/dqJ1MWMZL6aW0bOVNeev3ovucAMNKlOO51YlNlecUCe7x5 zA4ImWQJ9PDNI5aXmn2a6vP2i7w6b5+WwMdLNpB7FRK+8oYIKISKmbeI6kTHzsHfRwi3XkryBvr mg/gdvUAAK2krWEfkV419dtvrfJFyz2H1urr9WAr8N72Q== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id D653F203EC for ; Fri, 08 Nov 2024 04:24:26 +0000 (UTC) Received: from slategray.cherry.relay.mailchannels.net (slategray.cherry.relay.mailchannels.net [23.83.223.169]) by mail-a.sr.ht (Postfix) with ESMTPS id BF1A2203D1 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 08 Nov 2024 04:24:21 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CFAD48A2111 for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 8 Nov 2024 04:24:19 +0000 (UTC) Received: from nl-srv-smtpout1.hostinger.io (100-111-63-5.trex-nlb.outbound.svc.cluster.local [100.111.63.5]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 00C158A3BDE for <~johnnyrichard/olang-devel@lists.sr.ht>; Fri, 8 Nov 2024 04:24:18 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1731039859; a=rsa-sha256; cv=none; b=5GjP4We6jHLeDDq1852wmU8PQTN8rf+AJwrvbWpDaOMrAmKGU2TfzoBn+OQ122pnTUQ4nt Klj2Gz3OK7hYHJ/XrumSvdOpeRfZQyXqte12hQk9FN7DaE4xcQWchB7Pm6idanYVHw4Y20 /iZj5ukhxF1/I4b6B7qazYHIxZzcEVJkcK1WlQlOgcuJUDCuvMnrypbUvY8OJwwmDG7LBQ cX60rHxKGptIOmfa2lUujRwRjQPQakLROjhHWJkE0viyYo2hz4Fkzfp6B133JRoJOuwWLO +0Cc17UDxklN/TDc6Pr7N1HHCV4oj1vKOF2+Dllp6H53SY14TRghQyo08psxxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1731039859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:dkim-signature; bh=G1q/bCwk3hB5/VpDUx5+WzD8a9gYS6wipjgspzZauq4=; b=BYJ1r5YminuZZjH1/3cgLRBFAATcT4artwVxu6PL/hFsgWd2aajMo3JRwiC+krDlMnbqk+ k4M64x5D/TjQJXIDz9EkmC1fGkQ01ltveWRR/x+8yYijHql5EUexMYnRN2hxhxu76PiYhF +ej/LfImmrVHoDv3/vCXF9WyPGL5Y78ZLc4lAAK+frULIwy1QibcnKk/hllu+0aUF7Hfad Uh/nP3cEMEBVBBTY5fCFM6IRwEUMZCXIKTr/XveRQXrKlWqG9lGOG7KbGziW1vOewRTLis mKYCA1akSqLym37dqhE6PUk3K/W4OiO8+rBJ1PZfOqVUVkTRhHudbzDGaf7C1w== ARC-Authentication-Results: i=1; rspamd-594776fdf8-t82kw; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Whistle-Illegal: 3fa95e1a41290e81_1731039859599_2289686441 X-MC-Loop-Signature: 1731039859599:1448692506 X-MC-Ingress-Time: 1731039859598 Received: from nl-srv-smtpout1.hostinger.io (nl-srv-smtpout1.hostinger.io [145.14.150.87]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.111.63.5 (trex/7.0.2); Fri, 08 Nov 2024 04:24:19 +0000 From: Carlos Maniero DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1731039857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=G1q/bCwk3hB5/VpDUx5+WzD8a9gYS6wipjgspzZauq4=; b=mOIA/FL/t6X+QcZIhqyL6PvFMRJIY7QqJ0xbQ/jgNul95HaNBIV0LzMaLuwz0AcZmdQo5e QMmRJpb9+c+ihvFZZQ69+p73yCzPLl92+/Ysgsbb6CPL6ZL0uj0lyNWv4gl1gQbAY5Y2NI oG2orZq31KgznA/zSV8JoIYumeRDye394cDhnYLy+NDjWbe1FpYg2de4FYPvuK+SPlNVrg Ph4m12/kJyZtfTI1YReaOrfN6LgW5zIfkjQcCJwcYww0jGGr/CNeNYAL1pYxJs29bBpfuP plPpCATQd/8AYhjmhPJxpu2V0urlOi+53XLh5VMOi1bl54+vYBskamLknYBV1A== To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Carlos Maniero Subject: [PATCH olang v1] docs: add code highlight post processor Message-ID: <20241108042411.105478-1-carlos@maniero.me> X-Mailer: git-send-email 2.46.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Date: Fri, 08 Nov 2024 04:24:16 +0000 (UTC) X-CM-Envelope: MS4xfOE329f6+/wZhG76P/ZRciRLEV9WKxTnsuykdFgq2518RIH2cUvLzBV8QVYJ7ZV4Yj3/0EisYZDzByYV3XWoWEUaGQt5jzIjFEfru2yB03i11UCivElQ o4kRfvNHHo+2Wn3mXaXl9diQ7/bCkEz76LRL1ttjgzCSmEZn5P+FOyiKCB9frskIBcacv3gcNf3MpejbHicpYI3FyW8pX9DdEonQL5cecNXyi6ZOnaeiM9Ow X-CM-Analysis: v=2.4 cv=fpCOZ04f c=1 sm=1 tr=0 ts=672d9271 a=WwxFCuf3mf1fs3oSi6/dng==:117 a=WwxFCuf3mf1fs3oSi6/dng==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=mDV3o1hIAAAA:8 a=Oq8BXowDd8p49Wk_HHcA:9 a=jCEwsxz9xVFXAJ8V:21 a=WAbmWdyXlmQA:10 a=opHs5xzUWSMA:10 a=BXDaF_L80NY05PYiAFlV:22 X-AuthUser: carlos@maniero.me X-Sourcehut-Patchset-Status: PROPOSED List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -5.51 X-Spam-Score: -5.51 X-Migadu-Queue-Id: 346B677573 X-Migadu-Scanner: mx10.migadu.com X-TUID: 8pCjRyaB9h2p This a very simple token based code highlighter that is not able to evaluate syntax. How it works: The @sethl inserts a html comment at generated html. The generated html file is than post processed by the script which highlights the code. The alternative is to use the texi2any *HIGHLIGHT_SYNTAX* [1] experimental feature, which would require the inclusion of other dependency to the project. [1]: https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Syntax-Highlighting.html Signed-off-by: Carlos Maniero --- docs/info/Makefile | 1 + docs/info/_ext.texi | 15 +++++ docs/info/c-ffi.texi | 17 +++++- docs/info/codehl.py | 104 +++++++++++++++++++++++++++++++++ docs/info/getting-started.texi | 32 +++++++++- docs/info/specification.texi | 3 + docs/style.css | 92 ++++++++++++++++++++++++++--- 7 files changed, 250 insertions(+), 14 deletions(-) create mode 100644 docs/info/_ext.texi create mode 100644 docs/info/codehl.py diff --git a/docs/info/Makefile b/docs/info/Makefile index b2d29a4..12cb790 100644 --- a/docs/info/Makefile +++ b/docs/info/Makefile @@ -6,6 +6,7 @@ all: html html: olang.texi introduction.texi installation.texi getting-started.texi specification.texi contribution-guide.texi $(MAKEINFO) --set-customization-variable AFTER_BODY_OPEN="$(HTML_HEADER)" --css-include=../style.css -o html --html olang.texi + find html -name '*.html' | xargs python3 codehl.py .PHONY: clean clean: diff --git a/docs/info/_ext.texi b/docs/info/_ext.texi new file mode 100644 index 0000000..2a0d6e7 --- /dev/null +++ b/docs/info/_ext.texi @@ -0,0 +1,15 @@ +@ifclear olc_info_ext +@macro sethl{lang} +@html + +@end html +@end macro + +@macro sethl-{lang} +@html + +@end html +@end macro +@end ifclear + +@set olc_info_ext diff --git a/docs/info/c-ffi.texi b/docs/info/c-ffi.texi index 719fcd5..12ba9d0 100644 --- a/docs/info/c-ffi.texi +++ b/docs/info/c-ffi.texi @@ -1,3 +1,5 @@ +@include _ext.texi + @node C FFI @chapter C FFI @@ -13,6 +15,7 @@ To call external code you can use the @code{extern} statement. @subsection extern +@sethl olang @verbatim # file: answer.ol @@ -28,6 +31,7 @@ fn main(): u8 { That way instead of defining the @code{u32print} function. It must be provided at the linkage step. +@sethl c @verbatim // file: u32print.c @@ -40,10 +44,11 @@ int u32print(int number) { @subsection Compiling without linking -If you try to compile the answer.ol file you will receive the follow error: +If you try to compile the answer.ol file by using the +@code{olc answer.ol -o answer.o} command you will receive the follow error: +@sethl- output @verbatim -olc answer.ol -o answer.o /usr/bin/ld: answer.o.o: in function `main': (.text+0x10): undefined reference to `u32print' collect2: error: ld returned 1 exit status @@ -52,6 +57,7 @@ collect2: error: ld returned 1 exit status That's because @code{O} tries to link by default. To assemble the code without linking it, you can use the @code{-c} option. +@sethl- bash @verbatim olc answer.ol -c -o answer.o @end verbatim @@ -59,12 +65,14 @@ olc answer.ol -c -o answer.o After that you can do the same with the C file that contains the function that you are looking to call. +@sethl- bash @verbatim gcc u32print.c -c -o u32print.o @end verbatim And then you can link both object files into an executable: +@sethl- bash @verbatim gcc answer.o u32print.o -o answer @end verbatim @@ -73,6 +81,7 @@ gcc answer.o u32print.o -o answer All that is required is to set the function prototype. +@sethl olang @verbatim # file: sum.ol @@ -81,8 +90,9 @@ fn sum(a: u32, b: u32): u32 { } @end verbatim +@sethl c @verbatim -# file: csum.c +// file: csum.c #include @@ -96,6 +106,7 @@ int main() { Compiling: +@sethl- bash @verbatim olc sum.ol -c -o sum.o gcc sum.o csum.c -o csum diff --git a/docs/info/codehl.py b/docs/info/codehl.py new file mode 100644 index 0000000..0749138 --- /dev/null +++ b/docs/info/codehl.py @@ -0,0 +1,104 @@ +# Copyright (C) 2024 Carlos Maniero +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +import sys +import re + +re_hl_block = r'.*?
(?P.*?)<\/pre>'
+
+lexers = {
+    'default': [
+        (r'^(?P +)', None),
+        (r'^(?P\d+)', 'num'),
+        (r'^(?P\w+)', 'ident'),
+        (r'^(?P\(|\)|{|})', 'brac'),
+        (r'^(?P&\w+;|\^|\~|!|@|\#|\$|%|&|\*|-|\+|\.|=|,|:|;|\||\\|/|\?)', 'symbol'),
+        (r'^(?P.+)', None),
+    ],
+    'olang': [
+        (r'^(?P#.*)', 'comment'),
+        (r'^(?P\w+) *?\(', 'fn-name'),
+        (r'^(?Pfn|if|else|return|while|var|const|extern)', 'key'),
+        (r'^\b(?Pu8|u16|u32|u64)\b', 'type'),
+    ],
+    'c': [
+        (r'^(?P#.*)', 'macro'),
+        (r'^(?P".*?")', 'str'),
+        (r'^(?P//.*)', 'comment'),
+        (r'^(?P\w+) *?\(', 'fn-name'),
+        (r'^(?Pfn|if|else|return|while|var|const|extern)', 'key'),
+        (r'^\b(?Pint|long|float)\b', 'type'),
+    ],
+    'bash': [
+        (r'^(?P-+.+? ?)', 'opt'),
+        (r'^(?P[A-z0\d\.-/]+)', 'ident'),
+    ],
+    'output': [
+        (r'(?P.*)', None),
+    ],
+    'ebnf': [
+        (r'^(?P.+?::=)', 'fn-name'),
+        (r'^(?P\|)', 'fn-name'),
+        (r'^(?P\?|\*)', 'key'),
+        (r'^(?P\(\*.*?\*\))', 'comment'),
+        (r'^(?P\'.*?\')', 'str'),
+    ]
+}
+
+def format_code_line(line, lang):
+    new_line = ''
+
+    lexer = lexers.get(lang, []) + lexers['default']
+
+    while line != '':
+        for (regex, name) in lexer:
+            match = re.match(regex, line)
+            if match:
+                value = match.group('value')
+                line = line[len(value):]
+                if name:
+                    new_line += f'{value}'
+                else:
+                    new_line += value
+                break
+
+
+    return f'{new_line}'
+
+def format_pre(match):
+    lang = match.group('lang')
+    css_class = match.group('class')
+    css_classes = f'code-hl lang-{lang} {css_class or ""}'.strip()
+    raw_lines = match.group('code').split('\n')
+
+    while raw_lines[-1].strip() == '':
+        raw_lines = raw_lines[:-1]
+
+    code = "\n".join([format_code_line(line, lang) for line in raw_lines])
+
+    return f'
{code}
' + +def codehl(code): + return re.sub(re_hl_block, format_pre, code, flags=re.DOTALL) + +if __name__ == '__main__': + for file_name in sys.argv[1:]: + print(f"HL\t{file_name}") + + with open(file_name, 'r+') as file: + content = codehl(file.read()) + + file.seek(0) + file.write(content) + file.truncate() diff --git a/docs/info/getting-started.texi b/docs/info/getting-started.texi index 77b9298..75c00f0 100644 --- a/docs/info/getting-started.texi +++ b/docs/info/getting-started.texi @@ -1,3 +1,5 @@ +@include _ext.texi + @node Getting Started @chapter Getting Started @@ -15,6 +17,7 @@ much the same with some small quirks. Let's dive in! An O programming language program starts with a @code{main} function. This function must return the program exit code. +@sethl olang @verbatim fn main(): u8 { return 0 @@ -23,9 +26,10 @@ fn main(): u8 { To compile the program you can use @code{olc}. +@sethl- bash @verbatim -$ olc my_prog.ol -o my_prog -$ ./my_prog +olc my_prog.ol -o my_prog +./my_prog @end verbatim @section Functions @@ -34,6 +38,7 @@ Unlike C, O language does not require function prototypes. This means you can call a function before it's defined, making your code more flexible and easier to read in many cases. +@sethl olang @verbatim fn main(): u8 { return fib(8) @@ -56,12 +61,14 @@ fn fib(n: u32): u32 { Comments starts with a @code{#}. +@sethl- olang @verbatim # Hi I'm a comment and I'll be ignored by the compiler. @end verbatim @section Variables +@sethl- olang @verbatim var answer: u32 = 42 @end verbatim @@ -72,6 +79,7 @@ Any non zero expr is true. @subsection If-Else +@sethl olang @verbatim if expr { # statement @@ -84,6 +92,7 @@ if expr { While loop +@sethl olang @verbatim while expr { # statement @@ -92,6 +101,7 @@ while expr { @subsection While loop +@sethl olang @verbatim while expr { # statement @@ -128,6 +138,7 @@ Unsigned 64 bits. @item Equals +@sethl- olang @verbatim expr1 == expr2 @end verbatim @@ -136,6 +147,7 @@ Results zero (false) or one (true). @item Less +@sethl- olang @verbatim expr1 < expr2 @end verbatim @@ -144,6 +156,7 @@ Results zero (false) or one (true). @item Less Equal +@sethl- olang @verbatim expr1 <= expr2 @end verbatim @@ -152,6 +165,7 @@ Results zero (false) or one (true). @item Greater +@sethl- olang @verbatim expr1 > expr2 @end verbatim @@ -160,6 +174,7 @@ Results zero (false) or one (true). @item Greater Equal +@sethl- olang @verbatim expr1 >= expr2 @end verbatim @@ -168,6 +183,7 @@ Results zero (false) or one (true). @item Or +@sethl- olang @verbatim expr1 || expr2 @end verbatim @@ -176,6 +192,7 @@ Results zero (false) if both are true or one (true) if any is true. @item And +@sethl- olang @verbatim expr1 && expr2 @end verbatim @@ -190,24 +207,28 @@ Results zero (false) if any is false or one (true) if both are true. @item Shift left +@sethl- olang @verbatim n << bits @end verbatim @item Shift left +@sethl- olang @verbatim n >> bits @end verbatim @item And +@sethl- olang @verbatim n & bits @end verbatim @item Or +@sethl- olang @verbatim n | bits @end verbatim @@ -220,30 +241,35 @@ n | bits @item Addition +@sethl- olang @verbatim expr1 + expr2 @end verbatim @item Subtraction +@sethl- olang @verbatim expr1 - expr2 @end verbatim @item Multiplication +@sethl- olang @verbatim expr1 * expr2 @end verbatim @item Division +@sethl- olang @verbatim expr1 / expr2 @end verbatim @item Remaining +@sethl- olang @verbatim expr1 % expr2 @end verbatim @@ -258,6 +284,7 @@ Dealing with memory address. Get the address of a variable. +@sethl olang @verbatim var my_var: u32 = 0 @@ -268,6 +295,7 @@ var my_pointer: u32* = &my_var Accessing the value of the address a pointer points to. +@sethl olang @verbatim var my_var: u32 = 0 diff --git a/docs/info/specification.texi b/docs/info/specification.texi index 707d932..47dad9a 100644 --- a/docs/info/specification.texi +++ b/docs/info/specification.texi @@ -1,3 +1,5 @@ +@include _ext.texi + @node Language Specification @chapter Specification @@ -19,4 +21,5 @@ This is the O Programming Language EBNF grammar specification[^1] NOTE: This grammar spec is a DRAFT and it covers only a small portion of the language. +@sethl ebnf @verbatiminclude olang.ebnf diff --git a/docs/style.css b/docs/style.css index 9ee71e3..0a50254 100644 --- a/docs/style.css +++ b/docs/style.css @@ -44,10 +44,6 @@ dd { margin-left: 4ch; } -pre { - margin-bottom: 1rem; -} - p { padding-bottom: 1ch; } @@ -109,12 +105,90 @@ footer { } pre { - background: gray; - color: black; - padding: 2ch; - font-weight: bold; - max-width: 100%; + margin-bottom: 1ch; + max-width: calc(100vw - 7ch); + width: calc(100vw - 7ch); overflow: auto; + position: relative; + counter-reset: line; + background: black; + color: white; + border-left: 1ch solid grey; + padding: 2ch 1ch; +} + +dd pre { + max-width: calc(100vw - 11ch); + width: calc(100vw - 11ch); +} + +pre:before, pre:after { + content: ""; + background: grey; + position: absolute; + left: 0ch; + width: 1ch; + height: 1ch; +} + +pre:before { + top: 0ch; +} +pre:after { + bottom: 0ch; +} + +.code-line { + counter-increment: line; +} + +.code-line:before { + content: "" counter(line, decimal-leading-zero) " "; + color: grey; +} + +.no-numbers .code-line:before { + content: "" +} + +.code-key { + color: yellow; +} + +.code-fn-name { + color: aqua; +} + +.code-symbol,.code-brac { + color: silver; +} + +.code-num { + color: orange; +} + +.code-type { + color: lime; +} + +.code-comment { + color: grey; +} + +.code-macro { + color: orange; +} + +.code-str { + color: lime; +} + +.lang-output { + color: grey; +} + +.lang-bash .code-opt { + color: silver; } .logo-name { -- 2.46.1