Skip to content

Commit

Permalink
Merge: v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vain0x committed Jul 21, 2022
2 parents 2d01bfc + 39361cd commit 5af4fcf
Show file tree
Hide file tree
Showing 691 changed files with 46,866 additions and 32,054 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fantomas-tool": {
"version": "4.5.0",
"version": "4.6.0-alpha-004",
"commands": [
"fantomas"
]
Expand Down
32 changes: 31 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,44 @@ insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.{fs,fsx,milone,milone_project,yml}]
[*.{fs,fsx,milone}]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.json]
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.ninja]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.{sln,fsproj}]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.ungram]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[milone_manifest]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
28 changes: 18 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@



# Third-party tools.
# Fetched files.
/bin/
src/libmilonert/hashmap.h



# Build caches.
*.generated.*
*.timestamp
build.ninja
target



# Build outputs.
# Generated files.
*.o
*.out

target/

tests/**/MiloneCore_*.c
tests/**/MiloneDerive_*.c
tests/**/Std_*.c

tests/examples/*/*.c
tests/primitives/std_*/*.c



# Deprecated: These rules are no longer used.
*.generated.*
*.timestamp
build.ninja
runtime/hashmap.h
tests/**/MiloneStd_*.c
4 changes: 2 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/runtime"
"${workspaceFolder}/src/libmilonert"
],
"defines": [],
"cStandard": "c11",
Expand All @@ -13,7 +13,7 @@
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/runtime"
"${workspaceFolder}/src/libmilonert"
],
"defines": [
"_DEBUG",
Expand Down
89 changes: 60 additions & 29 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,98 @@

(*What is ARCHITECTURE.md?* See [this article: ARCHITECTURE.md](https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html).)

## Code map
## Bird's Eye Overview

Compiler does *parse* a program and then *codegen*.

[ milone-lang code ]
|
| OK?
+--------→ [ error ]
[ IR ]
|
| codegen
[ C code ]

## Code Map

Projects:

- MiloneShared: Shared types and utils
- MiloneSyntax: Syntax analysis and type checking
- MiloneTransform: Code generation
- MiloneCli: CLI app
- MiloneLspServer: LSP server implementation (F#)
- lib: MiloneShared: Shared types, functions and utilities
- lib: MiloneSyntaxTypes: Types for MiloneSyntax
- lib: MiloneSyntax: Syntax analysis and semantic check
- lib: MiloneTranslationTypes: Types for MiloneTranslation
- lib: MiloneTranslation: Code generation actual logic
- lib: MiloneCliCore: CLI client implementation
- app: MiloneCli
- lib: MiloneLspServerCore: LSP server implementation (F#)
- app: MiloneLspServer

Diagram of project dependencies:

Shared
Shared
^
/ \
/ \
Syntax Transform
Syntax Translation
^ ^ ^
| \ /
| \ /
| Cli
LSP

Note that Transform is not depended by Syntax and LSP server.
That illustrates modification of Transform doesn't affect interface of the language.
Note that Translation isn't depended by Syntax and LSP server.
That illustrates modification of Translation doesn't affect the interface of language.

### Data structures
### Intermediate representations

- Abstract Syntax Tree (AST)
- AST is well-known. IR for syntax.
- Name resolution intermediate representation (NIR)
- Functional-style IR for semantic check. Symbols are strings.
- Typed intermediate representation (TIR)
- Functional-style IR. For checking.
- Functional-style IR for semantic check. Symbols are internal IDs.
- High-level intermediate representation (HIR)
- Functional-style IR. For transformation.
- Functional-style IR for transformation and codegen.
- Mid-level intermediate representation (MIR)
- For C code generation.
- Imperative-style IR.
- Imperative-style IR for C code generation.
- C intermediate representation (CIR)
- Similar to AST of C language.
- IR similar to AST of C language.

Diagram of data flow.

FileSystem (*.milone)
Files (*.fs, *.milone)
| tokenize & parse
v
AST
 ↓
NIR
↓ -- name resolution
TIR -- type check etc.
|
v
TIR -- type checking etc.
|
~ -- Syntax / Transform boundary
|
v
HIR -- closure conversion etc.
~ -- boundary
↓ -- lower
HIR
↓ -- closure conversion etc.
MIR
CIR
FileSystem (*.c)
Files (*.c)

### Language-Specific Files

- FSharpOnly and Program.fs are F# only part.

## Cross-Cutting Concerns

*WIP*

----

### Others
## Less Interesting Notes

- FSharpOnly and Program.fs is F# only part.
- MiloneOnly is milone-lang only part.
- Reason why app project and lib project are separated (e.g. MiloneCliCore and MiloneCli.):
- I expected separation should reduce the compilation time. Improvement isn't observed though.
Loading

0 comments on commit 5af4fcf

Please sign in to comment.