]> Repositorios git - scryer-prolog.git/commitdiff
transition to the operator precedence parser.
authorMark Thom <[email protected]>
Wed, 6 Sep 2017 06:36:14 +0000 (00:36 -0600)
committerMark Thom <[email protected]>
Wed, 6 Sep 2017 06:36:14 +0000 (00:36 -0600)
15 files changed:
.gitmodules [new file with mode: 0644]
Cargo.lock
Cargo.toml
README.md
build.rs [deleted file]
src/main.rs
src/prolog/ast.rs
src/prolog/builtins.rs
src/prolog/io.rs
src/prolog/iterators.rs
src/prolog/machine.rs
src/prolog/mod.rs
src/prolog/parser [new submodule]
src/prolog/prolog_parser.lalrpop [deleted file]
src/prolog/prolog_parser.rs [deleted file]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..ca057cc
--- /dev/null
@@ -0,0 +1,4 @@
+[submodule "src/prolog/parser"]
+       path = src/prolog/parser
+       url = http://github.com/mthom/prolog-parser
+       branch = rusty-wam_branch
index d1a41907899f29425053f44fb1e64a0074d8de15..3d7dbbb20add69c2cb2f8d17646f549aab55074c 100644 (file)
@@ -1,9 +1,10 @@
 [root]
 name = "rusty-wam"
-version = "0.6.7"
+version = "0.7.0"
 dependencies = [
- "lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "termion 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -17,169 +18,149 @@ dependencies = [
 ]
 
 [[package]]
-name = "ascii-canvas"
-version = "1.0.0"
+name = "bitflags"
+version = "0.7.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
-]
 
 [[package]]
-name = "atty"
-version = "0.1.2"
+name = "conv"
+version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "bit-set"
-version = "0.4.0"
+name = "custom_derive"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "kernel32-sys"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "bit-vec"
-version = "0.4.4"
+name = "lazy_static"
+version = "0.2.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "diff"
-version = "0.1.10"
+name = "libc"
+version = "0.2.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "docopt"
-version = "0.7.0"
+name = "magenta"
+version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "either"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "ena"
-version = "0.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "fixedbitset"
-version = "0.1.6"
+name = "magenta-sys"
+version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
 
 [[package]]
-name = "itertools"
-version = "0.5.10"
+name = "memchr"
+version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "kernel32-sys"
-version = "0.2.2"
+name = "num"
+version = "0.1.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-complex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-rational 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "lalrpop"
-version = "0.13.1"
+name = "num-bigint"
+version = "0.1.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-snap 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "lalrpop-intern"
-version = "0.13.1"
+name = "num-complex"
+version = "0.1.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+]
 
 [[package]]
-name = "lalrpop-snap"
-version = "0.13.1"
+name = "num-integer"
+version = "0.1.35"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "lalrpop-util"
-version = "0.13.1"
+name = "num-iter"
+version = "0.1.34"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+]
 
 [[package]]
-name = "lazy_static"
-version = "0.2.8"
+name = "num-rational"
+version = "0.1.39"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
+]
 
 [[package]]
-name = "libc"
-version = "0.2.24"
+name = "num-traits"
+version = "0.1.40"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "memchr"
-version = "1.0.1"
+name = "ordered-float"
+version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
-name = "ordermap"
-version = "0.2.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "petgraph"
-version = "0.4.5"
+name = "rand"
+version = "0.3.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "fixedbitset 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "ordermap 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -204,20 +185,6 @@ name = "rustc-serialize"
 version = "0.3.24"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
-[[package]]
-name = "strsim"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "term"
-version = "0.4.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
 [[package]]
 name = "termion"
 version = "1.4.0"
@@ -244,11 +211,6 @@ dependencies = [
  "unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
-[[package]]
-name = "unicode-xid"
-version = "0.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
 [[package]]
 name = "unreachable"
 version = "0.1.1"
@@ -279,35 +241,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [metadata]
 "checksum aho-corasick 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "500909c4f87a9e52355b26626d890833e9e1d53ac566db76c36faa984b889699"
-"checksum ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2"
-"checksum atty 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d0fd4c0631f06448cc45a6bbb3b710ebb7ff8ccb96a0800c994afe23a70d5df2"
-"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
-"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
-"checksum diff 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0a515461b6c8c08419850ced27bc29e86166dcdcde8fbe76f8b1f0589bb49472"
-"checksum docopt 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab32ea6e284d87987066f21a9e809a73c14720571ef34516f0890b3d355ccfd8"
-"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
-"checksum ena 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe5a5078ac8c506d3e4430763b1ba9b609b1286913e7d08e581d1c2de9b7e5"
-"checksum fixedbitset 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fcf4412e2d11115c5ed81c2fbdaba8028de0c92553497aa771fc5f4e0c5c8793"
-"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
+"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
+"checksum conv 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299"
+"checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9"
 "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum lalrpop 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8ebe5a5c90d5edeecb7f62f6ebec0a3d0f6faf4759a052708348cda99fd311a0"
-"checksum lalrpop-intern 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05410c1e4aff497bdea1ccb274ac35536fda0ee858600df36966502d4f7acbe3"
-"checksum lalrpop-snap 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f866ece35287f5223a1a022c5d86417c260cda2ca9c8a156af9959404ce5313"
-"checksum lalrpop-util 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c7743f235fc17f5f50f3b1e64a8690ee154f17f86bd68cbb78787c5b37907f7"
 "checksum lazy_static 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3b37545ab726dd833ec6420aaba8231c5b320814b9029ad585555d2a03e94fbf"
 "checksum libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)" = "38f5c2b18a287cf78b4097db62e20f43cace381dc76ae5c0a3073067f78b7ddc"
+"checksum magenta 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf0336886480e671965f794bc9b6fce88503563013d1bfb7a502c81fe3ac527"
+"checksum magenta-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40d014c7011ac470ae28e2f76a02bfea4a8480f73e701353b49ad7a8d75f4699"
 "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4"
-"checksum ordermap 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "c036a53e6bb62d7eee2edf7e087df56fd84c7bbae6a0bd93c2b9f54bddf62e03"
-"checksum petgraph 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "14c6ae5ccb73b438781abc93d35615019b1ad6e24b44116377fb819cfd7587de"
+"checksum num 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "a311b77ebdc5dd4cf6449d81e4135d9f0e3b153839ac90e648a8ef538f923525"
+"checksum num-bigint 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "8fd0f8dbb4c0960998958a796281d88c16fbe68d87b1baa6f31e2979e81fd0bd"
+"checksum num-complex 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "503e668405c5492d67cf662a81e05be40efe2e6bcf10f7794a07bd9865e704e6"
+"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
+"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
+"checksum num-rational 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "288629c76fac4b33556f4b7ab57ba21ae202da65ba8b77466e6d598e31990790"
+"checksum num-traits 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "99843c856d68d8b4313b03a17e33c4bb42ae8f6610ea81b28abe076ac721b9b0"
+"checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
+"checksum rand 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "eb250fd207a4729c976794d03db689c9be1d634ab5a1c9da9492a13d8fecbcdf"
 "checksum regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1731164734096285ec2a5ec7fea5248ae2f5485b3feeb0115af4fda2183b2d1b"
 "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
 "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
-"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
-"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
 "checksum termion 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9105678ba52491a8e38e67be7842435ac44d7797b9b05bcdad370b0c84559615"
 "checksum thread-id 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8df7875b676fddfadffd96deea3b1124e5ede707d4884248931077518cf1f773"
 "checksum thread_local 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c85048c6260d17cf486ceae3282d9fb6b90be220bf5b28c400f5485ffc29f0c7"
-"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
 "checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
 "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
 "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
index 186ab5475cdd580d2f54f2cfd6ecf83de7432ee4..de3f9c1339a113929a226b5a5cf46b98b932f842 100644 (file)
@@ -1,18 +1,13 @@
 [package]
 name = "rusty-wam"
-version = "0.6.7"
+version = "0.7.0"
 authors = ["Mark Thom"]
 
-build = "build.rs"
-
 [dependencies]
+lazy_static = "0.2"
+num = "0.1"
 regex = "0.2.1"
+ordered-float = "0.5.0"
 
 [dependencies.termion]
-version = "1.4.0"
-
-[dependencies.lalrpop-util]
-version = "0.13.1"
-
-[build-dependencies.lalrpop]
-version = "0.13.1"
\ No newline at end of file
+version = "1.4.0"
\ No newline at end of file
index 952b51d840e01861457d2eefac7dace1cbd1882c..f4977fa4e85af76e4a427cf54be845ff9c1d0047 100644 (file)
--- a/README.md
+++ b/README.md
@@ -17,8 +17,8 @@ Extend rusty-wam to include the following, among other features:
 
 * call/N as a built-in meta-predicate (_done_).
 * ISO Prolog compliant throw/catch (_done_).
-* Built-in and user-defined operators of all fixities,
-  with custom associativity and precedence.
+* Built-in and user-defined operators of all fixities, with custom
+  associativity and precedence (_in progress_). 
 * Bignum and floating point arithmetic.
 * Built-in control operators (`,`, `;`, `->`, etc.).
 * Attributed variables using the SICStus Prolog interface and
diff --git a/build.rs b/build.rs
deleted file mode 100644 (file)
index 23c7d3f..0000000
--- a/build.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-extern crate lalrpop;
-
-fn main() {
-    lalrpop::process_root().unwrap();
-}
index aea87ddb4509b4dbec778f3b7d5244dde29701c3..88391731f2535920f0327817b20f5de2a16f0a1d 100644 (file)
@@ -1,8 +1,10 @@
+#[macro_use] extern crate lazy_static;
 extern crate termion;
 mod prolog;
 
 use prolog::io::*;
 use prolog::machine::*;
+use prolog::parser::toplevel::*;
 
 #[cfg(test)]
 mod tests {
@@ -12,8 +14,8 @@ mod tests {
     fn submit(wam: &mut Machine, buffer: &str) -> bool {
         wam.reset();
 
-        match parse_code(buffer.trim()) {
-            Some(tl) =>
+        match parse_code(buffer.trim(), wam.op_dir()) {
+            Ok(tl) =>
                 match eval(wam, &tl) {
                     EvalSession::InitialQuerySuccess(_, _) |
                     EvalSession::EntrySuccess |
@@ -21,7 +23,7 @@ mod tests {
                         true,
                     _ => false
                 },
-            None => panic!("Grammatical error of some kind!")
+            Err(e) => panic!("parse error: {:?}", e)
         }
     }
 
@@ -716,7 +718,7 @@ mod tests {
         assert_eq!(submit(&mut wam, "?- catch(f(x), _, _)."), true);
         assert_eq!(submit(&mut wam, "?- catch(f(y), _, _)."), true);
         assert_eq!(submit(&mut wam, "?- catch(f(z), _, _)."), true);
-        
+
         submit(&mut wam, "f(success). f(E) :- catch(g(E), E, handle(E)).");
         submit(&mut wam, "g(g_success). g(g_success_2). g(X) :- throw(X).");
         submit(&mut wam, "handle(x). handle(y). handle(z). handle(v) :- throw(X).");
@@ -736,12 +738,12 @@ mod tests {
 
 fn process_buffer(wam: &mut Machine, buffer: &str)
 {
-    match parse_code(buffer.trim()) {
-        Some(tl) => {
+    match parse_code(buffer, wam.op_dir()) {
+        Ok(tl) => {
             let result = eval(wam, &tl);
             print(wam, result);
         },
-        None => println!("Grammatical error!")
+        Err(s) => println!("{:?}", s)
     };
 }
 
@@ -760,7 +762,7 @@ fn prolog_repl() {
             continue;
         }
 
-        process_buffer(&mut wam, buffer.trim());
+        process_buffer(&mut wam, buffer.as_str());
         wam.reset();
     }
 }
index 91f4ef38ee380b5e87112d5c2e0ecb22a68c407b..7a8bdbe4aa534041775ee39bd855bb55990acc38 100644 (file)
@@ -1,13 +1,22 @@
+use prolog::num::bigint::BigInt;
+
+use prolog::ordered_float::*;
+
 use std::cell::Cell;
 use std::cmp::Ordering;
 use std::collections::{HashMap, VecDeque};
-use std::iter::*;
+use std::fmt;
+use std::io::Error as IOError;
+use std::num::{ParseFloatError};
 use std::ops::{Add, AddAssign};
+use std::str::Utf8Error;
 use std::vec::Vec;
 
+pub type Atom = String;
+
 pub type Var = String;
 
-pub type Atom = String;
+pub const LEXER_BUF_SIZE: usize = 4096;
 
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
 pub enum GenContext {
@@ -58,38 +67,6 @@ pub enum TopLevel {
     Rule(Rule)
 }
 
-impl TopLevel {
-    pub fn query_iter_mut<'a>(&'a mut self) -> Box<Iterator<Item=&'a mut QueryTerm> + 'a>
-    {
-        let mut iter: Box<Iterator<Item=&'a mut QueryTerm> + 'a> = Box::new(empty());
-
-        match self {
-            &mut TopLevel::Rule(Rule { head: (_, ref mut head), ref mut clauses }) => {
-                iter = Box::new(once(head));
-                iter = Box::new(iter.chain(clauses.iter_mut()));
-            },
-            &mut TopLevel::Query(ref mut clauses) =>
-                iter = Box::new(iter.chain(clauses.iter_mut())),
-            &mut TopLevel::Predicate(ref mut pred_clauses) =>
-                for pred_clause in pred_clauses.iter_mut() {
-                    match pred_clause {
-                        &mut PredicateClause::Rule(Rule { head: (_, ref mut head),
-                                                          ref mut clauses })
-                            =>
-                        {
-                            iter = Box::new(iter.chain(once(head)));
-                            iter = Box::new(iter.chain(clauses.iter_mut()));
-                        },
-                        _ => {}
-                    }
-                },
-            _ => {}
-        }
-
-        iter
-    }
-}
-
 #[derive(Clone, Copy)]
 pub enum Level {
     Deep, Shallow
@@ -142,13 +119,142 @@ impl Default for VarReg {
     }
 }
 
-#[derive(Clone, Hash, PartialEq, Eq)]
+pub type Specifier = u32;
+
+pub const XFX: u32 = 0x0001;
+pub const XFY: u32 = 0x0002;
+pub const YFX: u32 = 0x0004;
+pub const XF: u32  = 0x0010;
+pub const YF: u32  = 0x0020;
+pub const FX: u32  = 0x0040;
+pub const FY: u32  = 0x0080;
+pub const DELIMITER: u32 = 0x0100;
+pub const TERM: u32  = 0x1000;
+pub const LTERM: u32 = 0x3000;
+
+macro_rules! is_term {
+    ($x:expr) => ( ($x & TERM) != 0 )
+}
+
+macro_rules! is_lterm {
+    ($x:expr) => ( ($x & LTERM) != 0 )
+}
+
+macro_rules! is_op {
+    ($x:expr) => ( $x & (XF | YF | FX | FY | XFX | XFY | YFX) != 0 )
+}
+
+macro_rules! is_infix {
+    ($x:expr) => ( ($x & (XFX | XFY | YFX)) != 0 )
+}
+
+macro_rules! is_xfx {
+    ($x:expr) => ( ($x & XFX) != 0 )
+}
+
+macro_rules! is_xfy {
+    ($x:expr) => ( ($x & XFY) != 0 )
+}
+
+macro_rules! is_yfx {
+    ($x:expr) => ( ($x & YFX) != 0 )
+}
+
+macro_rules! is_yf {
+    ($x:expr) => ( ($x & YF) != 0 )
+}
+
+macro_rules! is_xf {
+    ($x:expr) => ( ($x & XF) != 0 )
+}
+
+macro_rules! is_fx {
+    ($x:expr) => ( ($x & FX) != 0 )
+}
+
+macro_rules! is_fy {
+    ($x:expr) => ( ($x & FY) != 0 )
+}
+
+macro_rules! prefix {
+    ($x:expr) => ($x & (FX | FY))
+}
+
+/* 'TokenTooLong' is hard to detect reliably if we don't process the
+input one character at a time. It would be easy to detect if the regex
+library supported matching on iterator inputs, but it currently does
+not. This is fine, mostly; the typical Prolog program will not contain
+tokens exceeding 4096 chars in length. */
+
+#[derive(Debug)]
+pub enum ParserError
+{
+    CommaArityMismatch,
+    UnexpectedEOF,
+    FailedMatch(String),
+    IO(IOError),
+    InadmissibleFact,
+    InadmissibleQueryTerm,
+    IncompleteReduction,
+    InconsistentPredicate,
+    ParseBigInt,
+    ParseFloat(ParseFloatError),
+    // TokenTooLong,
+    Utf8Conversion(Utf8Error)
+}
+
+impl From<IOError> for ParserError {
+    fn from(err: IOError) -> ParserError {
+        ParserError::IO(err)
+    }
+}
+
+impl From<Utf8Error> for ParserError {
+    fn from(err: Utf8Error) -> ParserError {
+        ParserError::Utf8Conversion(err)
+    }
+}
+
+impl From<ParseFloatError> for ParserError {
+    fn from(err: ParseFloatError) -> ParserError {
+        ParserError::ParseFloat(err)
+    }
+}
+
+#[derive(Clone, Copy, Eq, Hash, PartialEq)]
+pub enum Fixity {
+    In, Post, Pre
+}
+
+#[derive(Clone, Eq, Hash, PartialEq)]
 pub enum Constant {
     Atom(Atom),
-    BlockNum(usize),
+    Float(OrderedFloat<f64>),
+    Integer(BigInt),
+    String(String),
+    Usize(usize),
     EmptyList
 }
 
+impl fmt::Display for Constant {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self {
+            &Constant::Atom(ref atom) =>
+                write!(f, "{}", atom),
+            &Constant::EmptyList =>
+                write!(f, "[]"),
+            &Constant::Float(fl) =>
+                write!(f, "{}", fl),
+            &Constant::Integer(ref i) =>
+                write!(f, "{}", i),
+            &Constant::String(ref s) =>
+                write!(f, "{}", s),
+            &Constant::Usize(integer) =>
+                write!(f, "u{}", integer)
+        }
+    }
+}
+
 pub enum Term {
     AnonVar,
     Clause(Cell<RegType>, Atom, Vec<Box<Term>>),
@@ -193,7 +299,7 @@ pub enum ClauseType<'a> {
     Catch,
     Deep(Level, &'a Cell<RegType>, &'a Atom),
     Root,
-    Throw
+    Throw,
 }
 
 impl<'a> ClauseType<'a> {
@@ -201,7 +307,7 @@ impl<'a> ClauseType<'a> {
         match self {
             ClauseType::CallN | ClauseType::Catch | ClauseType::Throw => Level::Shallow,
             ClauseType::Deep(_, _, _) => Level::Deep,
-            ClauseType::Root => Level::Shallow
+            ClauseType::Root => Level::Shallow,
         }
     }
 }
@@ -302,8 +408,8 @@ pub enum BuiltInInstruction {
     IsAtomic,
     IsVar,
     ResetBlock,
-    SetBall, 
-    Unify, 
+    SetBall,
+    Unify,
     UnwindStack
 }
 
@@ -568,7 +674,7 @@ impl Term {
             _ => None
         }
     }
-    
+
     pub fn arity(&self) -> usize {
         match self {
             &Term::Clause(_, _, ref child_terms) => child_terms.len(),
index 636bf3e38061ff82bd2ae0c4e8fd7c32d4fa8d1f..8814f048aada9031a995e7660d3e5d4a27c6a27d 100644 (file)
@@ -10,9 +10,13 @@ pub enum PredicateKeyType {
     User
 }
 
+pub type OpDirKey = (Atom, Fixity);
+// name and fixity -> operator type and precedence.
+pub type OpDir = HashMap<OpDirKey, (Specifier, usize)>;
+
 pub type CodeDir = HashMap<PredicateKey, (PredicateKeyType, usize)>;
-     
-fn get_builtins() -> Code {    
+
+fn get_builtins() -> Code {
     vec![internal_call_n!(), // callN/N, 0.
          is_atomic!(), // atomic/1, 1.
          proceed!(),
@@ -78,7 +82,7 @@ fn get_builtins() -> Code {
          reset_block!(),
          proceed!(),
          trust_me!(), // 53.
-         allocate!(0),   
+         allocate!(0),
          query![get_var_in_query!(temp_v!(3), 1),
                 put_value!(temp_v!(2), 1)],
          reset_block!(),
@@ -86,7 +90,7 @@ fn get_builtins() -> Code {
          goto!(61, 0),
          set_ball!(), // throw/1, 59.
          unwind_stack!(),
-         fail!(), // false/0, 61.         
+         fail!(), // false/0, 61.
          try_me_else!(7), // not/1, 62.
          allocate!(1),
          get_level!(),
@@ -100,10 +104,16 @@ fn get_builtins() -> Code {
          proceed!()]
 }
 
-pub fn build_code_dir() -> (Code, CodeDir) {
+pub fn build_code_dir() -> (Code, CodeDir, OpDir)
+{
     let mut code_dir = HashMap::new();
+    let mut op_dir   = HashMap::new();
+
     let builtin_code = get_builtins();
-    
+
+    op_dir.insert((String::from(":-"), Fixity::In),  (XFX, 1200));
+    op_dir.insert((String::from("?-"), Fixity::Pre), (FX, 1200));
+
     // there are 63 registers in the VM, so call/N is defined for all 0 <= N <= 62
     // (an extra register is needed for the predicate name)
     for arity in 0 .. 63 {
@@ -118,5 +128,5 @@ pub fn build_code_dir() -> (Code, CodeDir) {
     code_dir.insert((String::from("catch"), 3), (PredicateKeyType::BuiltIn, 5));
     code_dir.insert((String::from("throw"), 1), (PredicateKeyType::BuiltIn, 59));
 
-    (builtin_code, code_dir)
+    (builtin_code, code_dir, op_dir)
 }
index 5af2a61b91aec2060d1819095d9eae129944ac29..df6f73f6d9329056c5e05f496d19af1958e084f5 100644 (file)
@@ -2,7 +2,6 @@ use prolog::ast::*;
 use prolog::codegen::*;
 use prolog::debray_allocator::*;
 use prolog::machine::*;
-use prolog::prolog_parser::*;
 
 use termion::raw::IntoRawMode;
 use termion::input::TermRead;
@@ -10,20 +9,6 @@ use termion::event::Key;
 
 use std::io::{Write, stdin, stdout};
 use std::fmt;
-use std::mem::swap;
-
-impl fmt::Display for Constant {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self {
-            &Constant::Atom(ref atom) =>
-                write!(f, "{}", atom),
-            &Constant::EmptyList =>
-                write!(f, "[]"),
-            &Constant::BlockNum(integer) =>
-                write!(f, "u{}", integer)
-        }
-    }
-}
 
 impl fmt::Display for FactInstruction {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -209,110 +194,6 @@ impl fmt::Display for RegType {
     }
 }
 
-/*
-// Wait until constexprs are supported in stable before trying to
-// switch to this.
-
-struct ClauseRewriter { field: fn(&mut Vec<Box<Term>>) -> QueryTerm }
-
-impl Clone for ClauseRewriter {
-    fn clone(&self) -> Self {
-        ClauseRewriter { field: self.field }
-    }
-}
-
-struct ClauseRewriters {
-    rewriter_map: HashMap<&'static str, ClauseRewriter>
-}
-
-impl ClauseRewriters {
-    fn new() -> Self {
-        let mut rewriter_map =
-            [("call", ClauseRewriter { field: rewrite_call_N })]//,
-        //("catch", rewrite_catch),
-        //("throw", rewrite_throw)]
-            .iter().cloned().collect();
-
-        ClauseRewriters { rewriter_map: rewriter_map }
-    }
-
-    fn get(&self, name: &str) -> Option<&ClauseRewriter> {
-        self.rewriter_map.get(name)
-    }
-}
-*/
-
-fn rewrite_call_n(terms: &mut Vec<Box<Term>>) -> QueryTerm {
-    let mut new_terms = Vec::with_capacity(0);
-    swap(&mut new_terms, terms);
-
-    QueryTerm::CallN(new_terms)
-}
-
-fn rewrite_catch(terms: &mut Vec<Box<Term>>) -> QueryTerm {
-    let mut new_terms = Vec::with_capacity(0);
-    swap(&mut new_terms, terms);
-
-    QueryTerm::Catch(new_terms)
-}
-
-fn rewrite_throw(terms: &mut Vec<Box<Term>>) -> QueryTerm {
-    let mut new_terms = Vec::with_capacity(0);
-    swap(&mut new_terms, terms);
-
-    QueryTerm::Throw(new_terms)
-}
-
-fn rewrite_clause(name: &Atom, terms: &mut Vec<Box<Term>>) -> Option<QueryTerm>
-{
-    if name == "call" {
-        Some(rewrite_call_n(terms))
-    } else if name == "catch" && terms.len() == 3 {
-        Some(rewrite_catch(terms))
-    } else if name == "throw" && terms.len() == 1 {
-        Some(rewrite_throw(terms))
-    } else {
-        None
-    }
-}
-
-pub fn parse_code(input: &str) -> Option<TopLevel>
-{
-    match parse_TopLevel(input) {
-        Ok(mut tl) => {
-            for query in tl.query_iter_mut() {
-                let new_query = match query {
-                    &mut QueryTerm::Term(Term::Clause(_, ref name, ref mut cts)) =>
-                        rewrite_clause(name, cts),
-                    &mut QueryTerm::Term(Term::Var(_, _)) =>
-                        Some(QueryTerm::CallN(Vec::new())),
-                    _ => None
-                };
-
-                if let Some(mut new_query) = new_query {
-                    swap(&mut new_query, query);
-                }
-            }
-
-            Some(tl)
-        },
-        Err(_) => None
-    }
-}
-
-fn is_consistent(predicate: &Vec<PredicateClause>) -> bool {
-    let name  = predicate.first().unwrap().name();
-    let arity = predicate.first().unwrap().arity();
-
-    for clause in predicate.iter().skip(1) {
-        if !(name == clause.name() && arity == clause.arity()) {
-            return false;
-        }
-    }
-
-    true
-}
-
 #[allow(dead_code)]
 pub fn print_code(code: &Code) {
     for clause in code {
@@ -371,16 +252,9 @@ pub fn eval<'a, 'b: 'a>(wam: &'a mut Machine, tl: &'b TopLevel) -> EvalSession<'
     match tl {
         &TopLevel::Predicate(ref clauses) => {
             let mut cg = CodeGenerator::<DebrayAllocator>::new();
-
-            if is_consistent(clauses) {
-                let compiled_pred = cg.compile_predicate(clauses);
-                wam.add_predicate(clauses, compiled_pred)
-            } else {
-                let msg = r"Error: predicate is inconsistent.
-Each predicate must have the same name and arity.";
-
-                EvalSession::EntryFailure(String::from(msg))
-            }
+            let compiled_pred = cg.compile_predicate(clauses);
+            
+            wam.add_predicate(clauses, compiled_pred)
         },
         &TopLevel::Fact(ref fact) => {
             let mut cg = CodeGenerator::<DebrayAllocator>::new();
index 78dd0320167b5f74dff095732c977589f9486a65..014908b97976df3fc14b8eb929881210a417977b 100644 (file)
@@ -53,15 +53,12 @@ impl<'a> QueryIterator<'a> {
     fn from_term(term: &'a Term) -> Self {
         let state = match term {
             &Term::AnonVar =>
-            //IteratorState::AnonVar(Level::Shallow),
                 return QueryIterator { state_stack: vec![] },
             &Term::Clause(_, _, ref terms) =>
                 IteratorState::Clause(0, ClauseType::Root, terms),
             &Term::Cons(_, _, _) =>
-            //IteratorState::InitialCons(Level::Shallow, cell, head.as_ref(), tail.as_ref()),
                 return QueryIterator { state_stack: vec![] },
             &Term::Constant(_, _) =>
-            //IteratorState::Constant(Level::Shallow, cell, constant),
                 return QueryIterator { state_stack: vec![] },
             &Term::Var(ref cell, ref var) =>
                 IteratorState::Var(Level::Shallow, cell, var)
index f58bc73d6205fed26894614b76af0cb8d2e99d17..223ac2064d1dc7b62886254ca3217fa79f5dc534 100644 (file)
@@ -36,7 +36,7 @@ struct MachineState {
     tr: usize,
     hb: usize,
     block: usize, // an offset into the OR stack.
-    ball: (usize, Heap) // heap boundary, and a term copy
+    ball: (usize, Heap) // heap boundary, and a term copy    
 }
 
 struct DuplicateTerm<'a> {
@@ -158,6 +158,7 @@ pub struct Machine {
     ms: MachineState,
     code: Code,
     code_dir: CodeDir,
+    op_dir: OpDir,
     cached_query: Option<Code>
 }
 
@@ -205,12 +206,13 @@ impl Index<CodePtr> for Machine {
 
 impl Machine {
     pub fn new() -> Self {
-        let (code, code_dir) = build_code_dir();
+        let (code, code_dir, op_dir) = build_code_dir();
 
         Machine {
             ms: MachineState::new(),
             code: code,
             code_dir: code_dir,
+            op_dir: op_dir,
             cached_query: None
         }
     }
@@ -484,12 +486,8 @@ impl Machine {
 
         while let Some(view) = viewer.next() {
             match view {
-                CellView::Con(&Constant::BlockNum(integer)) =>
-                    result += integer.to_string().as_str(),
-                CellView::Con(&Constant::EmptyList) =>
-                    result += "[]",
-                CellView::Con(&Constant::Atom(ref atom)) =>
-                    result += atom.as_str(),
+                CellView::Con(ref r) =>
+                    result += format!("{}", r).as_str(),
                 CellView::HeapVar(cell_num) => {
                     result += "_";
                     result += cell_num.to_string().as_str();
@@ -552,6 +550,10 @@ impl Machine {
     pub fn reset(&mut self) {
         self.ms.reset();
     }
+
+    pub fn op_dir(&self) -> &OpDir {
+        &self.op_dir
+    }
 }
 
 impl MachineState {
@@ -1163,11 +1165,11 @@ impl MachineState {
 
     fn throw_exception(&mut self, mut hcv: Vec<HeapCellValue>) {
         let h = self.h;
-        
+
         self.registers[1] = Addr::HeapCell(h);
         self.h += hcv.len();
-        
-        self.heap.append(&mut hcv);        
+
+        self.heap.append(&mut hcv);
         self.goto_throw();
     }
 
@@ -1256,7 +1258,7 @@ impl MachineState {
                 self.p += 1;
             },
             &BuiltInInstruction::GetCurrentBlock => {
-                let c = Constant::BlockNum(self.block);
+                let c = Constant::Usize(self.block);
                 let addr = self[temp_v!(1)].clone();
 
                 self.write_constant_to_var(addr, &c);
@@ -1297,10 +1299,9 @@ impl MachineState {
             },
             &BuiltInInstruction::SetBall => {
                 let addr = self[temp_v!(1)].clone();
+                self.ball.0 = self.h;
 
                 {
-                    self.ball.0 = self.h;
-
                     let mut duplicator = DuplicateBallTerm::new(self);
                     duplicator.duplicate_term(addr);
                 }
@@ -1311,7 +1312,7 @@ impl MachineState {
                 let nb = self.store(self.deref(self[temp_v!(1)].clone()));
 
                 match nb {
-                    Addr::Con(Constant::BlockNum(nb)) => {
+                    Addr::Con(Constant::Usize(nb)) => {
                         let b = self.b - 1;
 
                         if nb > 0 && self.or_stack[b].b == nb {
@@ -1325,7 +1326,7 @@ impl MachineState {
             },
             &BuiltInInstruction::InstallNewBlock => {
                 self.block = self.b;
-                let c = Constant::BlockNum(self.block);
+                let c = Constant::Usize(self.block);
                 let addr = self[temp_v!(1)].clone();
 
                 self.write_constant_to_var(addr, &c);
@@ -1335,7 +1336,7 @@ impl MachineState {
                 let addr = self.deref(self[temp_v!(1)].clone());
 
                 match self.store(addr) {
-                    Addr::Con(Constant::BlockNum(b)) => {
+                    Addr::Con(Constant::Usize(b)) => {
                         self.block = b;
                         self.p += 1;
                     },
index 857496a1237790b6bb4b0a2dee76c49d40e8575c..0d7e0345949dff831ff31ee74d75321a7bcdd41e 100644 (file)
@@ -1,6 +1,13 @@
+extern crate num;
+extern crate ordered_float;
+
 pub mod allocator;
 pub mod and_stack;
+#[macro_use]
 pub mod ast;
+#[macro_use]
+pub mod macros;
+pub mod builtins;
 pub mod codegen;
 pub mod copier;
 pub mod debray_allocator;
@@ -9,12 +16,7 @@ pub mod heapview;
 pub mod indexing;
 pub mod io;
 pub mod iterators;
-#[macro_use]
-pub mod macros;
-pub mod naive_allocator;
-pub mod prolog_parser;
 pub mod machine;
 pub mod or_stack;
+pub mod parser;
 pub mod targets;
-
-pub mod builtins;
diff --git a/src/prolog/parser b/src/prolog/parser
new file mode 160000 (submodule)
index 0000000..de2a1a7
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit de2a1a73649e2c52a05d19ff33f08c33c22b3973
diff --git a/src/prolog/prolog_parser.lalrpop b/src/prolog/prolog_parser.lalrpop
deleted file mode 100644 (file)
index ccebf81..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-use prolog::ast::*;
-//use prolog::prolog_parser_utils::*;
-
-use std::cell::Cell;
-
-grammar;
-
-pub TopLevel: TopLevel = {
-    "?-" <q:Query> "." => TopLevel::Query(q),
-    <Predicate> => TopLevel::Predicate(<>),
-    <Rule>  "." => TopLevel::Rule(<>),
-    <Term>  "." => TopLevel::Fact(<>)
-};
-
-Atom : Atom = {
-    r"[a-z][A-Za-z0-9_]*" => <>.trim().to_string(),
-};
-
-BoxedTerm : Box<Term> = {
-    <t:Term> => Box::new(t)
-};
-
-Clause : Term = {
-    <a: Atom> "(" <ts: (<BoxedTerm> ",")*> <t:BoxedTerm> ")" => {
-       let mut ts = ts;
-       ts.push(t);
-       Term::Clause(Cell::default(), a, ts)
-    }
-};
-
-List : Term = {
-    "[]" => Term::Constant(Cell::default(), Constant::EmptyList),
-    "[" <ListInternals> "]" => <>
-};
-
-ListInternals : Term = {
-    <t:BoxedTerm> => Term::Cons(Cell::default(),
-                                t,
-                               Box::new(Term::Constant(Cell::default(),
-                                                       Constant::EmptyList))),
-    <t:BoxedTerm>  "," <li: ListInternals> => Term::Cons(Cell::default(),
-                                                         t,
-                                                        Box::new(li)),
-    <t1:BoxedTerm> "|" <t2:BoxedTerm> => Term::Cons(Cell::default(), t1, t2)
-};
-
-Predicate : Vec<PredicateClause> = {
-    <pcs: (<PredicateClause>)+> <pc: PredicateClause> => {
-        let mut pcs = pcs;
-       pcs.push(pc);
-       pcs
-    }
-};
-
-PredicateClause : PredicateClause = {
-    <Rule> "." => PredicateClause::Rule(<>),
-    <Term> "." => PredicateClause::Fact(<>)
-};
-
-Query : Vec<QueryTerm> = {
-    <tcs: (<QueryTerm> ",")*> <tc: QueryTerm> => {
-        let mut tcs = tcs;
-        tcs.push(tc);
-        tcs
-    }
-};
-
-Rule : Rule = {
-    <c:Clause> ":-" <h:QueryTerm> <cs: ("," <QueryTerm>)*> =>
-        Rule { head: (c, h), clauses: cs },
-    <a:Atom> ":-" <h:QueryTerm> <cs: ("," <QueryTerm>)*> =>
-        Rule { head: (Term::Constant(Cell::default(), Constant::Atom(a)), h),
-               clauses: cs }
-};
-
-QueryTerm : QueryTerm = {
-    "!"      => QueryTerm::Cut,
-    <Var>    => QueryTerm::CallN(vec![Box::new(Term::Var(Cell::default(), <>))]),
-    <Clause> => QueryTerm::Term(<>),        
-    <Atom>   => QueryTerm::Term(Term::Constant(Cell::default(), Constant::Atom(<>)))
-};
-
-Term : Term = {
-    <Clause> => <>,
-    <Atom>   => Term::Constant(Cell::default(), Constant::Atom(<>)),
-    <List>   => <>,
-    <Var>    => Term::Var(Cell::default(), <>),
-    "_"      => Term::AnonVar
-};
-
-Var : Var = {
-    r"[A-Z][A-Za-z0-9_]*" => <>.trim().to_string()
-};
diff --git a/src/prolog/prolog_parser.rs b/src/prolog/prolog_parser.rs
deleted file mode 100644 (file)
index c465658..0000000
+++ /dev/null
@@ -1,2633 +0,0 @@
-use prolog::ast::*;
-use std::cell::Cell;
-extern crate lalrpop_util as __lalrpop_util;
-
-mod __parse__TopLevel {
-    #![allow(non_snake_case, non_camel_case_types, unused_mut, unused_variables, unused_imports)]
-
-    use prolog::ast::*;
-    use std::cell::Cell;
-    extern crate lalrpop_util as __lalrpop_util;
-    #[allow(dead_code)]
-    pub enum __Symbol<'input> {
-        Term_22_21_22(&'input str),
-        Term_22_28_22(&'input str),
-        Term_22_29_22(&'input str),
-        Term_22_2c_22(&'input str),
-        Term_22_2e_22(&'input str),
-        Term_22_3a_2d_22(&'input str),
-        Term_22_3f_2d_22(&'input str),
-        Term_22_5b_22(&'input str),
-        Term_22_5b_5d_22(&'input str),
-        Term_22_5d_22(&'input str),
-        Term_22___22(&'input str),
-        Term_22_7c_22(&'input str),
-        Termr_23_22_5bA_2dZ_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(&'input str),
-        Termr_23_22_5ba_2dz_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(&'input str),
-        Nt_28_22_2c_22_20_3cQueryTerm_3e_29(QueryTerm),
-        Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2a(::std::vec::Vec<QueryTerm>),
-        Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(::std::vec::Vec<QueryTerm>),
-        Nt_28_3cBoxedTerm_3e_20_22_2c_22_29(Box<Term>),
-        Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2a(::std::vec::Vec<Box<Term>>),
-        Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(::std::vec::Vec<Box<Term>>),
-        Nt_28_3cPredicateClause_3e_29(PredicateClause),
-        Nt_28_3cPredicateClause_3e_29_2b(::std::vec::Vec<PredicateClause>),
-        Nt_28_3cQueryTerm_3e_20_22_2c_22_29(QueryTerm),
-        Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2a(::std::vec::Vec<QueryTerm>),
-        Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(::std::vec::Vec<QueryTerm>),
-        NtAtom(Atom),
-        NtBoxedTerm(Box<Term>),
-        NtClause(Term),
-        NtList(Term),
-        NtListInternals(Term),
-        NtPredicate(Vec<PredicateClause>),
-        NtPredicateClause(PredicateClause),
-        NtQuery(Vec<QueryTerm>),
-        NtQueryTerm(QueryTerm),
-        NtRule(Rule),
-        NtTerm(Term),
-        NtTopLevel(TopLevel),
-        NtVar(Var),
-        Nt____TopLevel(TopLevel),
-    }
-    const __ACTION: &'static [i32] = &[
-        // State 0
-        0, 0, 0, 0, 0, 0, 12, 13, 14, 0, 15, 0, 16, 17,
-        // State 1
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 2
-        0, 21, 0, 0, -42, 22, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 3
-        0, 0, 0, 0, -41, 23, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 4
-        -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43,
-        // State 5
-        -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47, -47,
-        // State 6
-        -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12, -12,
-        // State 7
-        0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 8
-        0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 9
-        -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51, -51,
-        // State 10
-        -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44, -44,
-        // State 11
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 12
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 13
-        -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23,
-        // State 14
-        -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
-        // State 15
-        -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, -50,
-        // State 16
-        -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19, -19,
-        // State 17
-        0, 0, 0, 0, 0, 0, 0, -13, -13, 0, -13, 0, -13, -13,
-        // State 18
-        0, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 19
-        0, 0, 0, 0, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 20
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 21
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 22
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 23
-        0, 0, 0, 0, 0, 0, 0, -29, -29, 0, -29, 0, -29, -29,
-        // State 24
-        0, 0, 0, 0, 0, 0, 0, -30, -30, 0, -30, 0, -30, -30,
-        // State 25
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 26
-        0, 21, 0, -36, -36, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 27
-        -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35,
-        // State 28
-        0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 29
-        0, 0, 0, 46, -31, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 30
-        -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34, -34,
-        // State 31
-        -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, -33,
-        // State 32
-        0, 21, -42, -42, 0, 0, 0, 0, 0, -42, 0, -42, 0, 0,
-        // State 33
-        0, 0, 0, 47, 0, 0, 0, 0, 0, -25, 0, 48, 0, 0,
-        // State 34
-        -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41, -41,
-        // State 35
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, 0, 0,
-        // State 36
-        -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20, -20,
-        // State 37
-        -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29,
-        // State 38
-        -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30, -30,
-        // State 39
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 40
-        0, 0, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 41
-        0, 0, 0, 54, -39, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 42
-        0, 0, 0, 54, -37, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 43
-        0, 0, 0, 56, -32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 44
-        -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46, -46,
-        // State 45
-        -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17, -17,
-        // State 46
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 47
-        0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 15, 0, 16, 17,
-        // State 48
-        -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
-        // State 49
-        0, 0, 59, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 50
-        -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
-        // State 51
-        -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9, -9,
-        // State 52
-        0, 0, 0, 61, -40, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 53
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 54
-        0, 0, 0, 61, -38, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 55
-        -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18, -18,
-        // State 56
-        -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
-        // State 57
-        -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27,
-        // State 58
-        -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, -22,
-        // State 59
-        -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10,
-        // State 60
-        32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 17,
-        // State 61
-        -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-        // State 62
-        -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
-    ];
-    const __EOF_ACTION: &'static [i32] = &[
-        0,
-        0,
-        0,
-        0,
-        -43,
-        -47,
-        -12,
-        0,
-        0,
-        -51,
-        -44,
-        0,
-        0,
-        -23,
-        -45,
-        -50,
-        -19,
-        -28,
-        0,
-        0,
-        0,
-        0,
-        0,
-        -48,
-        -49,
-        0,
-        0,
-        -35,
-        0,
-        0,
-        -34,
-        -33,
-        0,
-        0,
-        -41,
-        0,
-        -20,
-        -29,
-        -30,
-        0,
-        0,
-        0,
-        0,
-        0,
-        -46,
-        -17,
-        0,
-        0,
-        -24,
-        0,
-        -21,
-        -9,
-        0,
-        0,
-        0,
-        -18,
-        -26,
-        -27,
-        -22,
-        -10,
-        0,
-        -4,
-        -5,
-    ];
-    const __GOTO: &'static [i32] = &[
-        // State 0
-        0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 4, 5, 0, 6, 7, 0, 0, 8, 9, 10, 11, 0,
-        // State 1
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4, 5, 0, 0, 18, 0, 0, 19, 20, 0, 11, 0,
-        // State 2
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 3
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 4
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 5
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 6
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 7
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 8
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 9
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 10
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 11
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 27, 0, 28, 0, 0, 0, 0, 29, 30, 0, 0, 0, 31, 0,
-        // State 12
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 5, 36, 0, 0, 0, 0, 0, 37, 0, 11, 0,
-        // State 13
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 14
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 15
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 16
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 17
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 18
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 19
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 20
-        0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 33, 41, 35, 5, 0, 0, 0, 0, 0, 0, 37, 0, 11, 0,
-        // State 21
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 0, 0, 0, 0, 0, 42, 0, 0, 0, 31, 0,
-        // State 22
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 0, 0, 0, 0, 0, 43, 0, 0, 0, 31, 0,
-        // State 23
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 24
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 25
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 0, 0, 0, 0, 0, 44, 0, 0, 0, 31, 0,
-        // State 26
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 27
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 28
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 29
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 30
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 31
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 32
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 33
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 34
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 35
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 36
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 37
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 38
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 39
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 50, 35, 5, 0, 0, 0, 0, 0, 0, 37, 0, 11, 0,
-        // State 40
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 41
-        0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 42
-        0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 43
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 44
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 45
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 46
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 34, 35, 5, 57, 0, 0, 0, 0, 0, 37, 0, 11, 0,
-        // State 47
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 58, 35, 5, 0, 0, 0, 0, 0, 0, 37, 0, 11, 0,
-        // State 48
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 49
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 50
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 51
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 52
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 53
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 0, 0, 0, 0, 0, 62, 0, 0, 0, 31, 0,
-        // State 54
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 55
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 56
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 57
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 58
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 59
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 60
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 28, 0, 0, 0, 0, 0, 63, 0, 0, 0, 31, 0,
-        // State 61
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        // State 62
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    ];
-    fn __expected_tokens(__state: usize) -> Vec<::std::string::String> {
-        const __TERMINAL: &'static [&'static str] = &[
-            r###""!""###,
-            r###""(""###,
-            r###"")""###,
-            r###"",""###,
-            r###"".""###,
-            r###"":-""###,
-            r###""?-""###,
-            r###""[""###,
-            r###""[]""###,
-            r###""]""###,
-            r###""_""###,
-            r###""|""###,
-            r###"r#"[A-Z][A-Za-z0-9_]*"#"###,
-            r###"r#"[a-z][A-Za-z0-9_]*"#"###,
-        ];
-        __ACTION[(__state * 14)..].iter().zip(__TERMINAL).filter_map(|(&state, terminal)| {
-            if state == 0 {
-                None
-            } else {
-                Some(terminal.to_string())
-            }
-        }).collect()
-    }
-    pub fn parse_TopLevel<
-        'input,
-    >(
-        input: &'input str,
-    ) -> Result<TopLevel, __lalrpop_util::ParseError<usize, (usize, &'input str), ()>>
-    {
-        let mut __tokens = super::__intern_token::__Matcher::new(input);
-        let mut __states = vec![0_i32];
-        let mut __symbols = vec![];
-        let mut __integer;
-        let mut __lookahead;
-        let mut __last_location = Default::default();
-        '__shift: loop {
-            __lookahead = match __tokens.next() {
-                Some(Ok(v)) => v,
-                None => break '__shift,
-                Some(Err(e)) => return Err(e),
-            };
-            __last_location = __lookahead.2.clone();
-            __integer = match __lookahead.1 {
-                (2, _) if true => 0,
-                (3, _) if true => 1,
-                (4, _) if true => 2,
-                (5, _) if true => 3,
-                (6, _) if true => 4,
-                (7, _) if true => 5,
-                (8, _) if true => 6,
-                (9, _) if true => 7,
-                (10, _) if true => 8,
-                (11, _) if true => 9,
-                (12, _) if true => 10,
-                (13, _) if true => 11,
-                (0, _) if true => 12,
-                (1, _) if true => 13,
-                _ => {
-                    let __state = *__states.last().unwrap() as usize;
-                    let __error = __lalrpop_util::ParseError::UnrecognizedToken {
-                        token: Some(__lookahead),
-                        expected: __expected_tokens(__state),
-                    };
-                    return Err(__error);
-                }
-            };
-            '__inner: loop {
-                let __state = *__states.last().unwrap() as usize;
-                let __action = __ACTION[__state * 14 + __integer];
-                if __action > 0 {
-                    let __symbol = match __integer {
-                        0 => match __lookahead.1 {
-                            (2, __tok0) => __Symbol::Term_22_21_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        1 => match __lookahead.1 {
-                            (3, __tok0) => __Symbol::Term_22_28_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        2 => match __lookahead.1 {
-                            (4, __tok0) => __Symbol::Term_22_29_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        3 => match __lookahead.1 {
-                            (5, __tok0) => __Symbol::Term_22_2c_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        4 => match __lookahead.1 {
-                            (6, __tok0) => __Symbol::Term_22_2e_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        5 => match __lookahead.1 {
-                            (7, __tok0) => __Symbol::Term_22_3a_2d_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        6 => match __lookahead.1 {
-                            (8, __tok0) => __Symbol::Term_22_3f_2d_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        7 => match __lookahead.1 {
-                            (9, __tok0) => __Symbol::Term_22_5b_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        8 => match __lookahead.1 {
-                            (10, __tok0) => __Symbol::Term_22_5b_5d_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        9 => match __lookahead.1 {
-                            (11, __tok0) => __Symbol::Term_22_5d_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        10 => match __lookahead.1 {
-                            (12, __tok0) => __Symbol::Term_22___22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        11 => match __lookahead.1 {
-                            (13, __tok0) => __Symbol::Term_22_7c_22((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        12 => match __lookahead.1 {
-                            (0, __tok0) => __Symbol::Termr_23_22_5bA_2dZ_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        13 => match __lookahead.1 {
-                            (1, __tok0) => __Symbol::Termr_23_22_5ba_2dz_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23((__tok0)),
-                            _ => unreachable!(),
-                        },
-                        _ => unreachable!(),
-                    };
-                    __states.push(__action - 1);
-                    __symbols.push((__lookahead.0, __symbol, __lookahead.2));
-                    continue '__shift;
-                } else if __action < 0 {
-                    if let Some(r) = __reduce(input, __action, Some(&__lookahead.0), &mut __states, &mut __symbols, ::std::marker::PhantomData::<()>) {
-                        return r;
-                    }
-                } else {
-                    let __state = *__states.last().unwrap() as usize;
-                    let __error = __lalrpop_util::ParseError::UnrecognizedToken {
-                        token: Some(__lookahead),
-                        expected: __expected_tokens(__state),
-                    };
-                    return Err(__error)
-                }
-            }
-        }
-        loop {
-            let __state = *__states.last().unwrap() as usize;
-            let __action = __EOF_ACTION[__state];
-            if __action < 0 {
-                if let Some(r) = __reduce(input, __action, None, &mut __states, &mut __symbols, ::std::marker::PhantomData::<()>) {
-                    return r;
-                }
-            } else {
-                let __state = *__states.last().unwrap() as usize;
-                let __error = __lalrpop_util::ParseError::UnrecognizedToken {
-                    token: None,
-                    expected: __expected_tokens(__state),
-                };
-                return Err(__error);
-            }
-        }
-    }
-    pub fn __reduce<
-        'input,
-    >(
-        input: &'input str,
-        __action: i32,
-        __lookahead_start: Option<&usize>,
-        __states: &mut ::std::vec::Vec<i32>,
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>,
-        _: ::std::marker::PhantomData<()>,
-    ) -> Option<Result<TopLevel,__lalrpop_util::ParseError<usize, (usize, &'input str), ()>>>
-    {
-        let __nonterminal = match -__action {
-            1 => {
-                // ("," <QueryTerm>) = ",", QueryTerm => ActionFn(31);
-                let __sym1 = __pop_NtQueryTerm(__symbols);
-                let __sym0 = __pop_Term_22_2c_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action31::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29(__nt), __end));
-                0
-            }
-            2 => {
-                // ("," <QueryTerm>)* =  => ActionFn(29);
-                let __start = __symbols.last().map(|s| s.2.clone()).unwrap_or_default();
-                let __end = __lookahead_start.cloned().unwrap_or_else(|| __start.clone());
-                let __nt = super::__action29::<>(input, &__start, &__end);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 0);
-                __symbols.push((__start, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2a(__nt), __end));
-                1
-            }
-            3 => {
-                // ("," <QueryTerm>)* = ("," <QueryTerm>)+ => ActionFn(30);
-                let __sym0 = __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action30::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2a(__nt), __end));
-                1
-            }
-            4 => {
-                // ("," <QueryTerm>)+ = ",", QueryTerm => ActionFn(47);
-                let __sym1 = __pop_NtQueryTerm(__symbols);
-                let __sym0 = __pop_Term_22_2c_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action47::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__nt), __end));
-                2
-            }
-            5 => {
-                // ("," <QueryTerm>)+ = ("," <QueryTerm>)+, ",", QueryTerm => ActionFn(48);
-                let __sym2 = __pop_NtQueryTerm(__symbols);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action48::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__nt), __end));
-                2
-            }
-            6 => {
-                // (<BoxedTerm> ",") = BoxedTerm, "," => ActionFn(40);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_NtBoxedTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action40::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29(__nt), __end));
-                3
-            }
-            7 => {
-                // (<BoxedTerm> ",")* =  => ActionFn(38);
-                let __start = __symbols.last().map(|s| s.2.clone()).unwrap_or_default();
-                let __end = __lookahead_start.cloned().unwrap_or_else(|| __start.clone());
-                let __nt = super::__action38::<>(input, &__start, &__end);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 0);
-                __symbols.push((__start, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2a(__nt), __end));
-                4
-            }
-            8 => {
-                // (<BoxedTerm> ",")* = (<BoxedTerm> ",")+ => ActionFn(39);
-                let __sym0 = __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action39::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2a(__nt), __end));
-                4
-            }
-            9 => {
-                // (<BoxedTerm> ",")+ = BoxedTerm, "," => ActionFn(53);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_NtBoxedTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action53::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__nt), __end));
-                5
-            }
-            10 => {
-                // (<BoxedTerm> ",")+ = (<BoxedTerm> ",")+, BoxedTerm, "," => ActionFn(54);
-                let __sym2 = __pop_Term_22_2c_22(__symbols);
-                let __sym1 = __pop_NtBoxedTerm(__symbols);
-                let __sym0 = __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action54::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__nt), __end));
-                5
-            }
-            11 => {
-                // (<PredicateClause>) = PredicateClause => ActionFn(37);
-                let __sym0 = __pop_NtPredicateClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action37::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::Nt_28_3cPredicateClause_3e_29(__nt), __end));
-                6
-            }
-            12 => {
-                // (<PredicateClause>)+ = PredicateClause => ActionFn(57);
-                let __sym0 = __pop_NtPredicateClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action57::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::Nt_28_3cPredicateClause_3e_29_2b(__nt), __end));
-                7
-            }
-            13 => {
-                // (<PredicateClause>)+ = (<PredicateClause>)+, PredicateClause => ActionFn(58);
-                let __sym1 = __pop_NtPredicateClause(__symbols);
-                let __sym0 = __pop_Nt_28_3cPredicateClause_3e_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action58::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_3cPredicateClause_3e_29_2b(__nt), __end));
-                7
-            }
-            14 => {
-                // (<QueryTerm> ",") = QueryTerm, "," => ActionFn(34);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_NtQueryTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action34::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29(__nt), __end));
-                8
-            }
-            15 => {
-                // (<QueryTerm> ",")* =  => ActionFn(32);
-                let __start = __symbols.last().map(|s| s.2.clone()).unwrap_or_default();
-                let __end = __lookahead_start.cloned().unwrap_or_else(|| __start.clone());
-                let __nt = super::__action32::<>(input, &__start, &__end);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 0);
-                __symbols.push((__start, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2a(__nt), __end));
-                9
-            }
-            16 => {
-                // (<QueryTerm> ",")* = (<QueryTerm> ",")+ => ActionFn(33);
-                let __sym0 = __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action33::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2a(__nt), __end));
-                9
-            }
-            17 => {
-                // (<QueryTerm> ",")+ = QueryTerm, "," => ActionFn(59);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_NtQueryTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action59::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__nt), __end));
-                10
-            }
-            18 => {
-                // (<QueryTerm> ",")+ = (<QueryTerm> ",")+, QueryTerm, "," => ActionFn(60);
-                let __sym2 = __pop_Term_22_2c_22(__symbols);
-                let __sym1 = __pop_NtQueryTerm(__symbols);
-                let __sym0 = __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action60::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__nt), __end));
-                10
-            }
-            19 => {
-                // Atom = r#"[a-z][A-Za-z0-9_]*"# => ActionFn(5);
-                let __sym0 = __pop_Termr_23_22_5ba_2dz_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action5::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtAtom(__nt), __end));
-                11
-            }
-            20 => {
-                // BoxedTerm = Term => ActionFn(6);
-                let __sym0 = __pop_NtTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action6::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtBoxedTerm(__nt), __end));
-                12
-            }
-            21 => {
-                // Clause = Atom, "(", BoxedTerm, ")" => ActionFn(55);
-                let __sym3 = __pop_Term_22_29_22(__symbols);
-                let __sym2 = __pop_NtBoxedTerm(__symbols);
-                let __sym1 = __pop_Term_22_28_22(__symbols);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym3.2.clone();
-                let __nt = super::__action55::<>(input, __sym0, __sym1, __sym2, __sym3);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 4);
-                __symbols.push((__start, __Symbol::NtClause(__nt), __end));
-                13
-            }
-            22 => {
-                // Clause = Atom, "(", (<BoxedTerm> ",")+, BoxedTerm, ")" => ActionFn(56);
-                let __sym4 = __pop_Term_22_29_22(__symbols);
-                let __sym3 = __pop_NtBoxedTerm(__symbols);
-                let __sym2 = __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __sym1 = __pop_Term_22_28_22(__symbols);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym4.2.clone();
-                let __nt = super::__action56::<>(input, __sym0, __sym1, __sym2, __sym3, __sym4);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 5);
-                __symbols.push((__start, __Symbol::NtClause(__nt), __end));
-                13
-            }
-            23 => {
-                // List = "[]" => ActionFn(8);
-                let __sym0 = __pop_Term_22_5b_5d_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action8::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtList(__nt), __end));
-                14
-            }
-            24 => {
-                // List = "[", ListInternals, "]" => ActionFn(9);
-                let __sym2 = __pop_Term_22_5d_22(__symbols);
-                let __sym1 = __pop_NtListInternals(__symbols);
-                let __sym0 = __pop_Term_22_5b_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action9::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtList(__nt), __end));
-                14
-            }
-            25 => {
-                // ListInternals = BoxedTerm => ActionFn(10);
-                let __sym0 = __pop_NtBoxedTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action10::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtListInternals(__nt), __end));
-                15
-            }
-            26 => {
-                // ListInternals = BoxedTerm, ",", ListInternals => ActionFn(11);
-                let __sym2 = __pop_NtListInternals(__symbols);
-                let __sym1 = __pop_Term_22_2c_22(__symbols);
-                let __sym0 = __pop_NtBoxedTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action11::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtListInternals(__nt), __end));
-                15
-            }
-            27 => {
-                // ListInternals = BoxedTerm, "|", BoxedTerm => ActionFn(12);
-                let __sym2 = __pop_NtBoxedTerm(__symbols);
-                let __sym1 = __pop_Term_22_7c_22(__symbols);
-                let __sym0 = __pop_NtBoxedTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action12::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtListInternals(__nt), __end));
-                15
-            }
-            28 => {
-                // Predicate = (<PredicateClause>)+, PredicateClause => ActionFn(13);
-                let __sym1 = __pop_NtPredicateClause(__symbols);
-                let __sym0 = __pop_Nt_28_3cPredicateClause_3e_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action13::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtPredicate(__nt), __end));
-                16
-            }
-            29 => {
-                // PredicateClause = Rule, "." => ActionFn(14);
-                let __sym1 = __pop_Term_22_2e_22(__symbols);
-                let __sym0 = __pop_NtRule(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action14::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtPredicateClause(__nt), __end));
-                17
-            }
-            30 => {
-                // PredicateClause = Term, "." => ActionFn(15);
-                let __sym1 = __pop_Term_22_2e_22(__symbols);
-                let __sym0 = __pop_NtTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action15::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtPredicateClause(__nt), __end));
-                17
-            }
-            31 => {
-                // Query = QueryTerm => ActionFn(61);
-                let __sym0 = __pop_NtQueryTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action61::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtQuery(__nt), __end));
-                18
-            }
-            32 => {
-                // Query = (<QueryTerm> ",")+, QueryTerm => ActionFn(62);
-                let __sym1 = __pop_NtQueryTerm(__symbols);
-                let __sym0 = __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action62::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtQuery(__nt), __end));
-                18
-            }
-            33 => {
-                // QueryTerm = "!" => ActionFn(19);
-                let __sym0 = __pop_Term_22_21_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action19::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtQueryTerm(__nt), __end));
-                19
-            }
-            34 => {
-                // QueryTerm = Var => ActionFn(20);
-                let __sym0 = __pop_NtVar(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action20::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtQueryTerm(__nt), __end));
-                19
-            }
-            35 => {
-                // QueryTerm = Clause => ActionFn(21);
-                let __sym0 = __pop_NtClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action21::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtQueryTerm(__nt), __end));
-                19
-            }
-            36 => {
-                // QueryTerm = Atom => ActionFn(22);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action22::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtQueryTerm(__nt), __end));
-                19
-            }
-            37 => {
-                // Rule = Clause, ":-", QueryTerm => ActionFn(49);
-                let __sym2 = __pop_NtQueryTerm(__symbols);
-                let __sym1 = __pop_Term_22_3a_2d_22(__symbols);
-                let __sym0 = __pop_NtClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action49::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtRule(__nt), __end));
-                20
-            }
-            38 => {
-                // Rule = Clause, ":-", QueryTerm, ("," <QueryTerm>)+ => ActionFn(50);
-                let __sym3 = __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__symbols);
-                let __sym2 = __pop_NtQueryTerm(__symbols);
-                let __sym1 = __pop_Term_22_3a_2d_22(__symbols);
-                let __sym0 = __pop_NtClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym3.2.clone();
-                let __nt = super::__action50::<>(input, __sym0, __sym1, __sym2, __sym3);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 4);
-                __symbols.push((__start, __Symbol::NtRule(__nt), __end));
-                20
-            }
-            39 => {
-                // Rule = Atom, ":-", QueryTerm => ActionFn(51);
-                let __sym2 = __pop_NtQueryTerm(__symbols);
-                let __sym1 = __pop_Term_22_3a_2d_22(__symbols);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action51::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtRule(__nt), __end));
-                20
-            }
-            40 => {
-                // Rule = Atom, ":-", QueryTerm, ("," <QueryTerm>)+ => ActionFn(52);
-                let __sym3 = __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__symbols);
-                let __sym2 = __pop_NtQueryTerm(__symbols);
-                let __sym1 = __pop_Term_22_3a_2d_22(__symbols);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym3.2.clone();
-                let __nt = super::__action52::<>(input, __sym0, __sym1, __sym2, __sym3);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 4);
-                __symbols.push((__start, __Symbol::NtRule(__nt), __end));
-                20
-            }
-            41 => {
-                // Term = Clause => ActionFn(23);
-                let __sym0 = __pop_NtClause(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action23::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTerm(__nt), __end));
-                21
-            }
-            42 => {
-                // Term = Atom => ActionFn(24);
-                let __sym0 = __pop_NtAtom(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action24::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTerm(__nt), __end));
-                21
-            }
-            43 => {
-                // Term = List => ActionFn(25);
-                let __sym0 = __pop_NtList(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action25::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTerm(__nt), __end));
-                21
-            }
-            44 => {
-                // Term = Var => ActionFn(26);
-                let __sym0 = __pop_NtVar(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action26::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTerm(__nt), __end));
-                21
-            }
-            45 => {
-                // Term = "_" => ActionFn(27);
-                let __sym0 = __pop_Term_22___22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action27::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTerm(__nt), __end));
-                21
-            }
-            46 => {
-                // TopLevel = "?-", Query, "." => ActionFn(1);
-                let __sym2 = __pop_Term_22_2e_22(__symbols);
-                let __sym1 = __pop_NtQuery(__symbols);
-                let __sym0 = __pop_Term_22_3f_2d_22(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym2.2.clone();
-                let __nt = super::__action1::<>(input, __sym0, __sym1, __sym2);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 3);
-                __symbols.push((__start, __Symbol::NtTopLevel(__nt), __end));
-                22
-            }
-            47 => {
-                // TopLevel = Predicate => ActionFn(2);
-                let __sym0 = __pop_NtPredicate(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action2::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtTopLevel(__nt), __end));
-                22
-            }
-            48 => {
-                // TopLevel = Rule, "." => ActionFn(3);
-                let __sym1 = __pop_Term_22_2e_22(__symbols);
-                let __sym0 = __pop_NtRule(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action3::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtTopLevel(__nt), __end));
-                22
-            }
-            49 => {
-                // TopLevel = Term, "." => ActionFn(4);
-                let __sym1 = __pop_Term_22_2e_22(__symbols);
-                let __sym0 = __pop_NtTerm(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym1.2.clone();
-                let __nt = super::__action4::<>(input, __sym0, __sym1);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 2);
-                __symbols.push((__start, __Symbol::NtTopLevel(__nt), __end));
-                22
-            }
-            50 => {
-                // Var = r#"[A-Z][A-Za-z0-9_]*"# => ActionFn(28);
-                let __sym0 = __pop_Termr_23_22_5bA_2dZ_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action28::<>(input, __sym0);
-                let __states_len = __states.len();
-                __states.truncate(__states_len - 1);
-                __symbols.push((__start, __Symbol::NtVar(__nt), __end));
-                23
-            }
-            51 => {
-                // __TopLevel = TopLevel => ActionFn(0);
-                let __sym0 = __pop_NtTopLevel(__symbols);
-                let __start = __sym0.0.clone();
-                let __end = __sym0.2.clone();
-                let __nt = super::__action0::<>(input, __sym0);
-                return Some(Ok(__nt));
-            }
-            _ => panic!("invalid action code {}", __action)
-        };
-        let __state = *__states.last().unwrap() as usize;
-        let __next_state = __GOTO[__state * 25 + __nonterminal] - 1;
-        __states.push(__next_state);
-        None
-    }
-    fn __pop_Term_22_21_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_21_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_28_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_28_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_29_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_29_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_2c_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_2c_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_2e_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_2e_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_3a_2d_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_3a_2d_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_3f_2d_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_3f_2d_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_5b_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_5b_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_5b_5d_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_5b_5d_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_5d_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_5d_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22___22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22___22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Term_22_7c_22<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Term_22_7c_22(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Termr_23_22_5bA_2dZ_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Termr_23_22_5bA_2dZ_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Termr_23_22_5ba_2dz_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, &'input str, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Termr_23_22_5ba_2dz_5d_5bA_2dZa_2dz0_2d9___5d_2a_22_23(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, QueryTerm, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2a<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<QueryTerm>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2a(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<QueryTerm>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_22_2c_22_20_3cQueryTerm_3e_29_2b(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Box<Term>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2a<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<Box<Term>>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2a(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<Box<Term>>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cBoxedTerm_3e_20_22_2c_22_29_2b(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cPredicateClause_3e_29<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, PredicateClause, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cPredicateClause_3e_29(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cPredicateClause_3e_29_2b<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<PredicateClause>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cPredicateClause_3e_29_2b(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, QueryTerm, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2a<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<QueryTerm>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2a(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, ::std::vec::Vec<QueryTerm>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt_28_3cQueryTerm_3e_20_22_2c_22_29_2b(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtAtom<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Atom, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtAtom(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtBoxedTerm<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Box<Term>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtBoxedTerm(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtClause<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Term, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtClause(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtList<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Term, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtList(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtListInternals<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Term, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtListInternals(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtPredicate<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Vec<PredicateClause>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtPredicate(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtPredicateClause<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, PredicateClause, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtPredicateClause(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtQuery<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Vec<QueryTerm>, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtQuery(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtQueryTerm<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, QueryTerm, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtQueryTerm(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtRule<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Rule, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtRule(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtTerm<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Term, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtTerm(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtTopLevel<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, TopLevel, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtTopLevel(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_NtVar<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, Var, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::NtVar(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-    fn __pop_Nt____TopLevel<
-      'input,
-    >(
-        __symbols: &mut ::std::vec::Vec<(usize,__Symbol<'input>,usize)>
-    ) -> (usize, TopLevel, usize) {
-        match __symbols.pop().unwrap() {
-            (__l, __Symbol::Nt____TopLevel(__v), __r) => (__l, __v, __r),
-            _ => panic!("symbol type mismatch")
-        }
-    }
-}
-pub use self::__parse__TopLevel::parse_TopLevel;
-mod __intern_token {
-    #![allow(unused_imports)]
-    use prolog::ast::*;
-    use std::cell::Cell;
-    extern crate lalrpop_util as __lalrpop_util;
-    extern crate regex as __regex;
-    pub struct __Matcher<'input> {
-        text: &'input str,
-        consumed: usize,
-        regex_set: __regex::RegexSet,
-        regex_vec: Vec<__regex::Regex>,
-    }
-
-    impl<'input> __Matcher<'input> {
-        pub fn new(s: &'input str) -> __Matcher<'input> {
-            let __strs: &[&str] = &[
-                "^(?u:[A-Z])(?u:[0-9A-Z_-_a-z])*",
-                "^(?u:[a-z])(?u:[0-9A-Z_-_a-z])*",
-                "^(?u:!)",
-                "^(?u:\\()",
-                "^(?u:\\))",
-                "^(?u:,)",
-                "^(?u:\\.)",
-                "^(?u::\\-)",
-                "^(?u:\\?\\-)",
-                "^(?u:\\[)",
-                "^(?u:\\[\\])",
-                "^(?u:\\])",
-                "^(?u:_)",
-                "^(?u:\\|)",
-            ];
-            let __regex_set = __regex::RegexSet::new(__strs).unwrap();
-            let __regex_vec = vec![
-                __regex::Regex::new("^(?u:[A-Z])(?u:[0-9A-Z_-_a-z])*").unwrap(),
-                __regex::Regex::new("^(?u:[a-z])(?u:[0-9A-Z_-_a-z])*").unwrap(),
-                __regex::Regex::new("^(?u:!)").unwrap(),
-                __regex::Regex::new("^(?u:\\()").unwrap(),
-                __regex::Regex::new("^(?u:\\))").unwrap(),
-                __regex::Regex::new("^(?u:,)").unwrap(),
-                __regex::Regex::new("^(?u:\\.)").unwrap(),
-                __regex::Regex::new("^(?u::\\-)").unwrap(),
-                __regex::Regex::new("^(?u:\\?\\-)").unwrap(),
-                __regex::Regex::new("^(?u:\\[)").unwrap(),
-                __regex::Regex::new("^(?u:\\[\\])").unwrap(),
-                __regex::Regex::new("^(?u:\\])").unwrap(),
-                __regex::Regex::new("^(?u:_)").unwrap(),
-                __regex::Regex::new("^(?u:\\|)").unwrap(),
-            ];
-            __Matcher {
-                text: s,
-                consumed: 0,
-                regex_set: __regex_set,
-                regex_vec: __regex_vec,
-            }
-        }
-    }
-
-    impl<'input> Iterator for __Matcher<'input> {
-        type Item = Result<(usize, (usize, &'input str), usize), __lalrpop_util::ParseError<usize,(usize, &'input str),()>>;
-
-        fn next(&mut self) -> Option<Self::Item> {
-            let __text = self.text.trim_left();
-            let __whitespace = self.text.len() - __text.len();
-            let __start_offset = self.consumed + __whitespace;
-            if __text.is_empty() {
-                self.text = __text;
-                self.consumed = __start_offset;
-                None
-            } else {
-                let __matches = self.regex_set.matches(__text);
-                if !__matches.matched_any() {
-                    Some(Err(__lalrpop_util::ParseError::InvalidToken {
-                        location: __start_offset,
-                    }))
-                } else {
-                    let mut __longest_match = 0;
-                    let mut __index = 0;
-                    for __i in 0 .. 14 {
-                        if __matches.matched(__i) {
-                            let __match = self.regex_vec[__i].find(__text).unwrap();
-                            let __len = __match.end();
-                            if __len >= __longest_match {
-                                __longest_match = __len;
-                                __index = __i;
-                            }
-                        }
-                    }
-                    let __result = &__text[..__longest_match];
-                    let __remaining = &__text[__longest_match..];
-                    let __end_offset = __start_offset + __longest_match;
-                    self.text = __remaining;
-                    self.consumed = __end_offset;
-                    Some(Ok((__start_offset, (__index, __result), __end_offset)))
-                }
-            }
-        }
-    }
-}
-
-#[allow(unused_variables)]
-fn __action0<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, TopLevel, usize),
-) -> TopLevel
-{
-    (__0)
-}
-
-#[allow(unused_variables)]
-fn __action1<
-    'input,
->(
-    input: &'input str,
-    (_, _, _): (usize, &'input str, usize),
-    (_, q, _): (usize, Vec<QueryTerm>, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> TopLevel
-{
-    TopLevel::Query(q)
-}
-
-#[allow(unused_variables)]
-fn __action2<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Vec<PredicateClause>, usize),
-) -> TopLevel
-{
-    TopLevel::Predicate(__0)
-}
-
-#[allow(unused_variables)]
-fn __action3<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Rule, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> TopLevel
-{
-    TopLevel::Rule(__0)
-}
-
-#[allow(unused_variables)]
-fn __action4<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Term, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> TopLevel
-{
-    TopLevel::Fact(__0)
-}
-
-#[allow(unused_variables)]
-fn __action5<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, &'input str, usize),
-) -> Atom
-{
-    __0.trim().to_string()
-}
-
-#[allow(unused_variables)]
-fn __action6<
-    'input,
->(
-    input: &'input str,
-    (_, t, _): (usize, Term, usize),
-) -> Box<Term>
-{
-    Box::new(t)
-}
-
-#[allow(unused_variables)]
-fn __action7<
-    'input,
->(
-    input: &'input str,
-    (_, a, _): (usize, Atom, usize),
-    (_, _, _): (usize, &'input str, usize),
-    (_, ts, _): (usize, ::std::vec::Vec<Box<Term>>, usize),
-    (_, t, _): (usize, Box<Term>, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> Term
-{
-    {
-       let mut ts = ts;
-       ts.push(t);
-       Term::Clause(Cell::default(), a, ts)
-    }
-}
-
-#[allow(unused_variables)]
-fn __action8<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, &'input str, usize),
-) -> Term
-{
-    Term::Constant(Cell::default(), Constant::EmptyList)
-}
-
-#[allow(unused_variables)]
-fn __action9<
-    'input,
->(
-    input: &'input str,
-    (_, _, _): (usize, &'input str, usize),
-    (_, __0, _): (usize, Term, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> Term
-{
-    __0
-}
-
-#[allow(unused_variables)]
-fn __action10<
-    'input,
->(
-    input: &'input str,
-    (_, t, _): (usize, Box<Term>, usize),
-) -> Term
-{
-    Term::Cons(Cell::default(),
-                                t,
-                               Box::new(Term::Constant(Cell::default(),
-                                                       Constant::EmptyList)))
-}
-
-#[allow(unused_variables)]
-fn __action11<
-    'input,
->(
-    input: &'input str,
-    (_, t, _): (usize, Box<Term>, usize),
-    (_, _, _): (usize, &'input str, usize),
-    (_, li, _): (usize, Term, usize),
-) -> Term
-{
-    Term::Cons(Cell::default(),
-                                                         t,
-                                                        Box::new(li))
-}
-
-#[allow(unused_variables)]
-fn __action12<
-    'input,
->(
-    input: &'input str,
-    (_, t1, _): (usize, Box<Term>, usize),
-    (_, _, _): (usize, &'input str, usize),
-    (_, t2, _): (usize, Box<Term>, usize),
-) -> Term
-{
-    Term::Cons(Cell::default(), t1, t2)
-}
-
-#[allow(unused_variables)]
-fn __action13<
-    'input,
->(
-    input: &'input str,
-    (_, pcs, _): (usize, ::std::vec::Vec<PredicateClause>, usize),
-    (_, pc, _): (usize, PredicateClause, usize),
-) -> Vec<PredicateClause>
-{
-    {
-        let mut pcs = pcs;
-       pcs.push(pc);
-       pcs
-    }
-}
-
-#[allow(unused_variables)]
-fn __action14<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Rule, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> PredicateClause
-{
-    PredicateClause::Rule(__0)
-}
-
-#[allow(unused_variables)]
-fn __action15<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Term, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> PredicateClause
-{
-    PredicateClause::Fact(__0)
-}
-
-#[allow(unused_variables)]
-fn __action16<
-    'input,
->(
-    input: &'input str,
-    (_, tcs, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-    (_, tc, _): (usize, QueryTerm, usize),
-) -> Vec<QueryTerm>
-{
-    {
-        let mut tcs = tcs;
-        tcs.push(tc);
-        tcs
-    }
-}
-
-#[allow(unused_variables)]
-fn __action17<
-    'input,
->(
-    input: &'input str,
-    (_, c, _): (usize, Term, usize),
-    (_, _, _): (usize, &'input str, usize),
-    (_, h, _): (usize, QueryTerm, usize),
-    (_, cs, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> Rule
-{
-    Rule { head: (c, h), clauses: cs }
-}
-
-#[allow(unused_variables)]
-fn __action18<
-    'input,
->(
-    input: &'input str,
-    (_, a, _): (usize, Atom, usize),
-    (_, _, _): (usize, &'input str, usize),
-    (_, h, _): (usize, QueryTerm, usize),
-    (_, cs, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> Rule
-{
-    Rule { head: (Term::Constant(Cell::default(), Constant::Atom(a)), h),
-               clauses: cs }
-}
-
-#[allow(unused_variables)]
-fn __action19<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, &'input str, usize),
-) -> QueryTerm
-{
-    QueryTerm::Cut
-}
-
-#[allow(unused_variables)]
-fn __action20<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Var, usize),
-) -> QueryTerm
-{
-    QueryTerm::CallN(vec![Box::new(Term::Var(Cell::default(), __0))])
-}
-
-#[allow(unused_variables)]
-fn __action21<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Term, usize),
-) -> QueryTerm
-{
-    QueryTerm::Term(__0)
-}
-
-#[allow(unused_variables)]
-fn __action22<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Atom, usize),
-) -> QueryTerm
-{
-    QueryTerm::Term(Term::Constant(Cell::default(), Constant::Atom(__0)))
-}
-
-#[allow(unused_variables)]
-fn __action23<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Term, usize),
-) -> Term
-{
-    __0
-}
-
-#[allow(unused_variables)]
-fn __action24<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Atom, usize),
-) -> Term
-{
-    Term::Constant(Cell::default(), Constant::Atom(__0))
-}
-
-#[allow(unused_variables)]
-fn __action25<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Term, usize),
-) -> Term
-{
-    __0
-}
-
-#[allow(unused_variables)]
-fn __action26<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Var, usize),
-) -> Term
-{
-    Term::Var(Cell::default(), __0)
-}
-
-#[allow(unused_variables)]
-fn __action27<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, &'input str, usize),
-) -> Term
-{
-    Term::AnonVar
-}
-
-#[allow(unused_variables)]
-fn __action28<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, &'input str, usize),
-) -> Var
-{
-    __0.trim().to_string()
-}
-
-#[allow(unused_variables)]
-fn __action29<
-    'input,
->(
-    input: &'input str,
-    __lookbehind: &usize,
-    __lookahead: &usize,
-) -> ::std::vec::Vec<QueryTerm>
-{
-    vec![]
-}
-
-#[allow(unused_variables)]
-fn __action30<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    v
-}
-
-#[allow(unused_variables)]
-fn __action31<
-    'input,
->(
-    input: &'input str,
-    (_, _, _): (usize, &'input str, usize),
-    (_, __0, _): (usize, QueryTerm, usize),
-) -> QueryTerm
-{
-    (__0)
-}
-
-#[allow(unused_variables)]
-fn __action32<
-    'input,
->(
-    input: &'input str,
-    __lookbehind: &usize,
-    __lookahead: &usize,
-) -> ::std::vec::Vec<QueryTerm>
-{
-    vec![]
-}
-
-#[allow(unused_variables)]
-fn __action33<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    v
-}
-
-#[allow(unused_variables)]
-fn __action34<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, QueryTerm, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> QueryTerm
-{
-    (__0)
-}
-
-#[allow(unused_variables)]
-fn __action35<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, PredicateClause, usize),
-) -> ::std::vec::Vec<PredicateClause>
-{
-    vec![__0]
-}
-
-#[allow(unused_variables)]
-fn __action36<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<PredicateClause>, usize),
-    (_, e, _): (usize, PredicateClause, usize),
-) -> ::std::vec::Vec<PredicateClause>
-{
-    { let mut v = v; v.push(e); v }
-}
-
-#[allow(unused_variables)]
-fn __action37<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, PredicateClause, usize),
-) -> PredicateClause
-{
-    (__0)
-}
-
-#[allow(unused_variables)]
-fn __action38<
-    'input,
->(
-    input: &'input str,
-    __lookbehind: &usize,
-    __lookahead: &usize,
-) -> ::std::vec::Vec<Box<Term>>
-{
-    vec![]
-}
-
-#[allow(unused_variables)]
-fn __action39<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<Box<Term>>, usize),
-) -> ::std::vec::Vec<Box<Term>>
-{
-    v
-}
-
-#[allow(unused_variables)]
-fn __action40<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Box<Term>, usize),
-    (_, _, _): (usize, &'input str, usize),
-) -> Box<Term>
-{
-    (__0)
-}
-
-#[allow(unused_variables)]
-fn __action41<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, Box<Term>, usize),
-) -> ::std::vec::Vec<Box<Term>>
-{
-    vec![__0]
-}
-
-#[allow(unused_variables)]
-fn __action42<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<Box<Term>>, usize),
-    (_, e, _): (usize, Box<Term>, usize),
-) -> ::std::vec::Vec<Box<Term>>
-{
-    { let mut v = v; v.push(e); v }
-}
-
-#[allow(unused_variables)]
-fn __action43<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    vec![__0]
-}
-
-#[allow(unused_variables)]
-fn __action44<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-    (_, e, _): (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    { let mut v = v; v.push(e); v }
-}
-
-#[allow(unused_variables)]
-fn __action45<
-    'input,
->(
-    input: &'input str,
-    (_, __0, _): (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    vec![__0]
-}
-
-#[allow(unused_variables)]
-fn __action46<
-    'input,
->(
-    input: &'input str,
-    (_, v, _): (usize, ::std::vec::Vec<QueryTerm>, usize),
-    (_, e, _): (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    { let mut v = v; v.push(e); v }
-}
-
-#[allow(unused_variables)]
-fn __action47<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, &'input str, usize),
-    __1: (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __1.2.clone();
-    let __temp0 = __action31(
-        input,
-        __0,
-        __1,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action45(
-        input,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action48<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, ::std::vec::Vec<QueryTerm>, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, QueryTerm, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    let __start0 = __1.0.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action31(
-        input,
-        __1,
-        __2,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action46(
-        input,
-        __0,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action49<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Term, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, QueryTerm, usize),
-) -> Rule
-{
-    let __start0 = __2.2.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action29(
-        input,
-        &__start0,
-        &__end0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action17(
-        input,
-        __0,
-        __1,
-        __2,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action50<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Term, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, QueryTerm, usize),
-    __3: (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> Rule
-{
-    let __start0 = __3.0.clone();
-    let __end0 = __3.2.clone();
-    let __temp0 = __action30(
-        input,
-        __3,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action17(
-        input,
-        __0,
-        __1,
-        __2,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action51<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Atom, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, QueryTerm, usize),
-) -> Rule
-{
-    let __start0 = __2.2.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action29(
-        input,
-        &__start0,
-        &__end0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action18(
-        input,
-        __0,
-        __1,
-        __2,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action52<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Atom, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, QueryTerm, usize),
-    __3: (usize, ::std::vec::Vec<QueryTerm>, usize),
-) -> Rule
-{
-    let __start0 = __3.0.clone();
-    let __end0 = __3.2.clone();
-    let __temp0 = __action30(
-        input,
-        __3,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action18(
-        input,
-        __0,
-        __1,
-        __2,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action53<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Box<Term>, usize),
-    __1: (usize, &'input str, usize),
-) -> ::std::vec::Vec<Box<Term>>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __1.2.clone();
-    let __temp0 = __action40(
-        input,
-        __0,
-        __1,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action41(
-        input,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action54<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, ::std::vec::Vec<Box<Term>>, usize),
-    __1: (usize, Box<Term>, usize),
-    __2: (usize, &'input str, usize),
-) -> ::std::vec::Vec<Box<Term>>
-{
-    let __start0 = __1.0.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action40(
-        input,
-        __1,
-        __2,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action42(
-        input,
-        __0,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action55<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Atom, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, Box<Term>, usize),
-    __3: (usize, &'input str, usize),
-) -> Term
-{
-    let __start0 = __1.2.clone();
-    let __end0 = __2.0.clone();
-    let __temp0 = __action38(
-        input,
-        &__start0,
-        &__end0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action7(
-        input,
-        __0,
-        __1,
-        __temp0,
-        __2,
-        __3,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action56<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, Atom, usize),
-    __1: (usize, &'input str, usize),
-    __2: (usize, ::std::vec::Vec<Box<Term>>, usize),
-    __3: (usize, Box<Term>, usize),
-    __4: (usize, &'input str, usize),
-) -> Term
-{
-    let __start0 = __2.0.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action39(
-        input,
-        __2,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action7(
-        input,
-        __0,
-        __1,
-        __temp0,
-        __3,
-        __4,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action57<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, PredicateClause, usize),
-) -> ::std::vec::Vec<PredicateClause>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __0.2.clone();
-    let __temp0 = __action37(
-        input,
-        __0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action35(
-        input,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action58<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, ::std::vec::Vec<PredicateClause>, usize),
-    __1: (usize, PredicateClause, usize),
-) -> ::std::vec::Vec<PredicateClause>
-{
-    let __start0 = __1.0.clone();
-    let __end0 = __1.2.clone();
-    let __temp0 = __action37(
-        input,
-        __1,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action36(
-        input,
-        __0,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action59<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, QueryTerm, usize),
-    __1: (usize, &'input str, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __1.2.clone();
-    let __temp0 = __action34(
-        input,
-        __0,
-        __1,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action43(
-        input,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action60<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, ::std::vec::Vec<QueryTerm>, usize),
-    __1: (usize, QueryTerm, usize),
-    __2: (usize, &'input str, usize),
-) -> ::std::vec::Vec<QueryTerm>
-{
-    let __start0 = __1.0.clone();
-    let __end0 = __2.2.clone();
-    let __temp0 = __action34(
-        input,
-        __1,
-        __2,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action44(
-        input,
-        __0,
-        __temp0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action61<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, QueryTerm, usize),
-) -> Vec<QueryTerm>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __0.0.clone();
-    let __temp0 = __action32(
-        input,
-        &__start0,
-        &__end0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action16(
-        input,
-        __temp0,
-        __0,
-    )
-}
-
-#[allow(unused_variables)]
-fn __action62<
-    'input,
->(
-    input: &'input str,
-    __0: (usize, ::std::vec::Vec<QueryTerm>, usize),
-    __1: (usize, QueryTerm, usize),
-) -> Vec<QueryTerm>
-{
-    let __start0 = __0.0.clone();
-    let __end0 = __0.2.clone();
-    let __temp0 = __action33(
-        input,
-        __0,
-    );
-    let __temp0 = (__start0, __temp0, __end0);
-    __action16(
-        input,
-        __temp0,
-        __1,
-    )
-}
-
-pub trait __ToTriple<'input, > {
-    type Error;
-    fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),Self::Error>;
-}
-
-impl<'input, > __ToTriple<'input, > for (usize, (usize, &'input str), usize) {
-    type Error = ();
-    fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
-        Ok(value)
-    }
-}
-impl<'input, > __ToTriple<'input, > for Result<(usize, (usize, &'input str), usize),()> {
-    type Error = ();
-    fn to_triple(value: Self) -> Result<(usize,(usize, &'input str),usize),()> {
-        value
-    }
-}