Skip to content

Commit b850577

Browse files
committed
Add prologue documentation.
1 parent caf4071 commit b850577

17 files changed

+348
-16
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ add_library(hic_objects OBJECT
5454
"${CMAKE_CURRENT_SOURCE_DIR}/src/tokenizer_parse_operator.cpp"
5555
"${CMAKE_CURRENT_SOURCE_DIR}/src/tokenizer_parse_positional_argument.cpp"
5656
"${CMAKE_CURRENT_SOURCE_DIR}/src/tokenizer_parse_string.cpp"
57+
"${CMAKE_CURRENT_SOURCE_DIR}/src/tokenizer_parse_version.cpp"
5758
"${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.cpp"
5859
"${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.hpp"
5960
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# module-declaration
2+
3+
## Syntax
4+
5+
`application` [_string_literal_](string_literal.md) __(__ `if` [_compile_condition_](compile_condition.md) __|__ `fallback` __)?__
6+
7+
## Semantics
8+
9+
Each file must have a `application` (or [`module`](module_declaration.md))
10+
declaration to give the file a executable name.
11+
12+
The optional compile-condition is evaluated during the prologue-scan phase of compilation,
13+
this checks if the file should be compiled.
14+
15+
Multiple files may have the same module-name, only if the conditional compilation is
16+
mutually exclusive. If a file has a `fallback` condition, it will be used if no other
17+
file with the same module-name is compiled.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# compile-condition
2+
3+
## Syntax
4+
5+
'`(` _compile_condition_ `)` __|__
6+
[_identifier_](identifier.md) __|__
7+
[_integer_literal_](integer_literal.md) __|__
8+
[_version_literal_](version_literal.md) __|__
9+
_compile_condition_ `<` _compile_condition_ __|__
10+
_compile_condition_ `>` _compile_condition_ __|__
11+
_compile_condition_ `<=` _compile_condition_ __|__
12+
_compile_condition_ `>=` _compile_condition_ __|__
13+
_compile_condition_ `==` _compile_condition_ __|__
14+
_compile_condition_ `!=` _compile_condition_ __|__
15+
_compile_condition_ `and` _compile_condition_ __|__
16+
_compile_condition_ `or` _compile_condition_ __|__
17+
`not` _compile_condition_
18+
19+
## Semantics
20+
21+
If a identifier is a `false`, then any comparison with a version-literal or integer-literal is `false` as well.
22+
23+
Build phases:
24+
- **download**: Download data before generating code.
25+
- **generate**: Generate code before building.
26+
- **build**: Build normal applications.
27+
28+
Build type:
29+
- **debug**: Application is build for debugging.
30+
- **release**: Application is build for release.
31+
32+
Operating systems:
33+
- **windows**: (version) Build for Microsoft Windows platform. Version of Windows
34+
- **macos**: (version) Build for Apple MacOS platform. Version of MacOS.
35+
- **linux**: (version) Build for Linux platform. Version of Linux kernel.
36+
- **ios**: (version) Mobile version of `macos`, which is also set.
37+
- **android**: (version) Mobile version of `linux`, which is also set.
38+
39+
Platform:
40+
- **desktop**:
41+
- **phone**:
42+
- **watch**:
43+
- **pad**:
44+
45+
The CPU:
46+
- **x86**: Intel x86 CPU. Integer is register size.
47+
- **x86_32**
48+
- **x86_64**
49+
- **x86_64v1**
50+
- **x86_64v2**
51+
- **x86_64v3**
52+
- **x86_64v4**
53+
- **x86_AVX**: Intel x86 AVX feature.
54+
- **arm**: Arm CPU. Integer is register size.
55+
- **arm_32**
56+
- **arm_64**

doc/language/syntax/file.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# File
2+
3+
## Syntax
4+
5+
[_prologue_](prologue.md)
6+
7+
## Semantics
8+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# import-declaration
2+
3+
## Syntax
4+
5+
`import` [_module_name_](module_name.md) `weak`__?__
6+
7+
## Semantics
8+
9+
An `import` declaration is used to import a module into the current file.

doc/language/syntax/literal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
[_boolean-literal_](boolean_literal.md) __|__\
99
[_null-literal_](null_literal.md) __|__\
1010
[_character-literal_](character_literal.md) __|__\
11+
[_version-literal_](version_literal.md) __|__
1112

1213
## Semantics
1314
A literal is a constant value that is directly represented in the source code.
1415
The literal can be an integer, float, string, boolean, null, or character.
16+
17+
version-literal is specifically added to be used with conditional-compilation,
18+
to compare with operating system or library versions. This is done at a very early stage of compilation, which
19+
is not able to use the standard library.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# module-declaration
2+
3+
## Syntax
4+
5+
`module` [_module_name_](module_name.md) __(__ `if` [_compile_condition_](compile_condition.md) __|__ `fallback` __)?__
6+
7+
## Semantics
8+
9+
Each file must have a `module` (or [`application`](application_declaration.md))
10+
declaration to give the file a module-name.
11+
12+
The optional compile-condition is evaluated during the prologue-scan phase of compilation,
13+
this checks if the file should be compiled.
14+
15+
Multiple files may have the same module-name, only if the conditional compilation is
16+
mutually exclusive. If a file has a `fallback` condition, it will be used if no other
17+
file with the same module-name is compiled.

doc/language/syntax/prologue.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Prologue
2+
3+
## Syntax
4+
5+
__(__ [_module_declaration_](module_declaration.md) __|__ [_application_declaration_](application_declaration.md) __)__ [_import_statement_](import_statement.md)__*__
6+
7+
## Semantic
8+
9+
The prologue of a file contains only `module`, `application` and `import` statements, this makes it easy
10+
to make a parser to quickly scan all the source files to create a dependency tree.
11+
12+
During prologue scan the parser can exit early.
13+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# version-literal
2+
3+
## Syntax
4+
5+
\[0-9\]__{1-7}__ `v` __(__ \[0-9\]__+__ __(__ `.` \[0-9\]__+__ __)?__ __)?__
6+
7+
## Semantics
8+

doc/language/tools/hic_toml.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# hic.toml
2+
3+
The `hic.toml` file is a configuration file used to specify the dependencies of a Hic project or package. It is written in TOML (Tom's Obvious, Minimal Language) format.
4+
5+
## Section Structure
6+
7+
### \[package\]
8+
The `[package]` section is where you define the metadata for your Hic package. This includes the name, version, and other details that describe the package.
9+
10+
```toml
11+
[package]
12+
name = "com.example.my_package"
13+
description = "A sample Hic package"
14+
version = "1.0.0"
15+
```
16+
17+
#### name
18+
The `name` field specifies the name of the package. It should be a valid module name, which typically follows the format `com.example.my_package`; reverse domain names are commonly used to avoid naming conflicts.
19+
20+
All modules-names in the package must have the prefix of the package name.
21+
22+
### \[dependencies\]
23+
24+
The `[dependencies]` section is where you define the external packages that your Hic project depends on. Each dependency is specified with a key-value pair, where the key is the name of the package and the value is an object containing the details of the dependency.
25+
26+
```toml
27+
[dependencies]
28+
com.example.foo = { git = "https://github.com/example/foo.git", branch = "v1.0" }
29+
com.example.baz = { url = "https://example.com/baz-2.3.zip"}
30+
com.example.qux = { path = "./local-qux" }
31+
com.example.bar = {}
32+
```
33+

0 commit comments

Comments
 (0)