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

249 commits

Author SHA1 Message Date
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
Andy Wingo
565c8e30cd update comments in psyntax.scm
* module/ice-9/psyntax.scm: Update comments. Fix a couple of needless
  conses in and-map.

* module/ice-9/psyntax-pp.scm (#{and-map*\ 35}): Regen.
2010-08-16 21:36:14 -07:00
Andy Wingo
ab6becd47f fix (set! MACRO exp) hygiene
* module/ice-9/psyntax.scm (lookup): Reflow comment.
  (chi-top, syntax): Add comments about mod for lookup.
  (set!): Lookup the identifier in the module attached to its syntax
  object. In the (set! MACRO foo) case, after expanding the macro, chi
  the resulting expression with the empty wrap, as syntax-type
  does. Seems to fix the case where the expansion references
  lexically-bound variables.

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

* test-suite/tests/syncase.test: Add a bunch of tests.
2010-07-09 17:05:02 +02:00
Andy Wingo
7cdd1615e0 relax restriction on _ in literals
* module/ice-9/psyntax.scm: Relax restriction on _ in literals.

* module/ice-9/psyntax-pp.scm: Regen.
2010-06-21 21:47:42 +02:00
Andy Wingo
b78d91d517 syntax-case treats _ as placeholder
* module/ice-9/psyntax.scm (underscore?): New helper, like ellipsis?.
  (syntax-case): Treat the _ pattern as a matches-all pattern,
  disallowing it from the keyword list. Another well-thought part of the
  R6RS.
  ($sc-dispatch): Dispatch _ patterns.

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

* test-suite/tests/syncase.test ("_ is a placeholder"): Add a test.
2010-06-21 20:56:05 +02:00
Andy Wingo
37620f3f4e set! name (lambda ...) names the lambda
* module/ice-9/psyntax.scm (build-lexical-assignment)
  (build-global-assignment): Maybe name the RHS.

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

* module/ice-9/boot-9.scm (catch, with-throw-handler, throw): Rework to
  use set! instead of define! so that we get names.
2010-06-19 13:56:16 +02:00
Andy Wingo
bfccdcd530 add support for variable transformers: settable identifier syntax
* module/ice-9/psyntax.scm (set!): Handle variable transformers; though,
  they cannot produce definitions.
  (make-variable-transformer): New procedure.
  (identifier-syntax): Allow the R6RS form that makes variable
  transformers.

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

* doc/ref/r6rs.texi (R6RS Incompatibilities): Remove letrec* item, and
  add set! restriction.
2010-06-19 12:43:40 +02:00
Andy Wingo
5f8c55ce3b fix order of internal definitions
* module/ice-9/psyntax.scm (chi-body): Whoops, actually render internal
  definitions into a letrec* in the right order.
* module/ice-9/psyntax-pp.scm: Regenerate.

* test-suite/tests/syntax.test: Add some letrec* tests.
2010-06-17 14:39:32 +02:00
Andy Wingo
0f2b9f6252 internal definitions expand out to letrec* instead of letrec
* module/ice-9/psyntax.scm (chi-body): Internal definitions are now
  letrec* instead of letrec, following the R6RS.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-17 13:43:26 +02:00
Andy Wingo
826373a25d psyntax, primitive expander, and memoizer support for letrec*
* libguile/expand.c (expand_letrec_helper): Factor out common code.
  (expand_letrec): Use expand_letrec_helper.
  (expand_letrec_star): New primitive syntax: letrec*.

* libguile/memoize.c (memoize): Add memoizer support for in-order letrec
  (letrec*).

* module/ice-9/psyntax.scm (build-letrec): Another arg, `in-order?'.
  (chi-body): Adapt to build-letrec change. We don't yet use letrec* for
  internal definitions.
  (letrec): Adapt to build-letrec change.
  (letrec*): New expander.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-17 13:43:26 +02:00
Andy Wingo
fb6e61ca21 beginnings of letrec* support in the expander
* libguile/expand.h (SCM_EXPANDED_LETREC_IN_ORDER_P)
  (SCM_MAKE_EXPANDED_LETREC): Add a new field to letrec, in-order?. Will
  be used to support letrec*.

* libguile/expand.c (LETREC, expand_named_let, expand_letrec): Adapt
  code.

* module/language/elisp/compile-tree-il.scm (compile-pair):
* module/ice-9/psyntax.scm (build-named-let, build-letrec): Pass #f for
  in-order? to `make-letrec'.

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

* module/language/tree-il.scm: Add letrec-in-order? accessor.
  (parse-tree-il, unparse-tree-il): Parse and unparse an in-order?
  letrec as `letrec*'.
  (tree-il->scheme): Serialize letrec*.
2010-06-17 13:43:26 +02:00
Andy Wingo
d71cc612c3 fix lexical call naming bug
* module/ice-9/psyntax.scm: Fix bug in which the whole syntax object was
  being recorded as the name of the operator in a lexical call, instead
  of just the symbolic name.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-11 16:58:36 +02:00
Andy Wingo
750ae8b7b7 add syntax-source accessor
* module/ice-9/psyntax.scm: Add syntax-source accessor.
* module/ice-9/psyntax-pp.scm: Regenerated.
* module/ice-9/boot-9.scm: Declare syntax-source.
2010-06-06 22:51:03 +02:00
Andy Wingo
f42d8bd8ff simplify macro representation in the wake of module hygiene changes
* module/ice-9/psyntax.scm (chi-install-global, chi-macro)
  (eval-local-transformer): Now that we handle module hygiene through
  syntax objects, there is no more need to record the current module
  when installing syntax transformers.

* module/ice-9/psyntax-pp.scm: Regenerated (trickily).

* libguile/_scm.h: Bump objcode version for macro representation change.

* libguile/macros.c (scm_macro_transformer): Adapt to change in macro
  representation.
2010-06-06 13:39:44 +02:00
Andy Wingo
9846796b6a fix module-hygiene corner case by relying more on syntax objects
* module/ice-9/psyntax.scm (chi-macro): Instead of assuming that output
  of a macro should be scoped relative to the module that was current
  when the macro was defined, allow the module information associated
  with the syntax object itself to pass through unmolested. Fixes bug
  29860.
  (datum->syntax): Propagate the module of the identifier through to the
  new syntax object, so that datum->syntax preserves module hygiene in
  addition to lexical hygiene.
  (include, include-from-path): Refactor to plumb though the hygiene
  information from the filename instead of the `include', allowing
  hygiene from the original caller of include-from-path to propagate
  through.

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

* test-suite/tests/syncase.test ("macro-generating macro"): Add test for
  bug 29860.
2010-06-06 13:00:59 +02:00
Andy Wingo
a96434cc33 source location propagation fixes in psyntax
* module/ice-9/psyntax.scm (syntax-type): Add some comments about source
  locations. In calls to chi-macro, pass the source location
  information. Propagate source location information when unpacking
  syntax objects.
  (chi-macro): Add a comment about source locations. Decorate output
  introduced by the macro with the source location of macro use.

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

Fixes bug #29817.
2010-06-05 19:40:43 +02:00
Andy Wingo
22cf27c815 fix procedure naming
* module/ice-9/psyntax.scm (define-expansion-accessors): New helper, to
  define accesors for a particular expansion data structure. Use it
  later to define lambda?, lambda-meta, and set-lambda-meta!.
  (maybe-name-value): Update to work with the newly defined accessors.
  (build-global-reference, build-let, build-named-let, build-letrec):
  Re-enable naming of procedures.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-06-02 16:07:11 +02:00
Andy Wingo
82c45730af lambda* usage in psyntax.scm
* module/ice-9/psyntax.scm (macroexpand): Use lambda*.
* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-20 13:28:25 +02:00
Andy Wingo
131ae7b49d remove *mode* fluid from psyntax
* module/ice-9/psyntax.scm: Remove the *mode* fluid. Whee :)
  (macroexpand): No need to bind aa *mode* fluid.

* module/ice-9/psyntax-pp.scm: Regenerated.
2010-05-20 12:54:47 +02:00