From 1530276ef578aa7e582a709475480e8ac6999ec1 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 24 Aug 2022 06:10:51 +0000 Subject: [PATCH] Update 'Section Syntax' --- Section-Syntax.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++ Sections.md | 17 ------- 2 files changed, 111 insertions(+), 17 deletions(-) create mode 100644 Section-Syntax.md delete mode 100644 Sections.md diff --git a/Section-Syntax.md b/Section-Syntax.md new file mode 100644 index 0000000..a1de2ce --- /dev/null +++ b/Section-Syntax.md @@ -0,0 +1,111 @@ +Sections start with a name token that is four letters long, and determines what +kind of section it is. It then has a permission token, and then a name which +defines the name of the section. There may be more tokens after the name +depending on what type of section it is. If the section's information does not +fit on one line, it will have an indented block underneath it with its content. + +There are 6 different types of sections that ARF supports: + +- objt: Object Type Definitions +- type: Blind Type Definitions +- enum: Enums +- face: Interfaces +- data: Data +- func: Functions and Methods + +This page covers syntactical elements of sections in general. For more detailed information, visit the section pages indivitually under the "Sections" section. +# Syntax of Different Sections + +## objt + +``` +objt ro Basic:Obj + ro that:Basic + ro this:Basic + +objt ro ComplexInit:Obj + ro whatever:{Int 3} + 230984 + 849 394580 + ro complex0:Bird + .that 98 + .this 2 + ro complex1:Bird + .that 98902 + .this 235 + ro basic:Int 87 +``` + +Object section syntax allows for members to be declared underneath it. It must have a type that it inherits from. It should not have anything after the type specifier. + +Currently, object section syntax does not support nested object definitions. + +Each member should start with a permission, then have a name, then a type specifier. After that, +they can have an optional initialization value. + +## type + +``` +type ro Basic:Int + +type ro BasicInit:Int 6 + +type ro IntArrayInit:{Int 3} + 3298 923 92 +``` + +Blind typedefs are very simple. They are composed of the inherited type, and an optional default value. + +## enum + +``` +enum ro NamedColor:U32 + red 0xFF0000 + green 0x00FF00 + blue 0x0000FF +``` + +Enums are also very simple. Each line under an enum represents a member and is composed of a name, and an optional initialization value. + +## face + +``` +face ro ReadWriter:Face + write + > data:{Byte ..} + < wrote:Int + < err:Error + read + > into:{Byte ..} + < read:Int + < err:Error +``` + +Interface sections contain a list of behaviors. Behaviors are a name followed by an indented block of inputs and outputs. It is essentially a more stripped down version of function syntax. + +## data + +``` +data ro integer:Int 3202 + +data ro integerArrayInitialized:{Int 16} + 3948 293 293049 948 912 + 340 0 2304 0 4785 92 +``` + +Data sections are syntactically similar to blind typedef sections. + +## func + +``` +func ro someFunction + @ reciever:SomeObject + > input:Int + < output:Int:mut + --- + somePhrase +``` + +Function sections are divided in two. The first part can contain inputs, outputs, and a method reciever. Inputs are preceded by a '>', outputs are preceded by a '<', and the method reciever is preceded by a '@'. Function outputs can have default values, whether they be simple or complex. + +The latter part contains the actual code of the function, which is composed of phrases. \ No newline at end of file diff --git a/Sections.md b/Sections.md deleted file mode 100644 index 7be09ac..0000000 --- a/Sections.md +++ /dev/null @@ -1,17 +0,0 @@ -Sections start with a name token that is four letters long, and determines what -kind of section it is. It then has a permission token, and then a name which -defines the name of the section. There may be more tokens after the name -depending on what type of section it is. If the section's information does not -fit on one line, it will have an indented block underneath it with its content. - -Here is a simple data section to illustrate how sections are written: - -``` -data ro someValue:{Int 4} - 3948 2934 - 39 289 -``` - -This is a data section whose value is read-only, is named someValue, and is an -array of integers with a length of 4. Its elements are initialized in the -indented block below. \ No newline at end of file