Update 'Section Syntax'
parent
8b41f7f857
commit
1530276ef5
111
Section-Syntax.md
Normal file
111
Section-Syntax.md
Normal file
@ -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.
|
17
Sections.md
17
Sections.md
@ -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.
|
|
Reference in New Issue
Block a user