descriptionInterpreter for the Daki logic programming language
homepage URLhttp://macro.win/dakilang.html
repository URLhttps://github.com/gonmf/dakilang.git
ownergonmf@sapo.pt
last changeSun, 16 Apr 2023 19:42:22 +0000 (16 20:42 +0100)
last refreshSat, 27 Apr 2024 08:14:37 +0000 (27 10:14 +0200)
content tags
add:
README.md

Daki language Ruby interpreter

Daki is a small computer programming language influenced by Prolog and Datalog. Read all about it.

For fast prototyping and iteration, this first interpreter is written in Ruby.

Installation

You will only require a not-too-old Ruby binary.

Instructions

The Daki interpreter can be used both in interactive and non-interactive mode. In non-interactive mode, the interpreter input, read from files, is also outputted so as to mimic what would appear on a terminal on interactive mode.

In non-interactive mode, the interpreter reads one or more text files in sequence, and interpretes each line fully before advancing. A line can change the global state, which consists of logical assertions.

To launch the interpreter in interactive mode, use the -i flag:

./dakilang -i

In non-interactive mode a syntax error will end the program, whereas nothing is stopped in interactive mode, so give it a go in interactive mode until you have a good grasp of the syntax.

To launch the interpreter in non-interactive mode, use -c with the file path to be executed:

./dakilang -c examples/example1.dl

You can mix the modes, you can start the interpreter by including - consulting - one or more files, and afterwards switching to interactive mode:

./dakilang -i -c examples/example1.dl -c examples/example2.dl

Switching to interactive mode is always performed only after every consulted file is interpreted, in order.

Options

The full list of command line options are:

OptionDescription
-h, --helpPrint out the program manual and exit
-v, --versionPrint out the program name and version, and exit
-c, --consultRead file with path F and interpret each line
-i, --interactiveActivate interactive mode after finishing consulting all files
-d, --debugActivate debug mode, which shows the output of the output of clause parsing and a trace of the query solver
-t, --timeChanges the default query timeout time; N is a floating point value in seconds
--disable-colorsDisable the use of colors in the interpreter's output

Tests

This interpreter has tests for the interpreter search algorithm itsef, and for the parser:

./test_interpreter.sh
./test_parser.sh

If you find a bug, or the interpreter crashes, please open an issue with the faulty instructions.

Debugging

To debug the interpreter itself, first make sure the Ruby gem pry is installed system-wide:

gem install pry

Then plant a binding.pry instruction where you need a breakpoint, and start the interpreter from inside the src/ folder:

cd src

ruby dakilang.rb -c ../program_to_debug.dl

Copyright (c) 2021 Gonçalo Mendes Ferreira

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

shortlog
2023-04-16 GonçaloDelete .travis.ymlmaster
2023-04-16 GonçaloUpdate README.md
2021-04-24 gonmfVersion 0.37
2021-04-24 gonmfChange syntax around line continuations and comments
2021-04-24 gonmfFix bug #5: line continuations with comments
2021-04-24 gonmfFix bug #4: parser error on inline array declarations
2021-04-13 gonmfUpdate README.md
2021-04-13 gonmfVersion 0.36
2021-04-13 gonmfFix bug in memoization
2021-04-13 gonmfUpdate README.md
2020-10-17 gonmfUse readline gem
2020-08-17 gonmfUpdate READMEv0.35
2020-08-08 GonçaloUpdate README.md
2020-07-26 gonmfVersion 0.35
2020-07-26 gonmfFix UTF-8 encoding issue
2020-07-25 gonmfVersion 0.34v0.34
...
tags
3 years ago v0.35
3 years ago v0.34
3 years ago v0.32
heads
12 months ago master