Getting Started¶
Installation¶
Currently, SMOL is best installed from source.
SMOL needs a Java JDK (version 11 or later) to be installed. The smol source code can be checked out via:
git clone https://github.com/smolang/SemanticObjects.git
or by downloading and unpacking the zip archive from https://github.com/smolang/SemanticObjects/archive/refs/heads/master.zip.
After obtaining the source code, change into that directory and execute the command:
./gradlew assemble
After a successful build, the SMOL REPL can be started in that directory via:
java -jar build/libs/smol.jar
Editor Support¶
There is basic support for SMOL for the following editors:
-
Supports syntax highlighting. Source, installation instructions at https://github.com/smolang/SemanticObjects/tree/master/editor-support/atom
-
Adds support for syntax highlighting and for running a SMOL REPL inside Emacs. Source, installation instructions at https://github.com/smolang/SemanticObjects/tree/master/editor-support/emacs
-
Supports syntax highlighting. Source, installation instructions at https://github.com/smolang/smol-vs-code. Latest release at https://github.com/smolang/smol-vs-code/releases/latest.
Running a Simple SMOL Program¶
SMOL itself is started from the command line and is typically used via an interactive prompt (a.k.a. REPL).
Here is a SMOL program that prints the canonical message:
main
print("Hello world!");
end
To run this code, save it in a file hello-world.smol
, and run it from the
REPL:
MO> read hello-world.smol
MO> auto
"Hello world!"
MO>
Instead of separate read
and auto
commands, you can also use
reada
; see The SMOL interactive REPL for a full list of commands.
Here is a more involved example, involving classes and breakpoints:
class Hello(String message)
Unit say_hello()
print(this.message);
end
end
main
print("Creating class ...");
Hello hello = new Hello("Hello world!");
breakpoint;
hello.say_hello();
end
Since the program will stop execution at the breakpoint, the runtime state can be queried from the REPL:
MO> reada /Users/rudi/Source/tmp/hello-world.smol
"Creating class ..."
MO> query SELECT ?obj ?message WHERE { ?obj a prog:Hello. ?obj prog:Hello_message ?message. }
--------------------------------------------------------------------------------------
| obj | message |
======================================================================================
| <https://github.com/Edkamb/SemanticObjects/Run1660809137988#obj3> | "Hello world!" |
--------------------------------------------------------------------------------------
MO> auto
"Hello world!"
MO>
Runtime state is queried using the SPARQL query language, both from the REPL and in the program.
SMOL Command-Line Parameters¶
Options:
-e, -l, --execute, --load
-j, --jenaReasoner TEXT Set value of the internally used reasoner to
'off', 'rdfs', or 'owl' (default -> 'owl')
-s, --sparqlEndpoint TEXT url for SPARQL endpoint
-b, --back PATH path to a file containing OWL class definitions
as background knowledge.
-d, --domain TEXT prefix for domain:.
-i, --input PATH path to a .smol file which is loaded on startup.
-r, --replay PATH path to a file containing a series of REPL
commands.
-o, --outdir PATH path to a directory used to create data files.
-v, --verbose Verbose output.
-m, --materialize Materialize triples and dump to file.
-q, --useQueryType Activates the type checker for access
-p, --prefixes VALUE Extra prefixes, given as a list -p PREFIX1=URI1
-p PREFIX2=URI2
-h, --help Show this message and exit
The SMOL interactive REPL¶
SMOL programs are run and queried via the REPL. Currently, the REPL offers the following commands:
General Commands¶
Command |
Description |
Parameters |
---|---|---|
|
exits the REPL |
|
|
Sets verbose output to on or off |
enabled: |
|
Sets or prints the directory where SMOL write data files |
path: a directory name; if omitted, print the current value |
Commands for Running SMOL¶
Command |
Description |
Parameters |
---|---|---|
|
reads a SMOL file |
file: Path to the |
|
reads and runs the given file |
file: Path to the |
|
starts or continues execution of the currently-loaded smol file until the next breakpoint |
|
|
executes the next statement |
Commands for Querying SMOL¶
Command |
Description |
Parameters |
---|---|---|
|
evaluates a smol expression in the current program state |
expression: a smol expression |
|
executes a SPARQL query in the current program state |
query: The SPARQL query to execute |
|
Set which sources to include (true) or exclude (false) when querying |
|
|
Specify which Jena reasoner to use, or turn it off |
reasoner: |
|
List all members of a class |
class: class expression in Manchester Syntax, e.g., |
|
Plots data from the given output port of an FMO in the given interval. In order to use this command, gnuplot must be installed. |
|
|
Create file in |
file (optional): the file to create; default |
Diagnostic Commands¶
Command |
Description |
Parameters |
---|---|---|
|
Print all classes and check that the internal ontology is consistent |
|
|
Print static information in internal format |
|
|
Print state in internal format |
|
|
Enables/disables guard clauses when searching for triples in the heap or the static table. This command is mainly used for debugging and performance measuring. |
|
|
Enables/disables virtualization searching for triples in the heap or the static table. This command is mainly used for debugging and performance measuring. |
|