Did you know ... | Search Documentation: |
Packs (add-ons) for SWI-Prolog |
Title: | Prolog parser and serialiser written in Prolog |
---|---|
Rating: | Not rated. Create the first rating! |
Latest version: | 1.0.2 |
SHA1 sum: | f50c083213afce8e06bcadddcd8c00b433dfe1e6 |
Author: | Falco Nogatz <fnogatz@gmail.com> |
Maintainer: | Falco Nogatz <fnogatz@gmail.com> |
Packager: | Falco Nogatz <fnogatz@gmail.com> |
Home page: | https://github.com/fnogatz/plammar |
Download URL: | https://github.com/fnogatz/plammar/releases/*.zip |
Requires: | cli_table |
dcg4pt | |
tap |
No reviews. Create the first review!.
Version | SHA1 | #Downloads | URL |
---|---|---|---|
1.0.2 | e65d9a4f00dad04e16868cd71e3fa86a0b238897 | 4 | https://github.com/fnogatz/plammar.git |
f50c083213afce8e06bcadddcd8c00b433dfe1e6 | 2 | https://github.com/fnogatz/plammar.git | |
09d2b4d9f32adb23e4aaff0c739d0342040dd885 | 18 | https://github.com/fnogatz/plammar.git | |
1.0.0 | c62ed0a8c17c59fe81047546ea584cb364e77ed5 | 2 | https://github.com/fnogatz/plammar.git |
0.0.1 | 8184e8745b366dfee83bcf73a9da92b606d5ac1a | 1 | https://github.com/fnogatz/plammar.git |
A Prolog grammar written in Prolog, for parsing and serialising Prolog code.
First, you need SWI-Prolog. See there for installation instructions.
We make use of the following packages:
library(tap)
library(dcg4pt)
library(cli_table)
All can be installed by calling the following query in SWI-Prolog:
?- pack_install(tap), pack_install(dcg4pt), pack_install(cli_table).
To get the latest development version, clone it via git and link it to the package directory of SWI-Prolog:
git clone https://github.com/fnogatz/plammar.git ln -s $PWD/plammar $(swipl -q -g "absolute_file_name(pack(.),D,[file_type(directory)]), write(D), halt")
It is possible to create a pre-compiled file which increases the tool's performance significantly. The command line interface is compiled using swipl's -c
option:
swipl -g main -o cli.exe -c cli.pl
The `.exe` suffix is chosen for compatibility with Windows systems. You can also use `make cli` to generate the pre-compiled CLI.
First, load the package:
?- use_module(library(plammar)).
Examples:
?- prolog_tokens(string("a(1)."), Tokens). ?- prolog_parsetree(string("a(1)."), PT). ?- prolog_ast(string("a(1)."), AST).
All three predicates can also take an additional Options list. The first argument accepts several data formats, including string(_)
, file(_)
, stream(_)
, chars(_)
and tokens(_)
. The predicates can be used to parse and serialise Prolog source code.
For more examples, have a look at the `/test` directory.
plammar comes with a command line interface to parse given source code. You can directly execute it via
swipl -g main cli.pl -- [options] [<filename>]
Call with `--help` instead of the filenames to get more options. The CLI accepts a filename as the first argument. If called without this filename, the source is read from stdin.
After the pre-compilation step mentioned before, the created executable can be called via:
./cli.exe [options] [<filename>]
Pack contains 35 files holding a total of 289K bytes.