Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Logtalk language #1308

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Jupytext works with notebooks in any of the following languages:
- Java
- Javascript
- Julia
- Logtalk
- Lua
- Matlab
- OCaml
Expand Down
1 change: 1 addition & 0 deletions src/jupytext/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"comment_suffix": "*/",
},
".xsh": {"language": "xonsh", "comment": "#"},
".lgt": {"language": "logtalk", "comment": "%"},
".lua": {"language": "lua", "comment": "--"},
".go": {"language": "go", "comment": "//"},
}
Expand Down
110 changes: 110 additions & 0 deletions tests/data/notebooks/inputs/ipynb_logtalk/logtalk_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# An implementation of the Ackermann function"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "logtalk"
}
},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[1mtrue"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%load ack.lgt\n",
"\n",
":- object(ack).\n",
"\n",
":- info([\n",
"\tversion is 1:0:0,\n",
"\tauthor is 'Paulo Moura',\n",
"\tdate is 2008-3-31,\n",
"\tcomment is 'Ackermann function (general recursive function).'\n",
"]).\n",
"\n",
":- public(ack/3).\n",
":- mode(ack(+integer, +integer, -integer), one).\n",
":- info(ack/3, [\n",
"\tcomment is 'Ackermann function.',\n",
"\targnames is ['M', 'N', 'V']\n",
"]).\n",
"\n",
"ack(0, N, V) :-\n",
"\t!,\n",
"\tV is N + 1.\n",
"ack(M, 0, V) :-\n",
"\t!,\n",
"\tM2 is M - 1,\n",
"\tack(M2, 1, V).\n",
"ack(M, N, V) :-\n",
"\tM2 is M - 1,\n",
"\tN2 is N - 1,\n",
"\tack(M, N2, V2),\n",
"\tack(M2, V2, V).\n",
"\n",
":- end_object."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sample query"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "logtalk"
}
},
"outputs": [
{
"data": {
"text/plain": [
"\u001b[1mV = 11"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ack::ack(2, 4, V)."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Logtalk",
"language": "logtalk",
"name": "logtalk_kernel"
},
"language_info": {
"codemirror_mode": "logtalk",
"file_extension": ".lgt",
"mimetype": "text/x-logtalk",
"name": "Logtalk"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
50 changes: 50 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_Rmd/logtalk_notebook.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
jupyter:
kernelspec:
display_name: Logtalk
language: logtalk
name: logtalk_kernel
---

# An implementation of the Ackermann function

```{logtalk vscode={'languageId': 'logtalk'}}
%%load ack.lgt

:- object(ack).

:- info([
version is 1:0:0,
author is 'Paulo Moura',
date is 2008-3-31,
comment is 'Ackermann function (general recursive function).'
]).

:- public(ack/3).
:- mode(ack(+integer, +integer, -integer), one).
:- info(ack/3, [
comment is 'Ackermann function.',
argnames is ['M', 'N', 'V']
]).

ack(0, N, V) :-
!,
V is N + 1.
ack(M, 0, V) :-
!,
M2 is M - 1,
ack(M2, 1, V).
ack(M, N, V) :-
M2 is M - 1,
N2 is N - 1,
ack(M, N2, V2),
ack(M2, V2, V).

:- end_object.
```

## Sample query

```{logtalk vscode={'languageId': 'logtalk'}}
ack::ack(2, 4, V).
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
% ---
% jupyter:
% kernelspec:
% display_name: Logtalk
% language: logtalk
% name: logtalk_kernel
% ---

% %% [markdown]
% # An implementation of the Ackermann function

% %% vscode={"languageId": "logtalk"}
%%load ack.lgt

:- object(ack).

:- info([
version is 1:0:0,
author is 'Paulo Moura',
date is 2008-3-31,
comment is 'Ackermann function (general recursive function).'
]).

:- public(ack/3).
:- mode(ack(+integer, +integer, -integer), one).
:- info(ack/3, [
comment is 'Ackermann function.',
argnames is ['M', 'N', 'V']
]).

ack(0, N, V) :-
!,
V is N + 1.
ack(M, 0, V) :-
!,
M2 is M - 1,
ack(M2, 1, V).
ack(M, N, V) :-
M2 is M - 1,
N2 is N - 1,
ack(M, N2, V2),
ack(M2, V2, V).

:- end_object.

% %% [markdown]
% ## Sample query

% %% vscode={"languageId": "logtalk"}
ack::ack(2, 4, V).
50 changes: 50 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_md/logtalk_notebook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
jupyter:
kernelspec:
display_name: Logtalk
language: logtalk
name: logtalk_kernel
---

# An implementation of the Ackermann function

```logtalk vscode={"languageId": "logtalk"}
%%load ack.lgt

:- object(ack).

:- info([
version is 1:0:0,
author is 'Paulo Moura',
date is 2008-3-31,
comment is 'Ackermann function (general recursive function).'
]).

:- public(ack/3).
:- mode(ack(+integer, +integer, -integer), one).
:- info(ack/3, [
comment is 'Ackermann function.',
argnames is ['M', 'N', 'V']
]).

ack(0, N, V) :-
!,
V is N + 1.
ack(M, 0, V) :-
!,
M2 is M - 1,
ack(M2, 1, V).
ack(M, N, V) :-
M2 is M - 1,
N2 is N - 1,
ack(M, N2, V2),
ack(M2, V2, V).

:- end_object.
```

## Sample query

```logtalk vscode={"languageId": "logtalk"}
ack::ack(2, 4, V).
```
57 changes: 57 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_myst/logtalk_notebook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
kernelspec:
display_name: Logtalk
language: logtalk
name: logtalk_kernel
---

# An implementation of the Ackermann function

```{code-cell}
---
vscode:
languageId: logtalk
---
%%load ack.lgt

:- object(ack).

:- info([
version is 1:0:0,
author is 'Paulo Moura',
date is 2008-3-31,
comment is 'Ackermann function (general recursive function).'
]).

:- public(ack/3).
:- mode(ack(+integer, +integer, -integer), one).
:- info(ack/3, [
comment is 'Ackermann function.',
argnames is ['M', 'N', 'V']
]).

ack(0, N, V) :-
!,
V is N + 1.
ack(M, 0, V) :-
!,
M2 is M - 1,
ack(M2, 1, V).
ack(M, N, V) :-
M2 is M - 1,
N2 is N - 1,
ack(M, N2, V2),
ack(M2, V2, V).

:- end_object.
```

## Sample query

```{code-cell}
---
vscode:
languageId: logtalk
---
ack::ack(2, 4, V).
```
50 changes: 50 additions & 0 deletions tests/data/notebooks/outputs/ipynb_to_percent/logtalk_notebook.lgt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
% ---
% jupyter:
% kernelspec:
% display_name: Logtalk
% language: logtalk
% name: logtalk_kernel
% ---

% %% [markdown]
% # An implementation of the Ackermann function

% %% vscode={"languageId": "logtalk"}
% %%load ack.lgt

:- object(ack).

:- info([
version is 1:0:0,
author is 'Paulo Moura',
date is 2008-3-31,
comment is 'Ackermann function (general recursive function).'
]).

:- public(ack/3).
:- mode(ack(+integer, +integer, -integer), one).
:- info(ack/3, [
comment is 'Ackermann function.',
argnames is ['M', 'N', 'V']
]).

ack(0, N, V) :-
!,
V is N + 1.
ack(M, 0, V) :-
!,
M2 is M - 1,
ack(M2, 1, V).
ack(M, N, V) :-
M2 is M - 1,
N2 is N - 1,
ack(M, N2, V2),
ack(M2, V2, V).

:- end_object.

% %% [markdown]
% ## Sample query

% %% vscode={"languageId": "logtalk"}
ack::ack(2, 4, V).
Loading