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

20710 commits

Author SHA1 Message Date
Andy Wingo
aaa8f201e9 Update reference for GUILE_EXTENSIONS_PATH
* NEWS: Update.
* doc/ref/guile-invoke.texi (Environment Variables): Add entry.
2021-03-04 21:54:08 +01:00
Andy Wingo
579870abbc Update documentation to incorporate read-syntax
* NEWS: Update a bit.
* doc/ref/api-debug.texi (Source Properties): Mention read-syntax.
* doc/ref/api-evaluation.texi (Annotated Scheme Read): New section.
* doc/ref/api-macros.texi (Syntax Case): Update for source vectors.
2021-03-04 21:42:22 +01:00
Andy Wingo
2c3029e660 Syntax objects print with source locations
* module/system/syntax.scm (print-syntax): Print source locations.
2021-03-04 21:42:22 +01:00
Daniel Llorens
bd93eaf7cc Add docstring for array-shape 2021-03-04 14:35:50 +01:00
Andy Wingo
d904392885 Fix reading improper curly-infix expressions
* module/ice-9/read.scm (%read): A fix to last night's fix, to make
srfi-105.test pass.
2021-03-04 12:40:14 +01:00
Michael Gran
6ca3ab621c don't presume availability of gmp.pc
This suggests moving the conditional that determines if mini-gmp is used
into scmconfig.h.

* configure.ac: replace PKG_CHECK_MODULES for gmp with AC_LIB_HAVE_LINKFLAGS
    Remove ENABLE_MINI_GMP define.  Also don't run mpz_inits test for
    --enable-mini-gmp.
* libguile/gen-scmconfig.c (main) [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_I_GSC_ENABLE_MINI_GMP
* libguile/bytevectors.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/init.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/numbers.c: include scm.h
    [SCM_ENABLE_MINI_GMP]: provide mpz_inits and mpz_clears
    [ENABLE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP to ENABLE_MINI_GMP
* libguile/numbers.h: include scm.h
* libguile/random.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
* libguile/socket.c [ENABLE_MINI_GMP]: replace ENABLE_MINI_GMP
    with SCM_ENABLE_MINI_GMP
2021-03-03 14:06:29 -08:00
Andy Wingo
eb5ffda6ce Fix reading #c32 vectors
* module/ice-9/read.scm (%read): Fix a wee typo.
2021-03-03 22:59:27 +01:00
Andy Wingo
ea86a5c6d2 Fix some srfi-105 parsing errors
* module/ice-9/read.scm (%read): Fix parsing errors.
2021-03-03 22:56:58 +01:00
Andy Wingo
94279414a8 Fix length of \U hex escape in new reader
* module/ice-9/read.scm (%read): \U escape is 6 digits long.
2021-03-03 22:44:30 +01:00
Andy Wingo
a574fdf964 Remove read extension support from primitive-read
* libguile/read.c (scm_read_sharp_extension): Remove.
(scm_read_sharp): Adapt.
2021-03-03 22:30:49 +01:00
Andy Wingo
f2a2baa042 More read.c simplifications
* libguile/read.c: Use "return EXPR" instead of "return (EXPR)".  Avoid
passing around line and column info, as we don't use it any more.
2021-03-03 22:22:56 +01:00
Andy Wingo
38abf6b247 primitive-read handles only default reader options
* libguile/read.c: Remove support for all non-default reader options.
Also remove support for source positions.  The idea is that
primitive-read should just be a stripped-down, easy-to-understand reader
that is enough to bootstrap the C reader.  Probably more refactoring
will follow.
2021-03-03 22:17:16 +01:00
Andy Wingo
a1fdb76455 Scheme reader fully replaces C reader
* libguile/read.h:
* libguile/read.c (scm_primitive_read): New name for C reader.
(scm_read): Call current value of "read" variable.
(scm_init_read): Initialize "read" binding to "primitive-read".
Replaced later in boot-9.
2021-03-03 21:43:33 +01:00
Daniel Llorens
9516a10ab3 Fix bug in new array reader
* module/ice-9/read.scm (read-array): Return pair for dimension when len
  is given; single number is lbnd for list->typed-array.
* test-suite/tests/arrays.test: More test cases for the reader.
2021-03-03 18:40:39 +01:00
Andy Wingo
8edf1dc623 Read-in-scheme replaces boot "read" definition
Instead of defining a separate module, given that "read" calls are quite
all over the place, we're just going to replace the boot "read" binding
with read.scm.  This way, we'll be able to remove support for reader
options in the boot reader, as it will only ever be used for a finite
set of files.

* NEWS: Update.
* module/Makefile.am (ice-9/boot-9.go): Depend on read.scm.
(SOURCES):
* am/bootstrap.am (SOURCES): Don't build a ice-9/read.go, as we include
it.
* module/ice-9/boot-9.scm (read-syntax): Define here, as "include" now
uses it.
(read-hash-procedures, read-hash-procedure, read-hash-extend): New
procedures.  Will replace C variants.
(read, read-syntax): Include read.scm to define these.
* module/ice-9/psyntax-pp.scm (include): Regenerate.
* module/ice-9/psyntax.scm (include): Use read-syntax, so we get better
source information.
* module/ice-9/read.scm (let*-values): New local definition, to avoid
loading srfi-11.
(%read): Use list->typed-array instead of u8-list->bytevector.
* module/language/scheme/spec.scm: Remove (ice-9 read) import;
read-syntax is there in the boot environment
2021-03-03 17:08:55 +01:00
Andy Wingo
118f0c23c4 Relax srfi-105 source expectations
* test-suite/tests/srfi-105.test ("curly-infix"): For { EXPR }, allow
the source to be at the { rather than at EXPR.
2021-03-03 17:08:55 +01:00
Andy Wingo
079800d682 Fix unterminated #!...!# error message in Scheme reader
* module/ice-9/read.scm (%read): Tweak "unterminated block constant"
error to be more compatible with C reader.
2021-03-03 16:22:56 +01:00
Andy Wingo
dba7669077 Fix reading neoteric exprs in Scheme reader
* module/ice-9/read.scm (%read): Call the inner reader, not the outer
reader.
2021-03-03 16:22:56 +01:00
Andy Wingo
816c8d23a1 Fix reader extensions in Scheme reader
* module/ice-9/read.scm (%read): Fix invocation of hash procedure.
2021-03-03 16:22:56 +01:00
Andy Wingo
5ea8c69e91 Invalid charset at EOF does not cause decoding error
* libguile/ports.c (peek_iconv_codepoint): If the input has no bytes,
there's little point in raising a decoding error here.  Therefore remove
the needless iconv acquisition, harmonising with suspendable-ports.
* test-suite/tests/ports.test ("port-encoding"): Update test to include
some input so that the exception gets raised.
2021-03-03 16:22:56 +01:00
Andy Wingo
c802ed4832 Remove textual-ports include from (ice-9 read)
* module/ice-9/read.scm: We'll be loading this file early, so avoid
extraneous deps.
2021-03-03 15:08:10 +01:00
Michael Gran
54adbd6f0f improve autoconfigury for minigmp
* configure.ac: add SCM_I_GSC_ENABLE_MINI_GMP var and rename
    GUILE_MINI_GMP to ENABLE_MINI_GMP
* libguile/bytevectors (GUILE_MINI_GMP): rename to ENABLE_MINI_GMP
* libguile/gen-scmconfig.c: renamed GUILE_MINI_GMP to ENABLE_MINI_GMP.
    rename GUILE_MINI_GMP to SCM_ENABLE_MINI_GMP
* libguile/gen-scmconfig.h: add SCM_I_GSC_ENABLE_MINI_GMP
* libguile/init.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP
* libguile/numbers.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP
* libguile/numbers.h: include scmconfig.h
    rename GUILE_MINI_GMP to SCM_ENABLE_MINI_GMP
* libguile/random.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP
* libguile/socket.c [GUILE_MINI_GMP]: prefer ENABLE_MINI_GMP
* libguile.h [GUILE_MINI_GMP]: prefer SCM_ENABLE_MINI_GMP
2021-03-02 06:18:32 -08:00
Michael Gran
eb1bd8050e Enable option to prefer mini-gmp over libgmp
* configure.ac: rework gmp library detection. Add new flag.
* libguile.h: modify gmp header inclusion
* libguile/Makefile.am: add mini-gmp.[ch] files
* libguile/bytevectors.c: add mini-gmp headers
* libguile/gen-scmconfig.c: new #include variable GUILE_MINI_GMP
* libguile/init.c: add mini-gmp header
* libguile/mini-gmp.c: new file
* libguile/mini-gmp.h: new file
* libguile/numbers.c: add fallback for missing mpz_get_d_2exp
* libguile/numbers.h: yse mini-gmp header
* libguile/random.c: use mini-gmp header
* libguile/socket.c: use mini-gmp header
2021-03-02 06:18:32 -08:00
Daniel Llorens
a4a5fbced3 Fix another typo in routine reading arrays
* module/ice-9/read.scm: As stated.
* test-suite/tests/arrays.test: Test a fixed case.
2021-03-02 15:12:20 +01:00
Andy Wingo
d69062daf1 Fix bug reading arrays with lengths
* module/ice-9/read.scm (%read): Fix typo.
2021-03-02 14:29:34 +01:00
Andy Wingo
e4647a0ca8 Update NEWS
* NEWS: Start updating for new release.
2021-03-01 20:17:36 +01:00
Andy Wingo
93b82fca20 Fix Scheme read without source positions
* module/ice-9/read.scm (read): Fix annotate when positions are
disabled.
2021-02-28 20:54:40 +01:00
Andy Wingo
697f2b3ca1 Shunt syntax-sourcev to (system syntax internal)
* module/ice-9/boot-9.scm: Add syntax-sourcev to hidden bindings.
2021-02-25 21:26:43 +01:00
Andy Wingo
6c57b2af79 read-syntax uses vector source representation
* module/ice-9/read.scm (read-syntax): Switch to sourcev format.
2021-02-25 21:26:17 +01:00
Andy Wingo
18c09f0492 Psyntax uses sourcev internally
* module/ice-9/psyntax.scm: Use the vector representation of source
properties internally.  We have to convert to alists when going to
Tree-IL, but this will be in harmony with syntax objects once the reader
switches to vectors too.
* module/ice-9/psyntax-pp.scm: Regenerate.
2021-02-25 21:26:15 +01:00
Andy Wingo
7e01042337 Assembler writes vector source properties
* module/system/vm/assembler.scm (intern-constant, link-data): Write the
vector representation of source instead of the alist.  Saves a lot of
heap size, object file size, and init time when serializing syntax
objects with source.
2021-02-25 21:24:59 +01:00
Andy Wingo
07f63cf4f3 Add syntax-sourcev
* libguile/syntax.c (sourcev_to_props, props_to_sourcev)
(scm_syntax_source, scm_syntax_sourcev): Add alternate source
representation for syntax objects.
2021-02-25 21:17:36 +01:00
Andy Wingo
636ae1d510 Optimize run-time init and relocation procedure
* module/system/vm/assembler.scm (<asm>, make-assembler)
(intern-constant, emit-init-constants): Instead of loading a dependent
value each time it's needed in the relocation procedure, eagerly patch
values when they are created.  Allows keeping values in registers, which
decreases code size.
2021-02-25 16:08:02 +01:00
Andy Wingo
3fcc0eb27b Commit updates from newest autoconf
* ABOUT-NLS:
* build-aux/config.rpath: These files were overwritten by
re-bootstrapping with the newest autoconf.  OK computer!
2021-02-25 16:08:02 +01:00
Andy Wingo
03448b289d Read Scheme via read-syntax
* module/language/scheme/spec.scm: Use read-syntax.
* test-suite/tests/dwarf.test: Adapt expected source locations.
* am/bootstrap.am (SOURCES): Add ice-9/read.
2021-02-25 16:07:47 +01:00
Andy Wingo
a758ba075a Fix read-syntax on vectors and arrays
* module/ice-9/read.scm (%read): Strip annotations from reading
the array elements.
2021-02-25 16:07:47 +01:00
Andy Wingo
0cc7991855 Ensure that (syntax ()) results in ()
* module/ice-9/psyntax.scm: Add a special case for ().  There are
already special cases for pairs, vectors, etc; the issue is that with
read-syntax, the () might be come into psyntax as an annotated syntax
object, which here we would want to strip, to preserve the invariant to
psyntax users that all lists are unwrapped.
2021-02-25 09:33:15 +01:00
Andy Wingo
9ade45097c Fix module scoping for datum->syntax with no identifier
* module/ice-9/psyntax.scm: With the new behavior of datum->syntax which
allows #f for the lexical context, we have the question of what module
to attach to these newly created syntax objects.  In that case we'll
mark down #f as the module, indicating that we know nothing.  We have to
extend a number of other cases to default to the expander's idea of the
current module, if a syntax object has no module scope.

Also, change datum->syntax to attach the empty wrap, not the top wrap.
Attaching the top wrap leads to multiply applying the top mark, as you
recurse into subexpressions.
2021-02-24 20:38:14 +01:00
Andy Wingo
e054504fd4 Remove top-marked? optimization from psyntax
* module/ice-9/psyntax.scm (strip): It used to be that terms in the
source program could have a "top" mark, and when stripping marks we'd
stop recursing when we see an expression with the top mark.  This had
the good effect that source programs could contain quoted syntax
objects, or quoted objects with shared structure -- in theory anyway.
In practice the compiler didn't support objects with shared structure.
Anyway when we switch to "read-syntax", quoted expressions can contain
syntax objects introduced by the reader, which naturally we would want
to strip away in a (quote FOO) form.  Therefore we remove the
top-marked? optimization.
2021-02-24 16:01:02 +01:00
Andy Wingo
1711608f15 Add quote-syntax
* module/ice-9/psyntax.scm (quote-syntax): New core form.  Usually the
  expander will unwrap all syntax objects from the input term.  However
  sometimes you want to preserve a syntax object, as a datum.  That's
  when you want quote-syntax.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/local-eval.scm (identifier-syntax-from-box): Use
  quote-syntax instead of our datum->syntax trick, which relied on
  psyntax's special treatment of the top mark.
2021-02-24 12:02:35 +01:00
Andy Wingo
a04a024f20 Implement read-syntax
* doc/ref/api-macros.texi (Syntax Case): Update documentation for
  datum->syntax.
* module/ice-9/psyntax.scm (datum->syntax): Use #:source keyword for
  source location info instead of an optional, and allow an alist.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/read.scm (%read, read): Refactor to allow read and
  read-syntax to share an implementation.
  (read-syntax): New function.
2021-02-21 22:09:41 +01:00
Andy Wingo
1bba859000 Document datum->syntax extensions
* doc/ref/api-macros.texi (Syntax Case): Document that template-id can
  be false, and document srcloc.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (syntax?): Allow the lexical context to be
  null.  Allow srcloc to be a source properties alist.  Inspired by
  Racket.
2021-02-21 11:35:12 +01:00
Andy Wingo
50d3dd83f0 Adapt uses of make-syntax to preserve syntax
* module/ice-9/psyntax.scm (datum->syntax): Add an additional optional
  argument, to allow callers to provide source annotation information.
* module/ice-9/psyntax-pp.scm: Regenerate.
2021-02-21 11:13:20 +01:00
Andy Wingo
3d8397c11d psyntax preserves source via syntax objects
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/psyntax.scm (wrap, source-wrap): Preserve source via
  syntax objects.
2021-02-21 11:05:27 +01:00
Andy Wingo
2edf91d51c Syntax objects have "source" field
* libguile/syntax.c (scm_make_syntax): Add optional "source" argument.
  Note that this function is internal.
  (scm_syntax_source): New function, replacing definition in boot-9.scm.
* libguile/syntax.h: Add new declarations.
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm (source-annotation): For syntax objects, the
  source annotation comes direct from the syntax object.
* module/system/vm/assembler.scm (link-data, intern-constant): Write
  5-word syntax objects.
2021-02-20 20:19:34 +01:00
Andy Wingo
064b394d5a Use lists instead of string ports to accumulate results
* module/ice-9/read.scm (read): Use lists, like read-delimited does.
  About 30% faster.
2021-02-17 15:50:10 +01:00
Andy Wingo
7244461a11 Fix read.scm bugs related to nonstandard reader options
* module/ice-9/read.scm (compute-reader-options): Fix handling of reader
  options, inline and otherwise.
2021-02-17 15:24:34 +01:00
Andy Wingo
6353b448cc Improve read error reporting
* module/ice-9/read.scm (read): Issue properly formatted read-errors, as
  users expect.
2021-02-17 14:54:53 +01:00
Andy Wingo
71e53d73fe Scheme read respects "positions" reader option
* module/ice-9/read.scm (read): Don't add source positions if the option
  is off.
2021-02-17 12:14:15 +01:00
Andy Wingo
beac6a3e29 More read micro-optimizations
* module/ice-9/read.scm (read): Use R5RS read-char, peek-char,
  write-char rather than (ice-9 textual-ports) wrappers, because the
  latter are expressed in terms of the former.
2021-02-17 12:10:57 +01:00