1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00
Commit graph

1348 commits

Author SHA1 Message Date
Hannes Müller
5abb24efe4
Fix make-custom-port in case encoding is #f
* module/ice-9/custom-ports.scm (make-custom-port): Code fails if
(fluid-ref %default-port-encoding) returns #f. In fact this was the
case why readline support on MSYS2 failed for guile 3.0.10, ref.
https://github.com/msys2/MSYS2-packages/issues/5079
But later used canonicalize-encoding is prepared to handle #f for
encoding. So allow encoding to also handle this case.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2025-02-28 22:12:03 +01:00
Ekaitz Zarraga
38ad264979
PEG: string-peg: Better support for escaping.
* module/ice-9/peg/string-peg.scm (peg-as-peg): Augment with rules for
hexadecimal digits, “\uXXX” for characters, “\t” for tabs, etc.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-22 22:14:12 +01:00
Ekaitz Zarraga
c86a48a92f
PEG: string-peg: Fix [^...] interpretation.
* module/ice-9/peg/string-peg.scm (NotInClass->defn): Adjust.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-22 22:14:04 +01:00
Adam Faiz
c2829e4a86 New line or field iteration procedures in (ice-9 rdelim)
* NEWS: Update
* module/ice-9/rdelim (for-rdelim-from-port, for-delimited-from-port,
  for-line-in-file): New procedures.
* doc/ref/api-io.texi: Documentation of `for-rdelim-for-port`-related
  procedures.
* test-suite/tests/rdelim.test: Tests for `for-rdelim-for-port`-related
  procedures.

Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
2024-12-19 22:36:38 +01:00
Ekaitz Zarraga
25504ba216
PEG: Add support for not-in-range and [^...]
Modern PEG supports inversed class like `[^a-z]` that would get any
character not in the `a-z` range. This commit adds support for that and
also for a new `not-in-range` PEG pattern for scheme.

* module/ice-9/peg/codegen.scm (cg-not-in-range): New function.
* module/ice-9/peg/string-peg.scm: Add support for `[^...]`
* test-suite/tests/peg.test: Test it.
* doc/ref/api-peg.texi: Document accordingly.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-09 18:15:01 +01:00
Ekaitz Zarraga
ff11753df1
PEG: Add full support for PEG + some extensions
This commit adds support for PEG as described in:

    <https://bford.info/pub/lang/peg.pdf>

It adds support for the missing features (comments, underscores in
identifiers and escaping) while keeping the extensions (dashes in
identifiers, < and <--).

The naming system tries to be as close as possible to the one proposed
in the paper.

* module/ice-9/peg/string-peg.scm: Rewrite PEG parser.
* test-suite/tests/peg.test: Fix import

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-12-09 18:13:08 +01:00
Mikael Djurfeldt
47807c9b11 Temporarily revert commit 7379049d3 (to make Guile bootstrap) 2024-12-06 10:26:29 +01:00
Andy Wingo
c51fcfffb6 psyntax: simplify free-id=?
* module/ice-9/psyntax.scm (free-id=?): Simplify.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-25 11:46:58 +01:00
Andy Wingo
2f175f3453 psyntax: Cosmetic change to overriden globals
* module/ice-9/psyntax.scm (define/override, define*/override): Use
instead of set! on globals.
($sc-dispatch): Renest.  Will compile to the same thing as before.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-20 15:55:44 +01:00
Andy Wingo
2395f3b74c psyntax: Reorder global-extend
* module/ice-9/psyntax.scm (global-extend): Put at the beginning.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 14:40:25 +01:00
Andy Wingo
81645a25d3 psyntax: Typo fix
* module/ice-9/psyntax.scm: Fix comment typo.
2024-11-19 14:37:32 +01:00
Andy Wingo
6788bb4564 psyntax: Cosmetic change
* module/ice-9/psyntax.scm (build-simple-lambda): Reflow.
2024-11-19 14:36:07 +01:00
Andy Wingo
a14948be2f psyntax: Clean up sourcev/src namings
* module/ice-9/psyntax.scm: Look forward to the all-sourcev world by
just naming things "src".
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 14:30:49 +01:00
Andy Wingo
2f684989e1 psyntax: Simplify output constructors.
* module/ice-9/psyntax.scm: Eta-reduce build-void, build-call, et al.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 14:23:47 +01:00
Andy Wingo
7379049d30 psyntax: Factor module-variable use to helpers
* module/ice-9/psyntax.scm (resolve-module*, resolve-variable): New
helpers.
(free-id=?, resolve-identifier): Use new helpers.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 11:58:23 +01:00
Andy Wingo
5ddb366375 psyntax: Remove stale analyze-variable case
* module/ice-9/psyntax.scm (analyze-variable): Remove "bare" case, long
gone.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-19 09:59:15 +01:00
Andy Wingo
cdf8473b19 psyntax: Separate core expanders from their installation
* module/ice-9/psyntax.scm (expand-let, expand-letrec, ...): Name these
expanders, then install them.  Allows for better code evolution and
decreases the indent.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 16:53:41 +01:00
Andy Wingo
6c4f9a58c9 psyntax: Remove pre-3.0 hack about syntax transformer bindings.
* module/ice-9/psyntax.scm (resolve-identifier): Remove "transformer is
a pair" case.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 16:00:23 +01:00
Andy Wingo
527b4498a8 psyntax: Simplify to first-order bindings. NFC
* module/ice-9/psyntax.scm (no-source, make-empty-ribcage): Make normal
bindings, not macros.
2024-11-18 15:59:06 +01:00
Andy Wingo
522b0b4510 psyntax: Match when rebuilding macro output
* module/ice-9/psyntax.scm (expand-macro): Use match.
(eval-local-transformer): Use unless for side effect.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 15:08:18 +01:00
Andy Wingo
b4aebbd7a5 psyntax: Cleanups; ensure order of top-level expansion
* module/ice-9/psyntax.scm (build-lexical-reference): No "type"
parameter.  Adapt callers.
(valid-bound-ids?, distinct-bound-ids?, bound-id-member?): Use match.
(expand-sequence, expand-top-sequence): Use match.  For
expand-top-sequence, ensure that both phases of expansion are run in
order; was the case before, but by accident.  Don't accumulate results
in reverse.
(parse-when-list): Use match.
2024-11-18 11:15:15 +01:00
Andy Wingo
12afcc74fb psyntax: Simplify locally-bound-identifiers
* module/ice-9/psyntax.scm (locally-bound-identifiers): Simplify to use
match and scope.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:21:41 +01:00
Andy Wingo
54c8901adc psyntax: Simplify id-var-name
* module/ice-9/psyntax.scm (id-var-name): No need for `search` to return
the marks.  Simplify to use scope instead of repeating, and use match.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:11:53 +01:00
Andy Wingo
14414655d3 psyntax: Fix bug introduced in 0295409483
* module/ice-9/psyntax.scm (analyze-variable): Fix erroneous pattern
matching.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-18 10:07:50 +01:00
Andy Wingo
2daea40200 psyntax: Use new `match' instead of cdadring
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Use `match' more.  Also use more first-order
definitions.  NFC.
2024-11-15 15:35:10 +01:00
Andy Wingo
0295409483 psyntax: Use new `match' instead of cdadring
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm: Use `match' more.  NFC.
2024-11-15 14:27:27 +01:00
Andy Wingo
d94292724b psyntax: Add simple pattern matcher
* module/ice-9/psyntax.scm (simple-match1, simple-match-pat,
simple-match-patv, match): Add simple pattern matcher.
* module/ice-9/psyntax-pp.scm: Regenerate.  Just different renumbering
of temps.
2024-11-15 14:16:20 +01:00
Andy Wingo
d30b39e4ea psyntax: Avoid lambda in procedure definitions
* module/ice-9/psyntax.scm: Instead of e.g. (define foo (lambda (x)
  ...)), do (define (foo x) ...).  No functional change.
2024-11-15 14:06:32 +01:00
Andy Wingo
4f05d1709b psyntax: Remove a useless level of let
* module/ice-9/psyntax.scm: Remove let around the body.
2024-11-15 13:57:57 +01:00
Andy Wingo
3b230745fe psyntax: Inline the single use of define-structure
* module/ice-9/psyntax.scm (define-structure): Remove, inline into use.
No predicate needed.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-15 13:56:04 +01:00
Andy Wingo
8c78234e80 psyntax: Functional annotation of function names
* module/ice-9/psyntax.scm (maybe-name-value): Return a fresh lambda
instead of mutating the given lambda.
(define-expansion-accessors): No need to define setters.
2024-11-14 16:54:25 +01:00
Andy Wingo
f376e6445d psyntax: Clean up use of fx+, etc
* module/ice-9/psyntax.scm (fx+, fx-, fx=): Remove.  Replace uses with
1+, 1-, =.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:11:51 +01:00
Andy Wingo
dd18780fb8 psyntax: Rename top-level-eval, local-eval
* module/ice-9/psyntax.scm (top-level-eval, local-eval): Rename from
top-level-eval-hook, local-eval-hook.  Adapt callers.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:02:20 +01:00
Andy Wingo
d60aeb3ced psyntax: Use vectors instead of gensyms for labels, marks
* module/ice-9/psyntax.scm (gen-unique): Instead of making a string with
an embedded hex counter, make a vector.  A little less work than making
a string, and slightly smaller binaries.
(gen-label, gen-mark): Use gen-unique.
(resolve-identifier): Adapt case that recognizes labels denoting
lexicals to be less strict.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 16:00:18 +01:00
Andy Wingo
70e2616975 psyntax: Remove useless gen-label invocations
* module/ice-9/psyntax.scm (expand-top-sequence): Remove needless
gen-label uses, and replace one use with gen-lexical (which is what is
needed).
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 15:46:05 +01:00
Andy Wingo
ebbb10c92d psyntax: Clean up lexical gensym creation
* module/ice-9/psyntax.scm (gen-lexical): Add a nice comment.  Rename
from build-lexical-var, and remove unused src argument.
(gen-var, generate-temporaries): Use gen-lexical.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-11-14 15:34:15 +01:00
Arne Babenhauserheide
c0bfa3219c fix typo in comment
module/ice-9/command-line.scm (compile-shell-switches): fix typo
2024-10-12 14:07:02 +02:00
Matthew Wette
78e9e51065 Redirect diagnostice output messages (e.g., auto-compiling code) to a newly defined current-info-port, and add a command line argument -I' to set the current-info-port to a void-port. * libguile/ports.c: add cur_infoport_fluid, scm_current_info_port, scm_set_current_info_port; define default current-info-port to stderr * libguile/load.c(compiled_is_fresh,load_thunk_from_path, do_try_auto_compile,scm_sys_warn_auto_compilation_enabled, scm_primitive_load_path): direct output messages to current_info_port; was current_warning_port * libguile/init.c(scm_init_standard_ports): set default current_info_port * module/ice-9/ports.scm: define current-info-port and set-current-info-port * module/ice-9/command-line.scm(*usage*,compile-shell-switches): add argument -I' to silence diagnostics (or current-info-port to void-port) * doc/ref/guile-invoke.texi: add description for `-I' command argument 2024-10-12 13:16:25 +02:00
Andy Wingo
a970ed5bd5 Update psyntax copyright notice
* module/ice-9/psyntax.scm: Use the newer LGPLv3 header.  Add FSF
copyright lines for each year the file was modified.  Remove inline
changelogs.  Remove some comments describing psyntax in other Scheme
implementations.
2024-08-26 09:51:53 +02:00
Maxim Cournoyer
522f368719 bug#71304: [PATCH] Add support for 'else' clause in R7RS cond-expand.
* module/ice-9/r7rs-libraries.scm (define-library)
<handle-cond-expand>: Add a pattern to match an 'else' clause.

Series-to: bug-guile@gnu.org
2024-07-01 23:38:01 +02:00
Andy Wingo
1120efe375 Fix race in check-guile to make needless guile-procedures symlink
* check-guile.in (top_srcdir): Don't try to make guile-procedures.tx, as
this races with multiple checkers, and it's gross.
* meta/uninstalled-env.in (GUILE_DOCSTRINGS_PATH): Instead when
uninstalled, use this variable.
* module/ice-9/documentation.scm (documentation-files): Remove the
current directory from the search path for documentation files; this was
always a hack.  Instead allow GUILE_DOCSTRINGS_PATH to override the
built-in search path.
2024-06-23 11:13:18 +02:00
Andy Wingo
8b324bef74 Remove dead code in resolve-interface
* module/ice-9/boot-9.scm (resolve-interface): Remove dead code.
2024-06-20 13:51:59 +02:00
Ludovic Courtès
461ff313fa
Rewrite ‘get-bytevector-all’ in Scheme.
* libguile/r6rs-ports.c (get_bytevector_all_var): New variable.
(init_bytevector_io_vars): New function.
(scm_get_bytevector_all): Rewrite as a proxy to ‘get-bytevector-all’
from (ice-9 binary-port).
* module/ice-9/binary-ports.scm (get-bytevector-all): New procedure.
* NEWS: Update.

Reported-by: Christopher Baines <mail@cbaines.net>
2024-06-16 15:05:09 +02:00
Michael Käppler
80d4055e42
Fix error messages containing format strings
The builtin primitive procedure `error` takes an optional message and
a list of arguments to include into the error message.
These args are formatted with `~S` and appended to the error message, so
that an example call of

`(error "Wrong argument: " 42)`

results in the output

"Wrong argument: 42"

If format strings occur in the message itself, however, they are
escaped. Thus a call like

`(error "Wrong argument: ~a" 42)`

is rendered as

"Wrong argument: ~a 42"

Some callers did not take this behavior into account, leading to
confusing error messages.
Changing the behavior of `error` to be
both backwards-compatible and accept also format strings inside messages
is not straightforward, because it would have to handle escaped `~`
characters as well. Therefore, fix `error` call sites using format
strings to use `format` before calling out to `error`.

The following files are affected:

* module/ice-9/format.scm (format)
* module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface)
* module/oop/goops.scm (make)
* module/srfi/srfi-37.scm (Comment at the beginning of file)
* module/system/base/compile.scm (call-once)
* module/system/repl/command.scm (break, tracepoint)
* module/system/repl/common.scm (repl-default-options)
* module/system/vm/traps.scm (arg-check, trap-at-source-location)

There are a couple of further call sites that were left unchanged,
either because they are using their own `error` procedure:

* module/ice-9/read.scm
* module/ice-9/command-line.scm

or are not referenced from other modules:

* module/system/base/lalr.upstream.scm:
* module/sxml/upstream/assert.scm:
* module/sxml/sxml-match.ss:

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Morgan Smith
f27e8b855f
Fix typos throughout codebase.
* NEWS:
* doc/ref/api-control.texi:
* doc/ref/api-data.texi:
* doc/ref/api-debug.texi:
* doc/ref/api-deprecated.texi:
* doc/ref/api-evaluation.texi:
* doc/ref/api-foreign.texi:
* doc/ref/api-i18n.texi:
* doc/ref/api-io.texi:
* doc/ref/api-languages.texi:
* doc/ref/api-macros.texi:
* doc/ref/api-memory.texi:
* doc/ref/api-modules.texi:
* doc/ref/api-options.texi:
* doc/ref/api-peg.texi:
* doc/ref/api-procedures.texi:
* doc/ref/api-scheduling.texi:
* doc/ref/api-undocumented.texi:
* doc/ref/api-utility.texi:
* doc/ref/expect.texi:
* doc/ref/goops.texi:
* doc/ref/misc-modules.texi:
* doc/ref/posix.texi:
* doc/ref/repl-modules.texi:
* doc/ref/scheme-ideas.texi:
* doc/ref/scheme-scripts.texi:
* doc/ref/srfi-modules.texi:
* gc-benchmarks/larceny/dynamic.sch:
* gc-benchmarks/larceny/twobit-input-long.sch:
* gc-benchmarks/larceny/twobit.sch:
* libguile/gc.h:
* libguile/ioext.c:
* libguile/list.c:
* libguile/options.c:
* libguile/posix.c:
* libguile/threads.c:
* module/ice-9/boot-9.scm:
* module/ice-9/optargs.scm:
* module/ice-9/ports.scm:
* module/ice-9/pretty-print.scm:
* module/ice-9/psyntax.scm:
* module/language/elisp/parser.scm:
* module/language/tree-il/compile-bytecode.scm:
* module/srfi/srfi-37.scm:
* module/srfi/srfi-43.scm:
* module/statprof.scm:
* module/texinfo/reflection.scm:
* test-suite/tests/eval.test:
* test-suite/tests/fluids.test:
Fix typos.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-05-06 11:51:53 +02:00
Ludovic Courtès
696acfc9e5
‘seek’ now accepts ‘SEEK_DATA’ and ‘SEEK_HOLE’ where supported.
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through.
(scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’.
* module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when
defined.
* test-suite/tests/ports.test ("size of sparse file")
("SEEK_DATA while on data", "SEEK_DATA while in hole")
("SEEK_HOLE while in hole"): New tests.
* NEWS: Update.
2024-04-15 19:58:25 +02:00
Nikita Domnitskii
025bb024ae eval-string: set port column to column, not line
* module/ice-9/eval-string.scm: set column to column, not line.
2024-04-05 17:51:33 -05:00
Andy Wingo
9e0f03c5fd Macro-introduced top-level vars scope to their module even if unbound
* module/ice-9/psyntax.scm (analyze-variable): Previously, a reference
to a top-level variable in a module other than the current module would
be silently rewritten to reference the current module, if the variable
was unbound in its original module.  This was a hack from the early days
of when we extended psyntax to know about the module system.  Fix to
properly use the scope of the introduced binding instead of the scope of
the macro use site.
* test-suite/tests/syntax.test ("macro-introduced cross-module unbound
identifiers"): Add test.
* module/ice-9/psyntax-pp.scm: Regenerate.
2024-02-20 14:15:12 +01:00
Andy Wingo
2717773bb1 Regenerate psyntax-pp.scm
* module/ice-9/psyntax-pp.scm (syntax?): Regenerate.  With the modified
pretty-printer, things are a bit different.
2024-02-20 14:15:12 +01:00
Jonas Hahnfeld
fb1f5e28b1
Match on correct argument in make-custom-port
* module/ice-9/custom-ports.scm (make-custom-port): Match on correct
argument for conversion strategy.
* NEWS: Update.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2024-01-29 14:44:58 +01:00