Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3fa9423

Browse files
committedOct 13, 2023
Worked on more documentation but somehow parent files got screwed up
1 parent f2c7a38 commit 3fa9423

20 files changed

+357
-67
lines changed
 

‎Cargo.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ members = [
1414
"tools/ide-plugins/raven-intellij-natives",
1515
"tools/ide-plugins/raven-language-server"
1616
]
17-
18-
exclude = [
19-
"crates/chalk"
20-
]
17+
resolver = "2"

‎LICENSE

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Permission is hereby granted, free of charge, to any
2+
person obtaining a copy of this software and associated
3+
documentation files (the "Software"), to deal in the
4+
Software without restriction, including without
5+
limitation the rights to use, copy, modify, merge,
6+
publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software
8+
is furnished to do so, subject to the following
9+
conditions:
10+
11+
The above copyright notice and this permission notice
12+
shall be included in all copies or substantial portions
13+
of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

‎README.md

+10-13
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@ Raven is an experimental language bringing modern features to every platform.
44

55
Raven's goal is to allow one codebase to run on every platform, without having to sacrifice speed or usability.
66

7-
Currently, Raven mainly targets desktop applications, but web, mobile, and JVM targets are planned.
7+
Currently, Raven targets desktop applications, but web, mobile, and JVM targets are planned.
88

9-
# !!! DO NOT DOWNLOAD RAVEN ANYWHERE WITH A SPACE IN THE PATH. EX: "C:/Program Files/Raven". IT WILL NOT WORK. I CANNOT FIX IT !!!
9+
# Installing
1010

11-
# Building
11+
For help on installing Raven, look at the [first chapter of the Raven book](docs/raven/1_installation.md)
1212

13-
Requires LLVM set with the environmental variable LLVM_SYS_130_PREFIX = (path to folder with bin)
13+
# Contributing
1414

15-
Please download LLVM from https://github.com/PLC-lang/llvm-package-windows/releases/tag/v13.0.0
15+
If your interested in contributing, look at [the current Raven projects](projects.md).
16+
More information can be found in the [building.md file](docs/building.md)
1617

17-
C++ is also required to be installed somewhere on your system, for Windows get it from https://visualstudio.microsoft.com/vs/community/
18+
Please read the [contributing guidelines](contributing.md) before contributing.
1819

19-
Nightly is required for building the compiler, you can set the project to nightly with ```rustup override set nightly```
20+
# Documentation
21+
For the documentation on the Raven language, look at the [Raven book in the raven folder](raven/raven.md)
2022

21-
# Running
22-
23-
Run this in the lib/test folder (or whatever Raven project in the repository you want to run)
24-
```cargo run --bin magpie```
25-
26-
That command will build and run Raven's CLI with the following options
23+
For crate-level, file-level, and function-level documentation over the Raven internals, look at the source itself in the language folder. You can also find a helpful document going over internals in [language/README.md](language/README.md)

‎docs/building.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# !!! DO NOT DOWNLOAD RAVEN ANYWHERE WITH A SPACE IN THE PATH. EX: "C:/Program Files/Raven". IT WILL NOT WORK. I CANNOT FIX IT !!!
2+
3+
This project requires the latest Rust download. Download it using Rustup from https://www.rust-lang.org/tools/install
4+
5+
# Building
6+
7+
Requires LLVM set with the environmental variable LLVM_SYS_130_PREFIX = (path to folder with bin)
8+
9+
Please download LLVM from https://github.com/PLC-lang/llvm-package-windows/releases/tag/v13.0.0
10+
11+
C++ is also required to be installed somewhere on your system, for Windows get it from https://visualstudio.microsoft.com/vs/community/.
12+
By default, Rustup should install this for you.
13+
14+
Nightly is required for building the compiler, you can set the project to nightly with ```rustup override set nightly```
15+
16+
# Running
17+
18+
Run this in the lib/test folder (or whatever Raven project in the repository you want to run)
19+
```cargo run --bin magpie```
20+
21+
That command will build and run Magpie in that folder, which will run the project there.
22+
23+
Magpie can also be passed individual files, for example you can run this from the root folder:
24+
```cargo run --bin magpie lib/test/src/main.rv```

‎docs/contributing.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributing Guidelines
2+
3+
# Licensing
4+
5+
This repository is under the MIT License. By contributing to this project, any contributions you make are also under the MIT License.
6+
The full license terms are in the LICENSE file. The license simply allows free copying, distribution, modification, publishing, sublicensing, merging, or selling your code.
7+
Basically, you have no right to prevent others from doing whatever they want with the code.
8+
However, the license also prevents you from taking any responsibility over how the code is used, and you are not liable for any damage cuased.
9+
10+
# Contributors
11+
12+
All contributors without direct write access must make contributions to their own forks and open a pull request for code review.
13+
14+
All contributions will automatically be checked by the CI. This will let you know if anything is broken, but you should test all code you write.
15+
16+
# Style
17+
18+
The repository follows the Rust style, with:
19+
- snake_case method, file, variable, and folder names
20+
- CamelCase structure names
21+
22+
When in doubt, follow the established code style found in the source.

‎docs/index.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Welcome to the Raven documentation!
2+
3+
This folder contains all the documentation over the Raven project and everything associated with Raven.
4+
5+
If your interested in contributing, look at [the current Raven projects](projects.md).
6+
7+
For the documentation on the Raven language, look at the [Raven book in the raven folder](raven/raven.md)
8+
9+
Please read the [contributing guidelines](contributing.md) before contributing.
10+
11+
For crate-level, file-level, and function-level documentation over the Raven internals, look at the source itself in the language folder. You can also find a helpful document going over internals in [language/README.md](../language/README.md)

‎docs/projects.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Core
2+
The core is the base compiler of Raven (written in Rust), most work is fixing issues with the language itself and adding new features.
3+
4+
This is in the language folder of the base repository
5+
6+
# Magpie
7+
Magpie is Raven's build tool, dependency manager, and version control. It is currently lacking most functionality.
8+
9+
This is in the tools/magpie folder of the base repository
10+
11+
# IDE Extensions / Raven Language Server
12+
This provides support to various IDEs such as VSCode and implementing features like syntax highlighting. It's a mix of Rust (Raven Language Server), NodeJS (VSCode), and Java (IntelliJ)
13+
14+
This is in the tools/ide-plugins folder of the base repository
15+
16+
# Website
17+
This is the main page for Raven.
18+
19+
The source is in the website folder of the base repository The website is on the gh-pages branch of the base repository
20+
21+
# Standard Library
22+
This is the standard library of Raven for every platform it supports. It's divided into a platform-specific std, and a universal std, which calls the platform std.
23+
24+
This is in the lib folder of the base repository

‎docs/raven/1_installation.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Installation
2+
3+
The best way to install Raven without building from source is through Magpie.
4+
5+
Raven comes with a helper program called "Magpie Wrapper" that will automatically keep the language up to date.
6+
7+
To install the latest Magpie or Magpie Wrapper, check out https://github.com/BigBadE/Raven-Language/releases/tag/nightly.
8+
9+
Follow the instructions on the release page to install the wrapper and run it.
10+
11+
# Running
12+
13+
Magpie can either run a project or a single file.
14+
15+
Running a project requires following the project format, a commented example can be found in the lib/test folder.
16+
17+
Running a single file just requires a .rv file with a main function. This file will provide examples you can run by copying them into a file
18+
and running it with Magpie.
19+
20+
An example of running a single file:
21+
```magpie my_file.rv```
22+
23+
This will run the file named my_file.rv.
24+
25+
To confirm your installation is working, try running the following Hello World! example:
26+
27+
```
28+
import stdio;
29+
30+
fn main() {
31+
printf("Hello World!");
32+
}
33+
```
34+
35+
For more information over how this example works, check out [Chapter 2: Getting Started](2_getting_started.md)

‎docs/raven/2_getting_started.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Getting Started - Types
2+
3+
Types are the backbone of Raven. Every single variable has a type, so types will be covered to help understand variables.
4+
5+
Raven comes with a few built in types, but it's most important to know the "primtives", basic types that all other types are built off of.
6+
They are the following:
7+
8+
- Unsigned Integers:
9+
Unsigned integers are an integer (whole number) with no sign (positive). There are 4 of them: ``u8``, ``u16``, ``u32``, and ``u64``.
10+
The u stands for unsigned, and the number after is the amount of bits the number has. To understand what the number of bits mean,
11+
it's worth reviewing binary. Keep in mind, if you try to go below 0, unsigned integers will underflow to the maximum number.
12+
Likewise, if you go over the maximum number, the number will overflow to 0.
13+
- Signed Integers:
14+
Signed integers have less range than unsigned integers, but they can be negative. There are also 4 of them: ``i8``, ``i16``, ``i32``, and ``i64``.
15+
The numbers mean the same thing, and i stands for signed.
16+
- Booleans:
17+
There is only one boolean type, ``bool``, which can be the value ``true`` or ``false``.
18+
- Floats:
19+
There are two float types, ``f32`` or ``f64``. Floats, unlike integers, can have decimals. Floats also have a gigantic range,
20+
but it's important to know the drawbacks of floats: Floats are imprecise. Because they're restricted to 32 or 64 bits, they can't
21+
represent every single number. Floats should never be directly compared because they may not precisely be the expected value.
22+
- Strings:
23+
Strings are unique because they can have a variables size. There is only one type, ``str``, but it can be one letter ("a")
24+
or a full sentence ("Hello World!", as seen earlier). That's why a ``str`` isn't mutable. Any operation you do on a ``str``
25+
actually creates a new type.
26+
27+
Now that you've learned the basics, lets move on to actually using those types:
28+
29+
# Variables
30+
31+
Variables are a way to store data for later use. Let's write simple code to square a number:
32+
33+
```
34+
fn main() {
35+
let squaring = 2;
36+
let squared = squaring * squaring;
37+
}
38+
```
39+
40+
In this example the line ``let squaring = 2;`` sets the variable ``squaring`` equal to the ``u64`` ``2``.
41+
We can use this variable later, for example when we do ```let squared = squaring * squaring;``` which takes the ```squaring```
42+
variable and squares it by multiplying it by itself, then assigning it to ``squared``.
43+
44+
So, reviewing what has been covered so far:
45+
- Every variable has a name and a type
46+
- Numbers are either unsigned, signed, or floats
47+
- Variables can be used like numbers with their name
48+
49+
Now, lets move onto something a little different. [Chapter 3: Control Flow](3_control_flow.md)

‎docs/raven/3_control_flow.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Control Flow
2+
3+
Control Flow is how we use different statements to control the flow of the program. What does that mean? Well, lets look at an example:
4+
What if we wanted to run some code only if a number is less than 5? Let's try it:
5+
```
6+
import stdio;
7+
8+
fn main() {
9+
let value = 7;
10+
if value < 5 {
11+
printf("Yep!");
12+
} else {
13+
printf("Nope!");
14+
}
15+
}
16+
```
17+
18+
Let's run the code with various values:
19+
```
20+
value | output
21+
------+-------
22+
7 | Nope!
23+
6 | Nope!
24+
5 | Nope!
25+
4 | Yep!
26+
```
27+
28+
So, if the value is less than 5, only the code in the ``if`` statement runs. If the value is greater than or equal to 5, than the code
29+
in the ``else`` statement runs. We can expand this with the ``else if`` statement:
30+
31+
```
32+
import stdio;
33+
34+
fn main() {
35+
let value = 7;
36+
if value < 5 {
37+
printf("Yep!");
38+
} else if value == 5 {
39+
printf("Five!");
40+
} else {
41+
printf("Nope!");
42+
}
43+
}
44+
```
45+
46+
47+
Let's run the code with the same values:
48+
```
49+
value | output
50+
------+-------
51+
7 | Nope!
52+
6 | Nope!
53+
5 | Five!
54+
4 | Yep!
55+
```
56+
57+
Following alone with the code, we can label each statement:
58+
(This code will NOT compile, it is purely for comprehension)
59+
60+
```
61+
import stdio;
62+
63+
fn main() {
64+
let value = 7;
65+
1: if value < 5 {
66+
printf("Yep!");
67+
2: } else if value == 5 {
68+
printf("Five!");
69+
3: } else {
70+
printf("Nope!");
71+
}
72+
}
73+
```
74+
75+
The logic is as follows:
76+
77+
1 is checked. IF value is less than 5, THEN Yep! is printed and nothing else happens.
78+
2 is checked IF 1 failed. IF value equals 5, THEN Five! is printed and nothing else happens.
79+
IF 1 and 2 failed, THEN Nope! is printed and nothing else happens.
80+
81+
If the logic doesn't make sense, feel free to mess around with the code on your own.
82+

‎docs/raven/raven.md

Whitespace-only changes.

‎language/checker/src/check_code.rs

+31-26
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,47 @@ use syntax::r#struct::VOID;
1515
use syntax::types::FinalizedTypes;
1616
use crate::output::TypesChecker;
1717

18-
pub async fn verify_code(process_manager: &TypesChecker, resolver: &Box<dyn NameResolver>, code: CodeBody, external: bool,
19-
syntax: &Arc<Mutex<Syntax>>, variables: &mut SimpleVariableManager, references: bool) -> Result<FinalizedCodeBody, ParsingError> {
18+
pub async fn verify_code(process_manager: &TypesChecker, resolver: &Box<dyn NameResolver>, code: CodeBody,
19+
syntax: &Arc<Mutex<Syntax>>, variables: &mut SimpleVariableManager, references: bool, top: bool) -> Result<FinalizedCodeBody, ParsingError> {
2020
let mut body = Vec::new();
21+
let mut found_end = false;
2122
for line in code.expressions {
23+
match &line.effect {
24+
Effects::CompareJump(_, _, _) => found_end = true,
25+
Effects::Jump(_) => found_end = true,
26+
_ => {}
27+
}
28+
2229
body.push(FinalizedExpression::new(line.expression_type,
2330
verify_effect(process_manager, resolver.boxed_clone(),
24-
line.effect, external, syntax, variables, references).await?));
31+
line.effect, syntax, variables, references).await?));
2532

2633
if let ExpressionType::Return = line.expression_type {
27-
if external {
28-
//Load if the function is external
29-
let effect = FinalizedEffects::ReferenceLoad(Box::new(body.pop().unwrap().effect));
30-
body.push(FinalizedExpression::new(ExpressionType::Return, effect));
31-
}
3234
return Ok(FinalizedCodeBody::new(body, code.label.clone(), true));
3335
}
3436
}
3537

38+
if !found_end && !top {
39+
panic!("Code body with label {} doesn't return or jump!", code.label)
40+
}
41+
3642
return Ok(FinalizedCodeBody::new(body, code.label.clone(), false));
3743
}
3844

3945
//IntelliJ seems to think the operation loop is unreachable for some reason.
4046
#[allow(unreachable_code)]
4147
#[async_recursion]
42-
async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameResolver>, effect: Effects, external: bool,
48+
async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameResolver>, effect: Effects,
4349
syntax: &Arc<Mutex<Syntax>>, variables: &mut SimpleVariableManager, references: bool) -> Result<FinalizedEffects, ParsingError> {
4450
let output = match effect {
45-
Effects::Paren(inner) => verify_effect(process_manager, resolver, *inner, external, syntax, variables, references).await?,
51+
Effects::Paren(inner) => verify_effect(process_manager, resolver, *inner, syntax, variables, references).await?,
4652
Effects::CodeBody(body) =>
47-
FinalizedEffects::CodeBody(verify_code(process_manager, &resolver, body, external,
48-
syntax, &mut variables.clone(), references).await?),
53+
FinalizedEffects::CodeBody(verify_code(process_manager, &resolver, body, syntax, &mut variables.clone(), references, false).await?),
4954
Effects::Set(first, second) => {
5055
FinalizedEffects::Set(Box::new(
51-
verify_effect(process_manager, resolver.boxed_clone(), *first, external, syntax, variables, references).await?),
56+
verify_effect(process_manager, resolver.boxed_clone(), *first, syntax, variables, references).await?),
5257
Box::new(
53-
verify_effect(process_manager, resolver, *second, external, syntax, variables, references).await?))
58+
verify_effect(process_manager, resolver, *second, syntax, variables, references).await?))
5459
}
5560
Effects::Operation(operation, mut values) => {
5661
let error = ParsingError::new(String::new(), (0, 0), 0,
@@ -110,25 +115,25 @@ async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameRes
110115
verify_effect(process_manager, resolver,
111116
Effects::ImplementationCall(calling, operation.name.clone(),
112117
String::new(), values, None),
113-
external, syntax, variables, references).await?
118+
syntax, variables, references).await?
114119
}
115120
Effects::ImplementationCall(calling, traits, method, effects, returning) => {
116121
let mut finalized_effects = Vec::new();
117122
for effect in effects {
118-
finalized_effects.push(verify_effect(process_manager, resolver.boxed_clone(), effect, external, syntax, variables, references).await?)
123+
finalized_effects.push(verify_effect(process_manager, resolver.boxed_clone(), effect, syntax, variables, references).await?)
119124
}
120125

121126
let return_type;
122127
if let Effects::NOP() = *calling {
123128
return_type = FinalizedTypes::Struct(VOID.clone());
124129
} else {
125-
let found = verify_effect(process_manager, resolver.boxed_clone(), *calling, external, syntax, variables, references).await?;
130+
let found = verify_effect(process_manager, resolver.boxed_clone(), *calling, syntax, variables, references).await?;
126131
return_type = found.get_return(variables).unwrap();
127132
finalized_effects.insert(0, found);
128133
}
129134

130135
if let Ok(inner) = Syntax::get_struct(syntax.clone(), placeholder_error(String::new()),
131-
traits, resolver.boxed_clone()).await {
136+
traits.clone(), resolver.boxed_clone()).await {
132137
let mut output = None;
133138
{
134139
let mut result = None;
@@ -172,17 +177,17 @@ async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameRes
172177
check_method(process_manager, method,
173178
finalized_effects, syntax, variables, returning).await?
174179
} else {
175-
panic!("Screwed up trait!");
180+
panic!("Screwed up trait! {}", traits);
176181
}
177182
}
178183
Effects::MethodCall(calling, method, effects, returning) => {
179184
let mut finalized_effects = Vec::new();
180185
for effect in effects {
181-
finalized_effects.push(verify_effect(process_manager, resolver.boxed_clone(), effect, external, syntax, variables, references).await?)
186+
finalized_effects.push(verify_effect(process_manager, resolver.boxed_clone(), effect, syntax, variables, references).await?)
182187
}
183188

184189
let method = if let Some(found) = calling {
185-
let found = verify_effect(process_manager, resolver.boxed_clone(), *found, external, syntax, variables, references).await?;
190+
let found = verify_effect(process_manager, resolver.boxed_clone(), *found, syntax, variables, references).await?;
186191
let return_type = found.get_return(variables).unwrap();
187192

188193
if is_modifier(return_type.inner_struct().data.modifiers, Modifier::Trait) {
@@ -238,7 +243,7 @@ async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameRes
238243
}
239244
Effects::CompareJump(effect, first, second) =>
240245
FinalizedEffects::CompareJump(Box::new(
241-
verify_effect(process_manager, resolver, *effect, external, syntax, variables, references).await?),
246+
verify_effect(process_manager, resolver, *effect, syntax, variables, references).await?),
242247
first, second),
243248
Effects::CreateStruct(target, effects) => {
244249
let mut target = Syntax::parse_type(syntax.clone(), placeholder_error(format!("Test")),
@@ -262,20 +267,20 @@ async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameRes
262267
return Err(placeholder_error(format!("Unknown field {}!", field_name)));
263268
}
264269

265-
final_effects.push((i, verify_effect(process_manager, resolver.boxed_clone(), effect, external, syntax, variables, references).await?));
270+
final_effects.push((i, verify_effect(process_manager, resolver.boxed_clone(), effect, syntax, variables, references).await?));
266271
}
267272

268273
FinalizedEffects::CreateStruct(Some(Box::new(FinalizedEffects::HeapAllocate(target.clone()))),
269274
target, final_effects)
270275
}
271276
Effects::Load(effect, target) => {
272-
let output = verify_effect(process_manager, resolver, *effect, external, syntax, variables, references).await?;
277+
let output = verify_effect(process_manager, resolver, *effect, syntax, variables, references).await?;
273278

274279
let types = output.get_return(variables).unwrap().inner_struct().clone();
275280
FinalizedEffects::Load(Box::new(output), target.clone(), types)
276281
}
277282
Effects::CreateVariable(name, effect) => {
278-
let effect = verify_effect(process_manager, resolver, *effect, external, syntax, variables, references).await?;
283+
let effect = verify_effect(process_manager, resolver, *effect, syntax, variables, references).await?;
279284
let found;
280285
if let Some(temp_found) = effect.get_return(variables) {
281286
found = temp_found;
@@ -297,7 +302,7 @@ async fn verify_effect(process_manager: &TypesChecker, resolver: Box<dyn NameRes
297302
let mut output = Vec::new();
298303
for effect in effects {
299304
output.push(verify_effect(process_manager, resolver.boxed_clone(), effect,
300-
external, syntax, variables, references).await?);
305+
syntax, variables, references).await?);
301306
}
302307

303308
let types = output.get(0).map(|found| found.get_return(variables).unwrap());

‎language/checker/src/check_function.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use no_deadlocks::Mutex;
44
#[cfg(not(debug_assertions))]
55
use std::sync::Mutex;
66
use syntax::function::{CodeBody, CodelessFinalizedFunction, FinalizedCodeBody, FinalizedFunction, UnfinalizedFunction};
7-
use syntax::{Attribute, SimpleVariableManager, is_modifier, Modifier, ParsingError};
7+
use syntax::{SimpleVariableManager, is_modifier, Modifier, ParsingError};
88
use syntax::async_util::NameResolver;
99
use syntax::code::{ExpressionType, FinalizedEffects, FinalizedExpression, FinalizedField, FinalizedMemberField};
1010
use syntax::syntax::Syntax;
@@ -67,12 +67,8 @@ pub async fn verify_function_code(process_manager: &TypesChecker, resolver: Box<
6767

6868
let mut variable_manager = SimpleVariableManager::for_function(&codeless);
6969

70-
let mut code = verify_code(process_manager, &resolver, code, codeless.data.attributes.iter()
71-
.any(|inner| if let Attribute::Basic(inner) = inner {
72-
inner == "extern"
73-
} else {
74-
false
75-
}), syntax, &mut variable_manager, include_refs).await?;
70+
let mut code = verify_code(process_manager, &resolver, code, syntax,
71+
&mut variable_manager, include_refs, true).await?;
7672

7773
if !code.returns {
7874
if codeless.return_type.is_none() {

‎language/parser/src/parser/operator_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn parse_operator(last: Option<Effects>, parser_utils: &mut ParserUtils, sta
1515

1616
parser_utils.index -= 1;
1717
while let Some(token) = parser_utils.tokens.get(parser_utils.index) {
18-
if token.token_type == TokenTypes::Operator || token.token_type == TokenTypes::Equals {
18+
if token.token_type == TokenTypes::Operator || token.token_type == TokenTypes::Equals || token.token_type == TokenTypes::Period {
1919
operation += token.to_string(parser_utils.buffer).as_str();
2020
} else {
2121
break

‎language/parser/src/parser/top_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub fn parse_top(parser_utils: &mut ParserUtils) {
7272
TokenTypes::EOF => return,
7373
_ => panic!("How'd you get here? {}: {:?} index {} ({:?})", parser_utils.file, token.token_type, parser_utils.index,
7474
parser_utils.tokens[parser_utils.index-6..parser_utils.index-1].iter()
75-
.map(|token| token.to_string(parser_utils.buffer)).collect::<Vec<_>>())
75+
.map(|token| format!("{} ({:?})", token.to_string(parser_utils.buffer), token.token_type)).collect::<Vec<_>>())
7676
}
7777
}
7878
}

‎language/syntax/src/async_util.rs

+8
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ impl<T: TopElement> Future for AsyncTypesGetter<T> {
9999
return Poll::Ready(output);
100100
}
101101

102+
// Check if a structure within the parent type with that name exists.
103+
let parent = self.name_resolver.parent().clone();
104+
if let Some(output) = self.get_types(&mut locked,
105+
parent, cx.waker().clone(), not_trait) {
106+
return Poll::Ready(output);
107+
}
108+
102109
// Check each import if the structure is in those files.
103110
for import in self.name_resolver.imports().clone() {
104111
if let Some(output) = self.get_types(&mut locked,
@@ -109,6 +116,7 @@ impl<T: TopElement> Future for AsyncTypesGetter<T> {
109116

110117
// If the async manager is finished, return an error.
111118
if locked.async_manager.finished {
119+
println!("Error {}", self.error);
112120
return Poll::Ready(Err(self.error.clone()));
113121
}
114122

‎language/syntax/src/function.rs

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ impl FinalizedFunction {
283283
}
284284

285285
/// A body of code, each body must have a label for jump effects to jump to.
286+
/// ! Each nested CodeBody MUST have a jump or return or else the compiler will error !
286287
#[derive(Clone, Default, Debug)]
287288
pub struct CodeBody {
288289
pub label: String,

‎language/syntax/src/types.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ use crate::syntax::Syntax;
2323
/// For example, "test" is a Struct called str, which is an internal type.
2424
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
2525
pub enum Types {
26-
//A basic struct
26+
// A basic struct
2727
Struct(Arc<StructData>),
28-
//A type with generic types
28+
// A type with generic types. For example, List<T> is GenericType with a base struct (List) and bounds T.
29+
// This List<T> will be degeneric'd into a type (for example, List<String>) then solidified.
2930
GenericType(Box<Types>, Vec<Types>),
30-
//A reference to a type
31+
// A reference to a type
3132
Reference(Box<Types>),
32-
//A generic with bounds
33+
// A generic with bounds
3334
Generic(String, Vec<Types>),
34-
//An array
35+
// An array
3536
Array(Box<Types>),
3637
}
3738

@@ -333,7 +334,7 @@ impl FinalizedTypes {
333334
/// Flattens GenericTypes into a Structure, degenericing them.
334335
#[async_recursion]
335336
pub async fn flatten(&mut self, generics: &mut Vec<FinalizedTypes>, syntax: &Arc<Mutex<Syntax>>) -> Result<FinalizedTypes, ParsingError> {
336-
// Flatten the arguments to this generic type.
337+
// Flatten the arguments to this GenericType.
337338
for generic in &mut *generics {
338339
if let FinalizedTypes::GenericType(base, bounds) = generic {
339340
*generic = base.flatten(bounds, syntax).await?;

‎lib/core/src/iter.rv

+18-5
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,26 @@ pub struct NumberIter {
1111

1212
impl Iter<u64> for NumberIter {
1313
pub fn next(self) -> u64 {
14-
//self.current = self.current + 1;
15-
//return self.current - 1;
16-
return 0;
14+
self.current = self.current + 1;
15+
return self.current - 1;
1716
}
1817

1918
pub fn has_next(self) -> bool {
20-
//return self.current != self.end;
21-
return false;
19+
return self.current != self.end;
20+
}
21+
}
22+
23+
#[priority(-1)]
24+
#[operation({}..{})]
25+
trait Range<T> {
26+
fn range(self, other: T) -> Iter<T>;
27+
}
28+
29+
impl Range<u64> for u64 {
30+
fn range(self, other: u64) -> Iter<T> {
31+
return new NumberIter {
32+
current: self,
33+
end: other,
34+
};
2235
}
2336
}

‎lib/test/src/main.rv

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import main::Test;
1+
import iter::NumberIter;
22
import stdio;
33

44
fn main() {
5-
let i = 0;
6-
while i != 5 {
5+
let iter = new NumberIter {
6+
current: 0,
7+
end: 5,
8+
};
9+
for i in iter {
710
printf("Loop!");
8-
i = i + 1;
911
}
1012
printf("Done!");
1113
}

0 commit comments

Comments
 (0)
Please sign in to comment.