From: Carlos Maniero <carlos@maniero.me>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Carlos Maniero <carlos@maniero.me>
Subject: [PATCH olang] docs: introduce olang for newcomers
Date: Tue, 08 Oct 2024 03:15:15 +0000 (UTC) [thread overview]
Message-ID: <20241008031511.20808-1-carlos@maniero.me> (raw)
The section introduction and getting started was empty in our manual.
Even that this is not the final documentation, this is something we can
iterate over to provide a basic O programming language overview for
newcomers.
Signed-off-by: Carlos Maniero <carlos@maniero.me>
---
docs/info/getting-started.texi | 229 +++++++++++++++++++++++++++++++++
docs/info/introduction.texi | 6 +
2 files changed, 235 insertions(+)
diff --git a/docs/info/getting-started.texi b/docs/info/getting-started.texi
index e94f124..e9ff5d3 100644
--- a/docs/info/getting-started.texi
+++ b/docs/info/getting-started.texi
@@ -1,2 +1,231 @@
@node Getting Started
@chapter Getting Started
+
+Welcome to the O programming language! This chapter will introduce you to the
+basics of the language's syntax. We'll cover variables, data types, operators,
+control flow, and functions.
+
+By the end of this chapter, you'll have a solid foundation in the O language
+syntax and be ready to start writing your own programs. Let's dive in!
+
+@section An olang program
+
+An O programmin language program starts with a @code{main} function. This
+function must return the program exit code.
+
+@verbatim
+fn main(): u8 {
+ return 0;
+}
+@end verbatim
+
+To compile the program you can use @code{olc}.
+
+@verbatim
+$ olc my_prog.ol -o my_prog
+$ ./my_prog
+@end verbatim
+
+@section Functions
+
+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.
+
+@verbatim
+fn main(): u8 {
+ return fib(8)
+}
+
+fn add(a: u32, b: u32): u32 {
+ return a + b
+}
+
+fn fib(n: u32): u32 {
+ if n <= 2 {
+ return n
+ }
+
+ return add(fib(n - 1), fib(n - 2))
+}
+@end verbatim
+
+@section Comments
+
+Comments starts with a @code{#}.
+
+@verbatim
+# Hi I'm a comment and I'll be ignored by the compiler.
+@end verbatim
+
+@section Variables
+
+@verbatim
+var answer: u32 = 42
+@end verbatim
+
+@section Flow control
+
+Any non zero expr is true.
+
+@verbatim
+if expr {
+ # statement
+} else {
+ # statement
+}
+@end verbatim
+
+@section Primitive data types
+
+@table @samp
+
+@item u8
+
+Unsigned 8 bits.
+
+@item u16
+
+Unsigned 16 bits.
+
+@item u32
+
+Unsigned 32 bits.
+
+@item u64
+
+Unsigned 64 bits.
+
+@end table
+
+@section Binary Operations
+
+Binary operations are pretty much like C.
+
+@subsection Logical
+
+@table @samp
+
+@item Equals
+
+@verbatim
+expr1 == expr2
+@end verbatim
+
+Results zero (false) or one (true).
+
+@item Less
+
+@verbatim
+expr1 < expr2
+@end verbatim
+
+Results zero (false) or one (true).
+
+@item Less Equal
+
+@verbatim
+expr1 <= expr2
+@end verbatim
+
+Results zero (false) or one (true).
+
+@item Greater
+
+@verbatim
+expr1 > expr2
+@end verbatim
+
+Results zero (false) or one (true).
+
+@item Greater Equal
+
+@verbatim
+expr1 >= expr2
+@end verbatim
+
+Results zero (false) or one (true).
+
+@item Or
+
+@verbatim
+expr1 || expr2
+@end verbatim
+
+Results zero (false) if both are true or one (true) if any is true.
+
+@item And
+
+@verbatim
+expr1 && expr2
+@end verbatim
+
+Results zero (false) if any is false or one (true) if both are true.
+
+@end table
+
+@subsection Bitwise
+
+@table @samp
+
+@item Shift left
+
+@verbatim
+n << bits
+@end verbatim
+
+@item Shift left
+
+@verbatim
+n >> bits
+@end verbatim
+
+@item And
+
+@verbatim
+n & bits
+@end verbatim
+
+@item Or
+
+@verbatim
+n | bits
+@end verbatim
+
+@end table
+
+@subsection Arithmetic
+
+@table @samp
+
+@item Addition
+
+@verbatim
+expr1 + expr2
+@end verbatim
+
+@item Subtraction
+
+@verbatim
+expr1 - expr2
+@end verbatim
+
+@item Multiplication
+
+@verbatim
+expr1 * expr2
+@end verbatim
+
+@item Division
+
+@verbatim
+expr1 / expr2
+@end verbatim
+
+@item Remaining
+
+@verbatim
+expr1 % expr2
+@end verbatim
+
+@end table
diff --git a/docs/info/introduction.texi b/docs/info/introduction.texi
index 4fb7cbc..579880f 100644
--- a/docs/info/introduction.texi
+++ b/docs/info/introduction.texi
@@ -1,3 +1,9 @@
@node Introduction
@chapter Introduction
+Welcome to the O programming manual. This manual will guide you to learn the
+language principles and how to contribute if you are a low level geek.
+
+Olang is a project maintained by enthusiast individuals across the globe. Join
+us in the system programming language universe. Let's fight complexity
+together.
base-commit: 5415f1e48b199feb6d63461f0adfffafb13d005a
--
2.46.0
next reply other threads:[~2024-10-08 3:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 3:15 Carlos Maniero [this message]
2024-10-08 3:15 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-10-08 9:57 ` [PATCH olang] docs: introduce olang for newcomers Johnny Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241008031511.20808-1-carlos@maniero.me \
--to=carlos@maniero.me \
--cc=~johnnyrichard/olang-devel@lists.sr.ht \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.johnnyrichard.com/olang.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox