Skip to content

Commit

Permalink
docs: add code snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhairs authored Jul 27, 2023
1 parent 0f04fd2 commit 62682e8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,25 @@ Production rules:
| "+" | "-" | "*" | "/" ;
ternary -> expression "?" expression ":" expression;
```

## Example code snippet
> For now the interpreter does not handle source files, so this is to be done in the REPL (line by line).
```js
let age = 15;
let is_adult = age >= 18;

if (is_adult){
print "You are an adult";
} else{
print "You cannot drink";
}

{
let age = age+3;
print age;
let message = age >= 18 ? "is an adult" : "cannot drink";
print message;
}
print age;
```
</samp>

0 comments on commit 62682e8

Please sign in to comment.