An open API service indexing awesome lists of open source software.

https://github.com/mattiaz/funk

A custom programming language called Funk. This is a mirror of the Gitlab repo.
https://github.com/mattiaz/funk

interpreter lexer parser programming-language

Last synced: 6 months ago
JSON representation

A custom programming language called Funk. This is a mirror of the Gitlab repo.

Awesome Lists containing this project

README

          

# Funk Programming Language

## Introduction
Funk is a custom programming language with its own interpreter. It was developed as part of the TDP019 course at Linköping University. Funk aims to provide a clean, expressive syntax with functional programming capabilities.

## Features
- Custom syntax designed for clarity and expressiveness
- Functional programming paradigm
- Static typing system
- Built-in error handling
- Comprehensive logging system
- REPL for interactive programming

## Project Structure
```sh
funk/
├── .vscode/ # VSCode settings and configurations
├── bin/ # Binary files (generated by make)
│ ├── tests/ # Test executables
│ └── funk # Main Funk interpreter
├── build/ # Object files (generated by make)
├── docs/ # Documentation
│ ├── Language Specification/ # Typst documents for language specification
│ ├── Language Specification.pdf # Formal language specification
│ └── html/ # Generated Doxygen documentation (after generation)
├── examples/ # Example programs
├── include/ # Header files
│ ├── ast/ # Abstract syntax tree
│ ├── lexer/ # Lexical analysis components
│ ├── logging/ # Logging implementation
│ ├── parser/ # Syntax analysis components
│ ├── token/ # Token implementation
│ └── utils/ # Utility functions
├── source/ # Source code
│ ├── main.cc # Main entry point
│ └── ... # Same structure as include/
├── tests/ # Test files for each major feature
├── .clang-format # Clang format configuration
├── compile+test # Script to compile and run all tests
├── Doxyfile # Doxygen configuration file
├── funk.log # Log file (created during execution)
└── Makefile # Build system configuration
```

## Installation

### Prerequisites
- C++ compiler with `c++17` support or higher
- Make build system
- Standard C++ libraries
- `gtest` library for testing

### Building from Source
1. Clone the repository:

```sh
git clone https://gitlab.liu.se/mataj513/tdp019.git
cd tdp019
```

2. Build the interpreter:
```sh
make
```

3. For a clean build:
```sh
make clean
make
```

4. For testing:
```sh
make tests
```

## Usage
After building the Funk interpreter, you can use it in the following ways:

### Running Funk Programs
To execute a Funk program file:
```sh
./bin/funk [args]
```

See examples in the [examples](examples) directory.

Arguments can be passed to the program by adding them after the file path. Arguments before the file path are interpreted as arguments to the interpreter itself.

For more help and options see:
```sh
./bin/funk --help
```

### REPL

The interpreter also supports a REPL (Read-Eval-Print-Loop) mode, allowing you to interactively enter and execute Funk code.

```sh
./bin/funk
```

### Logging
The interpreter uses a logging system to provide detailed information about its execution.
The log file is located at `funk.log` but can be changed by adding `--log new/path.log` to the program.

## Testing
Funk comes with a comprehensive test suite to ensure functionality:

1. Run all tests (compiles and executes tests):
```sh
./compile+test
```

2. Compile tests only:
```sh
make tests
```

3. Run a specific test:
```sh
./bin/tests/
```

## Documentation

### Language Specification
See the [Language Specification](docs/Language%20Specification.pdf) for a formal description of the Funk language.

### Doxygen Documentation
To generate the detailed documentation, run the following command:
```sh
doxygen Doxyfile
```

The generated documentation will be available in the `docs/html` directory. Open the `index.html` file in a web browser
to view the documentation.