https://github.com/JCumin/Brachylog
A terse declarative logic programming language
https://github.com/JCumin/Brachylog
code-golf declarative golfing-language language logic-programming prolog swi-prolog
Last synced: 6 months ago
JSON representation
A terse declarative logic programming language
- Host: GitHub
- URL: https://github.com/JCumin/Brachylog
- Owner: JCumin
- License: mit
- Created: 2015-08-26T16:30:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-07-28T08:00:32.000Z (almost 5 years ago)
- Last Synced: 2024-08-05T20:32:48.514Z (10 months ago)
- Topics: code-golf, declarative, golfing-language, language, logic-programming, prolog, swi-prolog
- Language: Prolog
- Homepage:
- Size: 5.9 MB
- Stars: 118
- Watchers: 11
- Forks: 5
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# What is it?
Brachylog is a declarative logic programming language much like Prolog. Brachylog is designed to be much terser than Prolog, while retaining some readability.
Currently in development.
Brachylog uses [SWI-Prolog](http://www.swi-prolog.org/) as Prolog engine.
## How do I use this?
### Documentation
Check out [Brachylog's Wiki](https://github.com/JCumin/Brachylog/wiki) if you want to learn how to write programs in this language.
You may want to watch this [**short video introduction to Brachylog**](https://www.youtube.com/watch?v=XYVhZ-MFcUs).
### Try it online!
You can try out Brachylog on [Try it online!](https://tio.run/nexus/brachylog2), thanks to @DennisMitchell.
### Brachylog language bar
[You can find here](https://abrudz.github.io/lb/brachylog) the Brachylog language bar which gives you access to all symbols used in Brachylog on any webpage (by clicking on the symbols or by inputing shortcuts), thanks to @abrudz.
### The interpreter
Brachylog's interpreter is entirely written in Prolog. Therefore, installing [SWI-Prolog](http://www.swi-prolog.org/) (version 7 and up) is mandatory to use Brachylog (We do not guarantee that Brachylog's interpreter will be compatible with any other Prolog implementation).
To run Brachylog's interpreter, start SWI-Prolog's interpreter inside the `src` directory available in this repository, and consult the file `brachylog.pl` (`consult(brachylog).`). Alternatively, you can run the interpreter with:
$ swipl src/brachylog.pl
You can then run Brachylog programs using different predicates:
- `run_from_file(FileName, Input, Output)`: `FileName` is an atom (i.e. between single quotes `'`) representing the file containing your Brachylog code. For example: `run_from_file('code.brachylog',"Test Input",Z)`.
- `run_from_atom(Code, Input, Output)`: `Code` is an atom (i.e. between single quotes `'`) containing your Brachylog code. For example: `run_from_atom('∧"Hello, World!"w',_,_)`. Note that you will have to escape certain characters in `Code`.- `run(Input, Output)`: This will run a Brachylog program that has already been transpiled to Prolog using either of the two previous predicates. More precisely, this will query `brachylog_main/2` in the file `compiled_brachylog.pl`.
The first two predicates will transpile your Brachylog program into Prolog, subsequently generating a file called `compiled_brachylog.pl` in the same directory that contains `brachylog.pl`. The three run predicates will then consult it and query `brachylog_main/3`.
Note that the first two run predicates also exist with either no `Output` argument, or with no `Input` nor `Output` argument, if necessary. For example, `run_from_file('code.brachylog')` is equivalent to `run_from_file('code.brachylog', _, _)`.### Contributors
- Julien Cumin - [@JCumin](https://github.com/JCumin)
- Markus Triska - [@triska](https://github.com/triska)
- ais523
- [@UnrelatedString](https://github.com/UnrelatedString)