Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wandvvs authored Mar 11, 2024
1 parent 52e9f1f commit d0aa9fc
Showing 1 changed file with 21 additions and 50 deletions.
71 changes: 21 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

# Was done
- [x] Variables semantic
- [x] Let statement
- [x] Mut statement
- [x] Assign statement
- [x] Exit statement
- [x] Arithmetic operations with precedence
- [ ] Print statement
- [ ] Const variables
- [X] Wrint line statement
- [X] Const variables
- [ ] Data types
- [ ] If statement
- [ ] Loop statement
Expand All @@ -28,65 +28,36 @@ cmake ..
make
```
3. Test language
```bash
./dust-lang <input.dust>
```
## Grammar
```
program : statement_list
statement_list : statement
| statement_list statement
statement : let_statement
| assign_statement
| exit_statement
let_statement : LET IDENTIFIER '=' expression ';'
assign_statement : IDENTIFIER '=' expression ';'
exit_statement : EXIT '(' expression ')' ';'
Example:
```js
extern std;

expression : term
| expression '+' term
| expression '-' term
mut a = 5;
a = "Hello, world!";

term : factor
| term '*' factor
| term '/' factor
const b = "Dust";

factor : INT_LITERAL
| IDENTIFIER
| '(' expression ')'
```
mut c = "string";
c = b;

## Example
```js
let a = 5;
let b = (a+5)/2;
c = "Test";

b = b + 3;
writeln(c);
writeln(b);
writeln(2+2*2);

exit(b*2);
exit(0);
```

Let`s compile it and run
```bash
./dust-lang input.dust
./dust-lang <input.dust>
./out
echo $?
```

LLVM IR:
```llvm
define i64 @main() {
entrypoint:
ret i64 16
}
```

Output:
```
16
Test
string
6
1333 333 333
```

0 comments on commit d0aa9fc

Please sign in to comment.