https://github.com/abrams27/fibin-language
A simple functional language written using c++ templates
https://github.com/abrams27/fibin-language
cpp-templates interpreter language
Last synced: about 1 year ago
JSON representation
A simple functional language written using c++ templates
- Host: GitHub
- URL: https://github.com/abrams27/fibin-language
- Owner: abrams27
- License: mit
- Created: 2020-10-08T20:07:50.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-09-28T19:32:32.000Z (over 4 years ago)
- Last Synced: 2025-01-07T23:25:14.091Z (about 1 year ago)
- Topics: cpp-templates, interpreter, language
- Language: C++
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fibin language
A simple functional language written using c++ templates.
---
coauthor: [@Pawel494](https://github.com/Pawel494)
# Semantics
* Literals `Lit` - only allowed Fibbonaci numbers (non negative): `Fib<0> = 0, Fib<1> = 1 ...`
or logic values: `True, False`, \
example:
```
Lit>, Lit
```
* Variables `Var`:
```
Var(const char*)
```
labels are string (1 to 6 signs) with letters (case insensitive) and digits, \
example:
```
Var("A"), Var("01234"), Var("Cdefg")
```
* Arithmetic operations `Sum, Inc1, Inc10`
- `Sum<...>` - multiple arguments sum (at least two),
- `Inc1` - adds `Fib<1>` to `Arg`,
- `Inc10` - adds `Fib<10` to `Arg`,
example:
```
Sum>, Lit>, Lit>>, Inc1>>
```
* Comparison `Eq` -
`Eq` compares value of Left with Right, \
example:
```
Eq>, Lit>>
```
* Refernce `Ref` -
`Ref` return the value of `Var`, \
example:
```
Ref
```
* Expression `Let` -
`Let` assigns `Value` to the `Var` and calculates given `Expression`, \
example:
```
Let>, Ref>
```
* Expression `If` -
`If` if `Condition` result is True then calculates value of `Then` otherwise value of `Else` is calculated, \
example:
```
If, Lit>, Lit>>
```
* Expression `Lambda` -
`Lambda` reprezents anonymous function with singe input argument `Var` and body `Body`, \
example:
```
Lambda>
```
* Function invocation `Invoke` -
`Invoke` calculates `Fun` result for the given input parameter `Param`, \
example:
```
Invoke>, Lit>>
```