# Building

1. Have dotnet-sdk installed
2. Go to the directory where fskalc is located
3. Run `dotnet restore` to restore the `obj/` directory
4. Run `dotnet run` for debug run
5. `./release.sh` for release run, the binary will be found in bin/Release/net[version]/[platform]/publish/fskalc, and also will be copied to the active directory

# Reference

The following is an informal overview of FSKalc's capabilties.

## Expressions

### Number literal

Example:

```
8.5
```

### Variable read

Example:

```
a
```

Will print an error message if variable is undefined. The `ans` variable implicitly refers to the result of the last expression statement.

### Parentheses for precedence

Example:

```
(5+6)*7
```

Parentheses increase precedence.

### Function calls

Functions are called with !.

Example:

```
sin! pi/2
```

Multile arguments need to be separated with commas.

```
logx! 5, 3
```


### Arithmetic operators

The following operators are valid, in decreasing precedence:

- `^` power; right associative
- `-` unary negation; note that multiple negations next to eachother are invalid!
- factor precedence:
    - `*` multiplication; left associative
    - `/` division; left associative
    - `//` integer (flooring) division; left associative
    - `%` modulo; left associative
    - if no binary operator is found, multiplication is assumed
- term precedence:
    - `+` addition; left associative
    - `-` subtraction; left associative

## Statements

Statements are the top level construct. Every line in an FSKalc program has to be a statement.

### Expression statement

Any valid expression is also a valid statement. The result of expression statements is printed to the screen, and also assigned to the variable names `ans`.

### Variable assignments

Variable assignments have the following syntax:

```
identifier = expression
```

Where the identifier is a string of characters containing only letters and underscores. 

Existing variables or functions can be overwritten by new variables/functions.

### Function declaration

Function declaration has the following syntax, demonstrated by an example below.

```
double x = x * 2
```

Multiple parameters need to be declared with commas separating.

```
sum x, y = x + y
```

Warning! as there are no scopes in FSKalc, passing
arguments to functions will modify the global scope.

## Builtins

### Builtin Constants

- pi
- tau (pi * 2)
- e (euler's number)
- inf (infinity)
- nan (not a number)

### Builtin Functions

- sin, cos, tan - they take 1 argument, in radians
- arcsin, arccos, arctan - they take 1 argument, they return in radians
- sqrt - returns square root
- log - logarithm base of 10
- ln - natural logarithm
- exp - returns e to the power of the argument
- rtx - returns the xth root (1st argument: base, 2nd argument: val)
- logx - returns the base x log (1st argument: base, 2nd argument: val)

## Comments

Comments can be inside matching `(*`, `*)` parentheses.