summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--match.c3
-rw-r--r--match.h2
-rw-r--r--parser.y4
-rw-r--r--txr.134
4 files changed, 41 insertions, 2 deletions
diff --git a/match.c b/match.c
index 60b5a6df..6fda6f19 100644
--- a/match.c
+++ b/match.c
@@ -60,7 +60,7 @@ val mingap_k, maxgap_k, gap_k, mintimes_k, maxtimes_k, times_k;
val lines_k, chars_k;
val text_s, choose_s, gather_s, do_s, mdo_s, mod_s, modlast_s;
val line_s, data_s, fuzz_s, load_s;
-val include_s, close_s, require_s;
+val include_s, close_s, require_s, in_package_s;
val longest_k, shortest_k, greedy_k;
val vars_k, resolve_k;
val append_k, into_k, var_k, list_k, tlist_k, string_k, env_k, counter_k;
@@ -4689,6 +4689,7 @@ static void syms_init(void)
include_s = intern(lit("include"), user_package);
close_s = intern(lit("close"), user_package);
require_s = intern(lit("require"), user_package);
+ in_package_s = intern(lit("in-package"), user_package);
longest_k = intern(lit("longest"), keyword_package);
shortest_k = intern(lit("shortest"), keyword_package);
greedy_k = intern(lit("greedy"), keyword_package);
diff --git a/match.h b/match.h
index 9894ecff..35e7cd05 100644
--- a/match.h
+++ b/match.h
@@ -25,7 +25,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-extern val text_s, choose_s, gather_s, do_s, mdo_s, require_s;
+extern val text_s, choose_s, gather_s, do_s, mdo_s, require_s, in_package_s;
extern val close_s, load_s, include_s, mod_s, modlast_s, line_s;
extern val counter_k, vars_k, env_k, var_k, into_k, named_k;
val match_expand_keyword_args(val elem);
diff --git a/parser.y b/parser.y
index 6615a3e7..9f628227 100644
--- a/parser.y
+++ b/parser.y
@@ -1676,6 +1676,10 @@ static val check_parse_time_action(val spec_rev)
eval_intrinsic(cons(progn_s, cdr(elem)), nil);
return nil;
}
+ if (sym == in_package_s) {
+ eval_intrinsic(elem, nil);
+ return nil;
+ }
}
}
return spec_rev;
diff --git a/txr.1 b/txr.1
index 50bb99c2..98c0f37b 100644
--- a/txr.1
+++ b/txr.1
@@ -3276,6 +3276,12 @@ The
directive evaluates \*(TL expressions immediately, during the parsing
of the \*(TX syntax in which it occurs.
+.coIP @(in-package)
+The
+.code in-package
+directive is used to switch to a different symbol package.
+It mirrors the \*(TL macro of the same name.
+
.PP
.SS* Subexpression Evaluation
@@ -6580,6 +6586,34 @@ can be used as a horizontal or vertical directive, whereas
.code mdo
is only vertical.
+.dir in-package
+
+The
+.code in-package
+directive shares the same syntax and semantics as the \*(TL macro
+of the same name:
+
+.cblk
+.mets (in-package << name )
+.cble
+
+The
+.code in-package
+directive is evaluated immediately upon being parsed,
+leaving no trace in the syntax tree of the surrounding \*(TX
+query.
+
+It causes the
+.code *package*
+special variable to take on the package denoted by
+.metn name .
+
+The directive that
+.meta name
+is either a string or symbol. An error exception is thrown if
+this isn't the case. Otherwise it searches for the package.
+If the package is not found, an error exception is thrown.
+
.SS* Blocks
.NP* Overview