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

217 commits

Author SHA1 Message Date
Andy Wingo
1ace4fbf3d add syntax-module
* module/ice-9/psyntax.scm (syntax-module): New accessor for syntax
  objects.
* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/boot-9.scm: Declare syntax-module.

* doc/ref/api-macros.texi: Document it.
2012-01-25 20:34:17 +01:00
Andy Wingo
3d51e57cfb add syntax-locally-bound-identifiers
* module/ice-9/boot-9.scm (syntax-locally-bound-identifiers): Declare
  variable.
* module/ice-9/psyntax.scm: Add locally-bound-identifiers helper, and
  define syntax-locally-bound-identifiers.
* module/ice-9/psyntax-pp.scm: Regenerated.
* doc/ref/api-macros.texi: Document the new procedure.
2012-01-25 20:34:16 +01:00
Andy Wingo
7d02e25661 avoid gensym when making labels in psyntax
* module/ice-9/psyntax.scm (gen-label): Avoid gensym, as we don't need
  to make symbols.

* module/ice-9/psyntax-pp.scm: Regenerate.
2012-01-19 13:08:19 +01:00
Andy Wingo
9b0975f1dc add syntax-local-binding
* module/ice-9/boot-9.scm (syntax-local-binding): New binding.

* module/ice-9/psyntax.scm: Locally define a fluid that holds the
  "transformer environment".  with-transformer-environment calls a
  procedure with the transformer environment, or raises an error if
  called outside the extent of a transformer.  Bind
  transformer-environment in expand-macro.
  (resolve-identifier): Backport this helper from master.
  (syntax-local-binding): New procedure to return binding information of
  a bound identifier (a lexical, macro, a pattern variable, a displaced
  lexical, a global, or some other form).

* module/ice-9/psyntax-pp.scm: Regenerate.

* doc/ref/api-macros.texi (Syntax Transformer Helpers): Add docs for
  syntax-local-binding, and syntax-source, and move some other
  descriptions to this new section.
2012-01-19 12:38:27 +01:00
Andy Wingo
0bdd43515e Merge commit 'f78a1ccede' 2012-01-10 00:23:49 +01:00
Andy Wingo
bbc2364a3e Merge commit 'cc8afa2b36'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il/peval.scm
2012-01-10 00:21:48 +01:00
Andy Wingo
449bf60b81 deprecate fluid-let-syntax in favor of syntax-parameterize
* module/ice-9/psyntax.scm (syntax-parameterize): Rename from
  fluid-let-syntax.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/boot-9.scm (define-inlinable): Use syntax-parameterize
  (and define-syntax-parameter).

* module/ice-9/deprecated.scm (fluid-let-syntax): Add deprecated shim.
2012-01-06 19:36:58 +01:00
Andy Wingo
286dc5e1c3 add define-syntax-parameter, same as define-syntax
* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
  Will be used to implement syntax parameters, following Barzilay,
  Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
  syntax-parameterize".  Adds a new binding type and definition form.

Conflicts:

	module/ice-9/psyntax.scm
2012-01-06 19:26:47 +01:00
Ludovic Courtès
b3da54d181 Placate a number of `syntax-check' verifications.
- "filesystem" -> "file system"
  - remove doubled words
  - use EXIT_* macros instead of literal numbers
  - update `syntax-check' exclusion files
2012-01-05 23:38:10 +01:00
Ludovic Courtès
f78a1ccede Raise an error for (begin) when `--disable-deprecated'.
* module/ice-9/psyntax.scm (define-expansion-constructors)[begin-form]:
  Emit a syntax-violation error for empty sequences when
  --disable-deprecated.

* test-suite/tests/syntax.test (pass-if-syntax-error): Fix typo in error
  message.
2012-01-05 22:38:06 +01:00
Andy Wingo
dc65d1cf5b document invalidity of (begin) as expression; add back-compat shim
* doc/ref/api-control.texi (begin): Update to distinguish between
  splicing begin and sequencing begin.

* module/ice-9/psyntax.scm (expand-expr): Add a back-compatibility shim
  for `(begin)'.
* module/ice-9/psyntax-pp.scm: Regenerate.

* test-suite/tests/syntax.test: Update to run illegal (begin) test only
  if we are not including deprecated features.
2011-12-21 20:14:59 -05:00
Andy Wingo
b2208d2e98 Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
	configure.ac
	libguile/fluids.c
	libguile/gc.c
	libguile/gc.h
	libguile/objcodes.c
	libguile/procprop.c
	libguile/vm.c
	module/ice-9/psyntax-pp.scm
	module/ice-9/psyntax.scm
2011-12-01 23:31:50 +01:00
Andy Wingo
440ac793c4 eval-when tidying up
* module/ice-9/psyntax.scm: Rename expand-when-list to parse-when-list,
  and simplify to compare literal values.
* module/ice-9/psyntax-pp.scm: Regenerate.
2011-11-16 20:15:26 +01:00
Andy Wingo
78a474558a psyntax: s/chi/expand/g
* module/ice-9/psyntax.scm: Rename all instances of "chi" to "expand".
  Addded a hack to expand-eval-when that will be fixed later.
* module/ice-9/psyntax-pp.scm: Regenerated.
2011-11-16 20:08:40 +01:00
Andy Wingo
de41e56492 hygienically rename macro-introduced bindings, reproducibly
* module/ice-9/psyntax.scm (chi-top-sequence): Detect bindings to
  identifiers introduced by macros.  In that case, in order to preserve
  hygiene, uniquify the variable's name, but in a way that is
  reproduceable (i.e., yields the same uniquified name after a
  recompile).
2011-11-07 11:45:15 +01:00
Andy Wingo
47e9919d22 resolve-identifier for toplevel definitions resolves by module
* module/ice-9/psyntax.scm (id-var-name): For mapping identifiers to
  toplevel definitions, also compare against the module.
  (resolve-identifier): Pass the module to id-var-name when looking up
  identifiers.
  (free-id=?): Adapt to id-var-name change.
  (chi-top-sequence): When adding a mapping from the given identifier
  to a toplevel definition, make the name be a pair.
2011-11-07 11:42:29 +01:00
Andy Wingo
19ef14f9b8 defined identifiers scoped in the current module
* ice-9/psyntax.scm (chi-top-sequence): Wrap defined identifiers with
  the current module.  Fixes http://savannah.gnu.org/bugs/?31472.
2011-11-07 11:39:05 +01:00
Andy Wingo
5b36d6034b syntax parameters implemented properly
* module/ice-9/psyntax.scm (resolve-identifier): Take an additional
  argument, indicating whether syntax parameters should be resolved or
  not.  Just return three values: the binding type and value, and the
  module for resolving toplevels.
  (chi-install-global): Take an extra arg, the type.  If we are defining
  a syntax parameter, construct a pair for the binding.
  (chi-body): Syntax parameters now use a per-parameter unique value (a
  pair) as a key in the expansion-time environment `r'.
  (syntax-parameterize): Don't allow parameterization of
  non-parameters.  This is an incompatible change, but it is for the
  better; you don't want to allow users to parameterize `lambda', after
  all.
2011-11-07 11:39:04 +01:00
Andy Wingo
ea3ca4e4d0 syntax-parameterize, not fluid-let-syntax
* module/ice-9/psyntax.scm (syntax-parameterize): Rename from
  fluid-let-syntax.

* module/ice-9/boot-9.scm (define-inlinable): Use syntax-parameterize
  (and define-syntax-parameter).
2011-11-07 11:38:47 +01:00
Andy Wingo
c2d822de19 add define-syntax-parameter, same as define-syntax
* module/ice-9/psyntax.scm (define-syntax-parameter): New toplevel form.
  Will be used to implement syntax parameters, following Barzilay,
  Culpepper, and Flatt's 2011 SFP workshop paper, "Keeping it Clean with
  syntax-parameterize".  Adds a new binding type and definition form.
2011-11-07 11:38:47 +01:00
Andy Wingo
c070de6345 psyntax: resolve-identifier refactor
* module/ice-9/psyntax.scm (id-var-name): Add a nice long comment.
  (lookup): Remove, as it is no longer used.
  (resolve-identifier): New helper, replaces most uses of id-var-name
  then `lookup'.
  (syntax-type, syntax, set!, fluid-let-syntax): Adapt to use
  resolve-identifier.
  (free-id=?): Adapt to id-var-name returning syntax objects.
2011-11-07 11:38:40 +01:00
Andy Wingo
45f584674a chi-top-sequence refactor
* module/ice-9/psyntax.scm (chi-top-sequence): Reimplement, more like
  chi-body.  Instead of adding empty definitions to the toplevel, add
  toplevel definitions to the wrap shared by all forms in the sequence.
2011-11-04 15:52:40 +01:00
Andy Wingo
f698b7286f minor psyntax refactors
* module/ice-9/psyntax.scm (syntax-type): Remove redundant lexical
  case.
  (syntax-rules, define-syntax-rule): Use `_' instead of `dummy' for the
  keyword.

* module/ice-9/boot-9.scm (define-syntax-rule): Remove redundant
  definition.
2011-11-04 14:12:35 +01:00
Andy Wingo
148dfc2409 refactor chi-top-sequence
* module/ice-9/psyntax.scm (chi-top-sequence): Refactor slightly.
* module/ice-9/psyntax-pp.scm: Regenerate.
2011-10-28 12:14:00 +02:00
Andy Wingo
ca12824581 Merge remote-tracking branch 'origin/stable-2.0'
This was a pretty big merge involving a fair amount of porting,
especially to peval and its tests.  I did not update psyntax-pp.scm,
that comes in the next commit.

Conflicts:
	module/ice-9/boot-9.scm
	module/ice-9/psyntax-pp.scm
	module/language/ecmascript/compile-tree-il.scm
	module/language/tree-il.scm
	module/language/tree-il/analyze.scm
	module/language/tree-il/inline.scm
	test-suite/tests/tree-il.test
2011-09-29 18:02:28 +02:00
Andy Wingo
1bbe0a631c psyntax uses define-syntax-rule
* module/ice-9/psyntax.scm: Use define-syntax-rule.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-09-02 11:34:00 +02:00
Andy Wingo
dea14eb99b add define-syntax-rule
* module/ice-9/psyntax.scm (define-syntax-rule): Add this new helper
  macro, to define a syntax-rules macro with one clause.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-09-02 11:28:11 +02:00
Andy Wingo
26c81c7f40 Merge remote-tracking branch 'origin/lexical-literals'
Conflicts:
	module/ice-9/psyntax-pp.scm
2011-06-30 13:48:43 +02:00
Andy Wingo
8a562c697b Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	libguile/deprecated.c
	module/ice-9/psyntax-pp.scm
2011-06-30 13:47:46 +02:00
Stefan Israelsson Tampe
0ed9680fba psyntax: enable dotted tail patterns
* module/ice-9/psyntax.scm (syntax-case): enabled the use of a
  general last cdr instead of just '() in matching with both
  a ellipsis (p ...) and a last rest pattern (. q)

* module/ice-9/psyntax-pp.scm: Regenerated.
2011-06-21 22:41:08 +02:00
Andy Wingo
78f0ef20a7 Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
	module/ice-9/psyntax-pp.scm
	module/language/tree-il/compile-glil.scm
2011-06-18 01:07:20 +02:00
Andreas Rottmann
933c6eb795 Silence warnings for variables created by `generate-temporaries'
* module/ice-9/psyntax.scm (generate-temporaries): Give temporaries the
  current module, so that they may be bound at the top level.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-06-17 10:43:24 +02:00
Andy Wingo
6fc3eae477 sequence of expressions -> seq of head and tail
* libguile/expand.h:
* module/language/tree-il.scm: Rename "sequence" to "seq", and instead
  of taking a list of expressions, take a head and a tail.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/spec.scm:
* module/language/elisp/compile-tree-il.scm:
* module/ice-9/psyntax.scm:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/eval.scm:
* libguile/memoize.h:
* libguile/memoize.c:
* libguile/expand.c:
* libguile/eval.c: Adapt to the new seq format.
2011-06-02 19:13:32 +02:00
Andy Wingo
a881a4ae3b add <primcall> to tree-il
* libguile/expand.c:
* libguile/expand.h (SCM_EXPANDED_PRIMCALL_TYPE_NAME):
  (SCM_EXPANDED_PRIMCALL_FIELD_NAMES):
  (SCM_EXPANDED_PRIMCALL_SRC):
  (SCM_EXPANDED_PRIMCALL_NAME):
  (SCM_EXPANDED_PRIMCALL_ARGS):
  (SCM_MAKE_EXPANDED_PRIMCALL): Add "primcall" Tree-IL type.

* doc/ref/compiler.texi (Tree-IL): Update docs.

* libguile/memoize.c (memoize): Memoizer for primcalls.

* module/ice-9/psyntax.scm: Build primcalls, sometimes.  Also change
  build-primref to just make a primitive-ref.

* module/language/tree-il.scm: Add primcall to the exports, parsers,
  serializers, etc.

* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* module/language/elisp/compile-tree-il.scm: Add primcall support.

* test-suite/tests/tree-il.test: Use primcalls sometimes.
2011-06-02 17:45:58 +02:00
Andy Wingo
7081d4f981 rename <application> to <call>
* doc/ref/compiler.texi (The Scheme Compiler): Update docs.

* libguile/expand.h:
* libguile/expand.c:
* module/language/tree-il.scm: Rename <application> to <call>.  Change
  the external representation from (apply proc arg ...) to (call proc
  arg ...).

* libguile/memoize.c:
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/brainfuck/compile-tree-il.scm:
* module/language/ecmascript/compile-tree-il.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* test-suite/tests/tree-il.test: Update all callers.
2011-06-02 13:42:55 +02:00
Andy Wingo
e2ccab571e psyntax simplification
* module/ice-9/psyntax.scm (strip): Inline the and-map* definition to
  its one call site.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-05-05 23:07:37 +02:00
Andy Wingo
04b04af85a fix free-id=? for module-bound keywords
* module/ice-9/psyntax.scm (free-id=?): For identifiers that are
  resolved to the toplevel, check that the variables that they would
  resolve to are equal, instead of simply checking that the symbolic
  identifier names are equal.  Allows keywords to be bound, renamed,
  exported, excluded, etc.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-04-29 16:37:42 +02:00
Andy Wingo
aa5698fb53 eval-when matches situations symbolically
* module/ice-9/psyntax.scm (chi-when-list): Just match symbolically
  instead of lexically, so as not to tie the meaning of eval-when to the
  bindings of eval, load, compile, and expand.
2011-04-29 16:36:50 +02:00
Andy Wingo
b735d33b2b psyntax simplification
* module/ice-9/psyntax.scm (id-var-name): Just rely on multiple-values
  truncation.
2011-04-29 11:14:56 +02:00
Andy Wingo
d8f699e8eb inline fxops in psyntax
* module/ice-9/psyntax.scm (fx+, fx-, fx=, fx<): Given our lame lack of
  an inliner, inline these manually with identifier syntax.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-03-31 13:29:58 +02:00
Andy Wingo
f929b9e5ec allow definitions in with-syntax body
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
  as seems to be suggested by the R6RS.

* test-suite/tests/syncase.test ("with-syntax"): Add test.

* module/ice-9/psyntax-pp.scm: Regenerate.
2011-03-31 13:23:27 +02:00
Andy Wingo
4da326f25d chi-top-sequence defines macros before expanding other exps
* module/ice-9/psyntax.scm (chi-top-sequence): Manually inline
  eval-if-c&e into its two call sites; I found it hard to understand
  otherwise.  If the mode is just 'e, defer expansion of definitions and
  expressions until the end, so that they can be expanded in a context
  of all syntax expanders defined in the sequence.
2011-02-27 12:59:03 +01:00
Andy Wingo
4c2e13e548 psyntax: fold chi-top-sequence into chi-top
* module/ice-9/psyntax.scm (chi-top-sequence): Pull chi-top into the
  body of this toplevel begin expander.  This will let us do r6rs
  toplevel expansion correctly.
  (chi-top): Remove.
  (macroexpand): Dispatch to chi-top-sequence directly.
2011-02-27 12:59:03 +01:00
Andy Wingo
0f550375be unquote and unquote-splicing can split multiple expressions
* module/ice-9/psyntax.scm (quasiquote): Import new definition from
  upstream psyntax, to allow unquote and unquote-splicing to take
  multiple arguments.
  (unquote, unquote-splicing): Adapt to not require a particular syntax
  form.

* module/ice-9/psyntax-pp.scm: Regenerated.
2011-02-08 21:38:57 +01:00
Andy Wingo
05a5e5d6d0 toplevel vars added by syntax expansion are unbound
* module/ice-9/psyntax.scm (chi-top): When adding to the toplevel
  environment at compile-time, default to undefined variables, not
  variables defined to #f.

* module/ice-9/psyntax-pp.scm: Regenerate.

* module/ice-9/boot-9.scm (module-add!): Add a new pre-modules version
  of this function, so we can add variables the environment, not just
  values.
  (module-define!): Use module-add!.
2011-01-31 21:09:20 +01:00
Andy Wingo
8f1870f20f syntax-violation uses lambda*, throws a structured message
* module/ice-9/psyntax.scm (syntax-violation): Use lambda* for subform
  arg. Instead of using scm-error, just throw to 'syntax-error with all
  we got.

* module/ice-9/psyntax-pp.scm (#{and-map*\ 37}): Regenerated.
2010-11-16 02:56:57 +01:00
Andy Wingo
381ccb0b89 more inlining in psyntax
* module/ice-9/psyntax.scm (make-wrap, wrap-marks, wrap-subst): Use
  identifier syntax here too.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-10-08 12:31:56 +02:00
Andy Wingo
cf45ff030c inline symbol? and vector? to opcodes, and a psyntax inlining tweak
* libguile/vm-i-scheme.c (symbol?, vector?): New
  instructions. Renumbered the rest.
* libguile/vm-i-system.c: Renumber instructions.
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.

* module/ice-9/psyntax.scm (binding-type, binding-value): Define using
  macros so that we inline to car and cdr opcodes. Oh, for an inliner :)

* module/language/tree-il/compile-glil.scm (*primcall-ops*)
* module/language/tree-il/primitives.scm
  (*interesting-primitive-names*, *effect-free-primitives*)
  (*effect+exception-free-primitives*): Add symbol? and vector?
  inlines.
2010-10-08 12:31:56 +02:00
Andy Wingo
44d65b23ce docstrings in syntax-rules
* module/ice-9/psyntax.scm (syntax-rules): Allow a docstring between the
  literals and the first clause.
2010-08-29 19:27:23 -07:00
Andy Wingo
8fad25c25f reindent psyntax.scm
* module/ice-9/psyntax.scm: Reindent.
2010-08-16 21:36:14 -07:00