<commit_before>/* toychrdb 3.1 -- simple CHR interpreter/debugger based on the refined
                   operational semantics of CHRs
   Copright (C) 2004 <NAME>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TOYCHRDB INTERPRETER/DEBUGGER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DESCRIPTION:
%       This is a simple CHR interpreter which is, unlike Chameleon, based on
%       the refined operational semantics of CHRs.  It also supports a
%       primative trace debugger.
%
%       Unlike the original toychr, the interpreter implements all of the
%       refined operational semantics, including waking up constraints on
%       Solve.
%
% NOTES:
%       (1) Cannot use toychr and toychrdb at the same time.
%       (2) toychrdb, unlike toychr, only works with SWIProlog.
%       (3) If your program uses tell/1, then debugging won't work.
%
% USAGE:
%       chr_compile(+File),
%       -Result chr_is +Goal.
%
% Where `Goal' is your query, `File' is the source file containing the CHR
% program and `Result' is the result of the query.
%
% DEBUGGING:
%       chr_trace
%               Like Prolog's trace/0.
%
%       chr_notrace
%               Like Prolog's notrace/0.
%
%       chr_spy(C)
%               Sets a spy point on a constraint of form C being activated.
%
%       chr_nospy
%               Disables all spy points.
%
%       chr_no_spy(C)
%               TODO: not implemented!
%
% OPTIONS:
%       chr_option(optimization_level,+N)
%               Sets optimization level to integer N.  Higher numbers should
%               be faster (note "should").  (default: all optimizations on)
%
%               N = 0: -) all optimizations off.
%
%               N = 1: -) No history if rule is not a propagation rule.
%                      -) Wakeup only on builtin constraints that bind
%                         variables.
%
%               N = 2: -) Delete entries from history where an id is dead.
%                      -) Wakeup only the constraints affected by a binding.
%                      -) Drop will fire if active constraint is not in the
%                      store.
%
%       chr_option(show_(stack|store|history|id),(yes|no|toggle))
%               When tracing, show the execution stack, store, history or
%               current ID. (default: show store only)
%
%       chr_option(allow_deep_guards,(yes|no|toggle))
%               Allow CHR constraints in rule guards or if-conditions.
%               Operationally, a sub-derivation is spawned with the guard as
%               the goal.  The guard is deemed to succeed if the
%               sub-derivation terminates without failure. (default: off)
%
% TODO:
%       -) Fix the problems listed in `NOTES'
%       -) Implement matching better.
%
% DISCLAIMER:
%       Do not use toychrdb to judge my Prolog programming skills!
%       Thankyou!
%---------------------------------------------------------------------------%


:- op(1180, xfx, ==>).
:- op(1180, xfx, <=>).
:- op(1150, fx, constraints).
:- op(1150, fx, chr_constraint).
:- op(1150, fx, handler).
:- op(1150, fx, rules).
:- op(1105, xfy, '|').
:- op(1100, xfx, \).
:- op(1200, xfx, @).


:- object(toychrdb,
	implements(expanding)).

	:- info([
		version is 0:5:0,
		author is '<NAME>; adapted to Logtalk by <NAME>.',
		date is 2020-09-03,
		copyright is 'Copright 2004 <NAME>; Copyright 2019 <NAME>',
		license is 'GNU GPL 2.0 or later version',
		comment is 'Simple CHR interpreter/debugger based on the refined operational semantics of CHRs.'
	]).

	:- public([
		chr_is/2,
		chr_trace/0, chr_notrace/0, chr_spy/1, chr_nospy/0, chr_no_spy/1, chr_option/2<commit_msg>Avoid a operator creation permission error with the `toychr` port when the backend compiler already defines the `|` operator<commit_after>/* toychrdb 3.1 -- simple CHR interpreter/debugger based on the refined
                   operational semantics of CHRs
   Copright (C) 2004 <NAME>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TOYCHRDB INTERPRETER/DEBUGGER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DESCRIPTION:
%       This is a simple CHR interpreter which is, unlike Chameleon, based on
%       the refined operational semantics of CHRs.  It also supports a
%       primative trace debugger.
%
%       Unlike the original toychr, the interpreter implements all of the
%       refined operational semantics, including waking up constraints on
%       Solve.
%
% NOTES:
%       (1) Cannot use toychr and toychrdb at the same time.
%       (2) toychrdb, unlike toychr, only works with SWIProlog.
%       (3) If your program uses tell/1, then debugging won't work.
%
% USAGE:
%       chr_compile(+File),
%       -Result chr_is +Goal.
%
% Where `Goal' is your query, `File' is the source file containing the CHR
% program and `Result' is the result of the query.
%
% DEBUGGING:
%       chr_trace
%               Like Prolog's trace/0.
%
%       chr_notrace
%               Like Prolog's notrace/0.
%
%       chr_spy(C)
%               Sets a spy point on a constraint of form C being activated.
%
%       chr_nospy
%               Disables all spy points.
%
%       chr_no_spy(C)
%               TODO: not implemented!
%
% OPTIONS:
%       chr_option(optimization_level,+N)
%               Sets optimization level to integer N.  Higher numbers should
%               be faster (note "should").  (default: all optimizations on)
%
%               N = 0: -) all optimizations off.
%
%               N = 1: -) No history if rule is not a propagation rule.
%                      -) Wakeup only on builtin constraints that bind
%                         variables.
%
%               N = 2: -) Delete entries from history where an id is dead.
%                      -) Wakeup only the constraints affected by a binding.
%                      -) Drop will fire if active constraint is not in the
%                      store.
%
%       chr_option(show_(stack|store|history|id),(yes|no|toggle))
%               When tracing, show the execution stack, store, history or
%               current ID. (default: show store only)
%
%       chr_option(allow_deep_guards,(yes|no|toggle))
%               Allow CHR constraints in rule guards or if-conditions.
%               Operationally, a sub-derivation is spawned with the guard as
%               the goal.  The guard is deemed to succeed if the
%               sub-derivation terminates without failure. (default: off)
%
% TODO:
%       -) Fix the problems listed in `NOTES'
%       -) Implement matching better.
%
% DISCLAIMER:
%       Do not use toychrdb to judge my Prolog programming skills!
%       Thankyou!
%---------------------------------------------------------------------------%


:- op(1180, xfx, ==>).
:- op(1180, xfx, <=>).
:- op(1150, fx, constraints).
:- op(1150, fx, chr_constraint).
:- op(1150, fx, handler).
:- op(1150, fx, rules).
:- if(\+ current_op(_, _, '|')).
	:- op(1105, xfy, '|').
:- endif.
:- op(1100, xfx, \).
:- op(1200, xfx, @).


:- object(toychrdb,
	implements(expanding)).

	:- info([
		version is 0:5:0,
		author is '<NAME>; adapted to Logtalk by <NAME>.',
		date is 2020-09-03,
		copyright is 'Copright 2004 <NAME>; Copyright 2019 <NAME>',
		license is 'GNU GPL 2.0 or later version',
		comment is 'Simple CHR interpreter/debugger based on the refined operational semantics of CHRs.'
	]).

	:- public([
		chr_is/2,
		chr_trace/0, chr_notrace/0, chr_spy/1, chr_nospy/0, chr_no_spy/1, chr_option/2
{'fraction_non_alphanumeric': 0.14033905916694733, 'fraction_numerical': 0.02110699449870888, 'mean_word_length': 2.4261538461538463, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4707140', 'n_tokens_mistral': 2746, 'n_tokens_neox': 2489, 'n_words': 993}