chiark / gitweb /
sod
5 years agosrc/final.lisp (test-module): Make it useful for testing error reporting.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/final.lisp (test-module): Make it useful for testing error reporting.

5 years agosrc/lexer-proto.lisp: New parser `must'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp: New parser `must'.

This is a simple wrapper around `error' for mandatory delimiters.  If it
doesn't find the delimiter, it reports the error and continues, possibly
producing a default value.

5 years agosrc/method-proto.lisp: Don't bind `*keyword-struct-disposition*' initially.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp: Don't bind `*keyword-struct-disposition*' initially.

Abolish the `:unset' state, which was an acknowledged hack for the
absence of `defvar-unbound' which we now have.

5 years agosrc/: Disentangle some pieces of module-parsing preparation.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/: Disentangle some pieces of module-parsing preparation.

Have `*module-map*' initialized in strictly one place, rather than a
`defparameter' and sneakily in `test-module'.  This is now a
`clear-the-decks' operation.  Use `defvar-unbound' to leave a trap for
the incautious who try to use it before the decks are cleared.

5 years agosrc/utilities.lisp (defvar-unbound): Make a variable with docs and no value.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/utilities.lisp (defvar-unbound): Make a variable with docs and no value.

5 years agosrc/final.lisp: Slightly tweak `clear-the-decks' usage.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/final.lisp: Slightly tweak `clear-the-decks' usage.

  * Force a clear after loading the file.  This is now safe, because
    we've arranged for us to be loaded after everything relevant.

  * Don't bother clearing /before/ `exercise' now that we know we've
    been cleared once.

  * Don't clear in `test-module'.

5 years agosrc/sod.asd.in: Make sure `final.lisp' is processed last.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/sod.asd.in: Make sure `final.lisp' is processed last.

Or at least after anything which hooks `clear-the-decks'.

5 years agosrc/fragment-parse.lisp, src/lexer-{impl,proto}.lisp: Better errors.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/fragment-parse.lisp, src/lexer-{impl,proto}.lisp: Better errors.

Improve error reporting for comments, string and character literals, and
C fragments.  Most significantly, if we encounter end-of-file while
trying to read one of these, then also report where the construct
started.  For C fragments, if we encounter a mismatching closing
bracket, then report where the opening bracket was; and if we hit end-
of-file while brackets are still open, then report where they were.

Also, deal with a subtlety in the initialization procedure for
`sod-token-scanner': the first token is read to `prime the pump' as part
of the behaviour of `token-scanner', which is done before `sod-token-
scanner' itself has had a chance to initialize its own slots -- such as
the filename to report to `file-location'.  There are several ways I
could have dealt with this -- e.g., introducing some deliberately-less-
specific superclass to initialize the filename for me -- but the path of
least resistance seems to be to cope with this problem carefully in
`scanner-token'.  This is anyway an improvement because the function no
longer depends on a sensible ambient error-location object being set.

5 years agosrc/lexer-proto.lisp (lexer-error): Use Oxford comma for expected tokens.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp (lexer-error): Use Oxford comma for expected tokens.

5 years agosrc/lexer-proto.lisp (lexer-error): Improve error reporting.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp (lexer-error): Improve error reporting.

Now EXPECTED can be `nil' to produce a simple `unexpected THING'
message.

5 years agosrc/lexer-impl.lisp: Don't always skip a token.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-impl.lisp: Don't always skip a token.

It's usually, or at least often, the wrong thing to do.  Consider, for
example, how to recover from trying to parse

( list[x] )

when presented with

( )

Instead, add a `:force-progress' argument to the `error' parser.  The
default is /not/ to consume a token; I think this is right.

5 years agosrc/parser/floc-proto.lisp, src/utilities.lisp: New `information' condition.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/floc-proto.lisp, src/utilities.lisp: New `information' condition.

For reporting extra information about errors.

5 years agosrc/parser/floc-proto.lisp: Add `enclosing-condition-with-location-type'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/floc-proto.lisp: Add `enclosing-condition-with-location-type'.

Split out the piece of `make-condition-with-location' which figures out
the appropriate subclass of `condition-with-location' to use to wrap a
given condition so that it can be extended more easily.

5 years agosrc/parser/floc-proto.lisp (make-condition-with-location): Error checking.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/floc-proto.lisp (make-condition-with-location): Error checking.

Check for errors rather than just mentioning them in the docstring.

5 years agosrc/module-parse.lisp (parse-class-body): Recover from `unknown class' error.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp (parse-class-body): Recover from `unknown class' error.

Dig up `SodObject' as a suitable default, and don't actually add the
class to the module.

5 years agosrc/utilities.lisp, src/class-finalize-impl.lisp: Improve error reports.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/utilities.lisp, src/class-finalize-impl.lisp: Improve error reports.

  * Arrange for `inconsistent-merge-error' to present the list of
    candidates more pleasantly for human reading.

  * Give `merge-lists' a new argument to turn items into presentable
    names.

  * Make a wrapper function for merging lists of classes to apply the
    right kind of presentation.

5 years agosrc/: Error message cleanup.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/: Error message cleanup.

  * Remove trailing `.'s from messages, to fit in with Unix conventions
    when they're output.  They'll look a little strange inside Lisp, but
    that's the right error to make.

  * Fix a `~a' to `~A' for consistency with everything else.

5 years agosrc/lexer-proto.lisp (syntax-error, lexer-error): Improve location handling.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp (syntax-error, lexer-error): Improve location handling.

The functions now provide a `:location' keyword argument, and use their
scanner argument as a default location if the keyword is omitted.

Nothing is currently using the optional arguments, but it might happen
later.

5 years agosrc/lexer-proto.lisp, ...: Kill `lexer-error' pointless CONSUMEDP flag.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp, ...: Kill `lexer-error' pointless CONSUMEDP flag.

Not sure what the idea was.  It seems to control printing the location
as part of the message, but the error printing machinery takes care of
doing that anyway; and even so, it seems to hang off this flag.

Kill it, and the redundant printing of the location.

5 years agosrc/module-parse.lisp: The direct-superclasses list is mandatory.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: The direct-superclasses list is mandatory.

5 years agosrc/module-parse.lisp: Report an error if the top-level parse fails.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: Report an error if the top-level parse fails.

5 years agosrc/c-types-impl.lisp: Provide both names for `_Bool'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp: Provide both names for `_Bool'.

Now the machinery can cope.

5 years agosrc/c-types-parse.lisp: Use the new `find-simple-c-type' function.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-parse.lisp: Use the new `find-simple-c-type' function.

New simple types added using `define-simple-c-type' won't be present in
the `*declspec-map*', or the `*module-type-map*', so they won't be found
at all using the previous search.  Now, look use `find-simple-c-type' if
the other two lookups don't work.

Now that this works, we don't need `void' or `bool' in the `*declspec-
map*', because they don't accept any modifiers.

5 years agosrc/c-types-parse.lisp (scan-simple-declspec): Prefer primitive types.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-parse.lisp (scan-simple-declspec): Prefer primitive types.

Look types up in `*declspec-map*' before consulting the
`*module-type-map*'.

5 years agosrc/lexer-impl.lisp: Describe EOF as `<end-of-file>' consistently.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-impl.lisp: Describe EOF as `<end-of-file>' consistently.

5 years agosrc/c-types-impl.lisp: Make string -> simple-c-type mapping more useful.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp: Make string -> simple-c-type mapping more useful.

  * Arrange for `define-simple-c-type' to accept multiple C type-name
    strings, and keep records in the `*simple-type-map*' allowing simple
    type names to be canonified.

  * Add a new function `find-simple-c-type' to retrieve the appropriate
    type object given one its names.

  * Use this when looking up types in property values.

  * Remove the type declarations from the builtin module because they're
    all entered as simple types directly now.

5 years agosrc/c-types-impl.lisp: Make `*simple-type-map*' use `equal' as its test.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp: Make `*simple-type-map*' use `equal' as its test.

It's mapping strings to things, so using `eql' was wrong.  In
particular, it caused (c-type (int :const)) to print incorrectly.

5 years agosrc/c-types-impl.lisp (intern-c-type): Canonify class and initargs.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp (intern-c-type): Canonify class and initargs.

Make sure the class and initargs are canonical before probing the
`*c-type-intern-map*'.

  * The class should ideally be represented by name.

  * The initargs should be in ascending order by keyword name.

In particular, this fixes a bug where `qualify-c-type' erroneously
returns a fresh type when asked to attach an empty list of qualifiers to
an already-interned type.

5 years agosrc/pset-impl.lisp: Don't look in `*module-type-map*' if it's unbound.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/pset-impl.lisp: Don't look in `*module-type-map*' if it's unbound.

It should be bound in general use, but depending on it makes testing
unnecessarily difficult.

5 years agosrc/utilities.lisp: Add new anaphoric `aand'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/utilities.lisp: Add new anaphoric `aand'.

5 years agosrc/module-parse.lisp, src/package.lisp: Read code in `sod-user' package.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp, src/package.lisp: Read code in `sod-user' package.

Define a `sod-user' package which uses `common-lisp' and `sod', and bind
`*package*' to this when we start reading a new module.

5 years agosrc/final.lisp: Improve `test-parser' for testing error reporting.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/final.lisp: Improve `test-parser' for testing error reporting.

This is nearly a rewrite.  By default, print errors and warnings
encountered during the parse, so that I can test how well the various
parsers cope with errors.  The output has changed, and there's a new
`:backtrace' keyword argument for disabling the error-trapping, to make
it easier to track down unexpected errors.

The new code is a little tricky.  A `token-scanner' tries to lex its
first token during initialization (`priming the pump'), and can
therefore emit lexical errors at this point.  We must therefore
establish `count-and-report-errors' around construction of the token
scanner; but it shouldn't be wrapped around the output stage -- partly
because I think I want to debug errors in that in the traditional way,
but mostly because the output includes the error counts.

So declare the scanner variables early, but initialize them later,
inside the body function.  This leaves a further problem: if priming the
pump fails badly, then `scanner' won't get set; so guard the final
output item from silliness in this case.

5 years agosrc/pset-parse.lisp: Evaluate the expression in `? SEXP'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/pset-parse.lisp: Evaluate the expression in `? SEXP'.

Trap errors, because they shouldn't abort the run.

5 years agosrc/pset-parse.lisp: Export the `parse-property' function.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/pset-parse.lisp: Export the `parse-property' function.

5 years agosrc/parser/scanner-impl.lisp: Location protocol for `string-scanner'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/scanner-impl.lisp: Location protocol for `string-scanner'.

Implement the protocol using the utilities carefully provided years ago
for the purpose.

5 years agosrc/parser/scanner-impl.lisp: Add missing `scanner-unread' method.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/scanner-impl.lisp: Add missing `scanner-unread' method.

For some reason, `string-scanner' didn't have this defined.

5 years agosrc/fragment-parse.lisp: Fix some ugly source formatting.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/fragment-parse.lisp: Fix some ugly source formatting.

5 years agodoc/structures.tex, lib/sod-structs.3: Justify union $C$__ichainu_$h$.
Mark Wooding [Fri, 8 Jun 2018 18:31:04 +0000 (19:31 +0100)]
doc/structures.tex, lib/sod-structs.3: Justify union $C$__ichainu_$h$.

5 years agodoc/structures.tex: Remove spurious line breaks in the source.
Mark Wooding [Fri, 8 Jun 2018 18:30:26 +0000 (19:30 +0100)]
doc/structures.tex: Remove spurious line breaks in the source.

Debris from copying from the troff(1) source.

5 years agolib/sod-structs.3: Move the definition of type $C$ somewhere more sensible.
Mark Wooding [Fri, 8 Jun 2018 18:28:54 +0000 (19:28 +0100)]
lib/sod-structs.3: Move the definition of type $C$ somewhere more sensible.

Now it's just after where we explain struct $C$__ichain_$h$, which is
where the similar text in the LaTeX manual is.

5 years agolib/sod-structs.3: Fix misnamed `struct SodClass__ilayout'.
Mark Wooding [Fri, 8 Jun 2018 18:27:50 +0000 (19:27 +0100)]
lib/sod-structs.3: Fix misnamed `struct SodClass__ilayout'.

5 years agolib/keyword.h: Some minor fixes to comments.
Mark Wooding [Thu, 7 Jun 2018 17:50:26 +0000 (18:50 +0100)]
lib/keyword.h: Some minor fixes to comments.

Delete some stray spaces, and fix some mangled English.

6 years agodoc/syntax.tex, src/sod-module.5: Add missing `<TYPE>' expression syntax.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex, src/sod-module.5: Add missing `<TYPE>' expression syntax.

6 years agodoc/syntax.tex, src/sod-module.5: Abstract out <plain-type> nonterminal.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex, src/sod-module.5: Abstract out <plain-type> nonterminal.

6 years agodoc/parsing.tex: Document missing `:ignore-unconsumed' flag to `error'.
Mark Wooding [Sun, 5 Jun 2016 22:08:08 +0000 (23:08 +0100)]
doc/parsing.tex: Document missing `:ignore-unconsumed' flag to `error'.

6 years agodoc/structures.tex, lib/sod-structs.3: Define variable `M'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/structures.tex, lib/sod-structs.3: Define variable `M'.

Oops.

6 years agodoc/{misc,parsing}.tex: Write <form> rather than <body-form>.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/{misc,parsing}.tex: Write <form> rather than <body-form>.

6 years agodoc/{runtime,structures}.tex: Fix careless transfer from the manpages.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/{runtime,structures}.tex: Fix careless transfer from the manpages.

6 years agodoc/meta.tex: Fix nonterminal `<...>' to `@<...>'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/meta.tex: Fix nonterminal `<...>' to `@<...>'.

6 years agodoc/: Align backslashes in C-macros by the right-hand margin.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/: Align backslashes in C-macros by the right-hand margin.

Do this in the source, and in the typeset code.

6 years agodoc/: Align layout control commands to right margin in `tabbing' etc.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/: Align layout control commands to right margin in `tabbing' etc.

This is mostly clean in `--word-diff'.  Here are the exceptions.

  * doc/parsing.tex: `--word-diff' gets confused around the various
    `condition-with-location' subclasses.  This is clean in `-b', so
    there's not actually anything complicated happening here.

  * doc/parsing.tex: I've sneakily removed a pointless trailing `%'.

  * doc/runtime.tex: I've inserted a couple of linebreaks with `%' so as
    to shorten the source-file lines.

  * doc/runtime.tex: Some `\-' have harmlessly moved past `@\\' macro-
    backslashes to take their proper places on the right margin.

6 years agodoc/sod.sty: Typeset code upright, even if surrounding text is italic.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/sod.sty: Typeset code upright, even if surrounding text is italic.

6 years agodoc/output.tex: Add the `user' and `early-user' output items to comment.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/output.tex: Add the `user' and `early-user' output items to comment.

6 years agodoc/sod.sty, doc/runtime.tex: Improve comment typesetting in code.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/sod.sty, doc/runtime.tex: Improve comment typesetting in code.

  * Don't typeset the initial `;' as commentary; handle multiple initial
    `;;' in sequence.

  * Add new commands for general inside-comment typesetting, and for
    C-style `/* ... */' comments.  Maybe there should be a thing for
    C++-style comments, but I don't tend to use them anyway.

  * Highlight code text in commentary.

6 years agodoc/parsing.tex: Fix awful inconsistency in indentation.
Mark Wooding [Sat, 22 Jul 2017 15:48:33 +0000 (16:48 +0100)]
doc/parsing.tex: Fix awful inconsistency in indentation.

Somehow the descriptions of the various condition classes ended up all
over the place.

6 years agodoc/syntax.tex: Replace `listing' environments with `prog'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Replace `listing' environments with `prog'.

6 years agodoc/syntax.tex: Mention superclass list is mandatory.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Mention superclass list is mandatory.

And discuss the difficulties of actually defining new root classes.

6 years agodoc/runtime.tex: Remove stray space between `*' and its operand.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/runtime.tex: Remove stray space between `*' and its operand.

6 years agodoc/syntax.tex: Fix wording error in description of <one-or-more>.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
doc/syntax.tex: Fix wording error in description of <one-or-more>.

Probably a cut-and-paste mistake.

6 years agodoc/list-exports.lisp, doc/SYMBOLS: Report on condition classes.
Mark Wooding [Sun, 26 Mar 2017 09:01:28 +0000 (10:01 +0100)]
doc/list-exports.lisp, doc/SYMBOLS: Report on condition classes.

Unfortunately, they don't have a well-defined metaclass, but we can dig
it out anyway.

6 years agodoc/list-exports.lisp, doc/SYMBOLS: Mark methods with their qualifiers.
Mark Wooding [Sun, 26 Mar 2017 09:16:34 +0000 (10:16 +0100)]
doc/list-exports.lisp, doc/SYMBOLS: Mark methods with their qualifiers.

6 years agodoc/list-exports.lisp: Insert correct Emacs dropping.
Mark Wooding [Sun, 2 Apr 2017 15:16:58 +0000 (16:16 +0100)]
doc/list-exports.lisp: Insert correct Emacs dropping.

6 years agodoc/list-exports.lisp: Relatively mild changes for ASDF3.
Mark Wooding [Sat, 8 Jul 2017 23:45:24 +0000 (00:45 +0100)]
doc/list-exports.lisp: Relatively mild changes for ASDF3.

I can't be bothered to support ASDF2 still, since this is only a tool
for people actually hacking on SOD, to try to keep the documentation
approximately in line with the code.

6 years agosrc/optparse.lisp, src/classes.lisp: Don't leak slot names.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/optparse.lisp, src/classes.lisp: Don't leak slot names.

This were the last slot-name leaks.  Yay!

6 years agosrc/lexer-proto.lisp (lexer-error): Fix spin from bad `format' string.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-proto.lisp (lexer-error): Fix spin from bad `format' string.

What should have been the `else' branch of the hairy list presentation
said `~;:' instead of `~:;', with the result that if there are four or
more expected character sequences, no branch of the conditional matches,
and the loop body doesn't consume any items so it spins forever.

6 years agosrc/c-types-impl.lisp: Fix name of `wchar_t'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp: Fix name of `wchar_t'.

Not sure how this ended up being wrong.

6 years agosrc/class-output.lisp (find-class-initializer): Use correct keyword.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/class-output.lisp (find-class-initializer): Use correct keyword.

This is a silly typo which persisted because the class-initializer
machinery hasn't been tested much yet.

6 years agosrc/parser/floc-proto.lisp: Restore missing argument.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/parser/floc-proto.lisp: Restore missing argument.

This code path was clearly never exercised.

6 years agosrc/method-proto.lisp (make-trampoline): Ignore unused keyword pointers.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp (make-trampoline): Ignore unused keyword pointers.

If we're not going to need a keyword pointer (because the applicable
methods have no keyword arguments) then ignore it explicitly.  (We can't
just omit the arguments, because direct-method functions may have to
work as part of an effective method which /does/ have keyword arguments
-- maybe even downstream -- and the trampoline functions must have the
same signature either way.)

6 years agosrc/method-proto.lisp (invoke-delegation-chain): Pass keyword args correctly.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp (invoke-delegation-chain): Pass keyword args correctly.

It's not correct to commit to `&sod__kw' or `sod__kw' for the entire
chain.  Typically, the first method gets called with `&sod__kw', but the
rest want plain `sod__kw'.

6 years agosrc/method-proto.lisp: Set `*keyword-struct-disposition*' properly.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-proto.lisp: Set `*keyword-struct-disposition*' properly.

No idea where this one came from.

6 years agolib/sod.h: Fix bungled varargs support macro.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
lib/sod.h: Fix bungled varargs support macro.

6 years agovars.am: Tweak `silent-rules' machinery.
Mark Wooding [Sun, 9 Jul 2017 01:00:52 +0000 (02:00 +0100)]
vars.am: Tweak `silent-rules' machinery.

Since Automake 1.11, the advice for setting up custom silent-rules
recipes has changed, so use the new machinery.

Also, I'm no longer mainly working on wheezy, and Automake has made the
operation field two spaces wider while I wasn't looking, so make the
output line up properly.

This means that SOD now requires Automake 1.11.2 or later to build from
the Git tree.

7 years agodebian/rules: Cope with `sbuild', which sets a fake home directory.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
debian/rules: Cope with `sbuild', which sets a fake home directory.

7 years agodebian/libsod-dev.install: Fix name of manpage.
Mark Wooding [Sun, 29 May 2016 15:32:47 +0000 (16:32 +0100)]
debian/libsod-dev.install: Fix name of manpage.

7 years agotest/Makefile.am: Distribute the test program source.
Mark Wooding [Sun, 29 May 2016 15:30:23 +0000 (16:30 +0100)]
test/Makefile.am: Distribute the test program source.

7 years agoMerge branches 'mdw/kwargs' and 'mdw/c11'
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
Merge branches 'mdw/kwargs' and 'mdw/c11'

* mdw/kwargs: (29 commits)
  New feature: initialization keyword arguments.
  src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
  New feature: proper object lifecycle protocol; init and teardown fragments.
  src/builtin.lisp: Bind `me' around slot initializers, and define the order.
  Replace the `init' class-slot function with an `init' message.
  Compatibility: the `init' function no longer calls `imprint' for you.
  src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
  doc/runtime.tex, lib/sod.3: Restructure the runtime library reference.
  doc/concepts.tex: Reorganize the instance lifecycle material.
  doc/: Miscellaneous clarifications and rewordings.
  doc/concepts.tex: Don't highlight `primary' as literal, because it's not.
  src/: Abolish the distinction between different kinds of initializers.
  src/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.
  New feature: messages with keyword arguments!
  lib/: Pure C machinery for handling `keyword arguments' to functions.
  doc/runtime.tex: Demote the object-system support stuff to a section.
  src/c-types-*.lisp: New type for functions which take keyword arguments.
  src/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.
  src/c-types-parse.lisp (parse-declarator): Explain how it works.
  src/: New function `reify-variable-argument-tail'.
  ...

* mdw/c11:
  src/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.
  src/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.
  src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
  src/c-types-{impl,parse}.tex: Support `_Atomic' types.
  src/c-types-parse.lisp: Introduce a pluggable parser for declspecs.
  src/c-types-parse.lisp: Hoist up the `ds-FOO' methods for raw types.
  src/c-types-parse.lisp: Improve handling of compatibility keywords.
  src/final.lisp: Add function for interactively testing type parsing.
  src/c-types-proto.lisp, src/c-types-impl.lisp: Qualifier name protocol.
  src/module-parse.lisp (parse-raw-class-item): Commit after declarator.
  Add a new class slot `align', holding the instance layout alignment.
  src/c-types-impl.lisp (make-or-intern-c-type): Pull out useful function.
  src/c-types-parse.lisp, src/c-types-proto.lisp: Some minor cleanups.
  src/parser/parser-proto.lisp: Add functions returning standard parsers.
  src/parser/: Allow parsers to commit to a parse while peeking.
  doc/clang.tex: Improve documentation of C type spec expansion.

Conflicts:
doc/SYMBOLS (regenerated)
doc/syntax.tex (hand-merge; extra parameter to <declarator>)
lib/sod.h (simple hand-merge)
src/sod-module.5 (extra parameter to <declarator>, added by hand)

7 years agosrc/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-impl.lisp, src/c-types-parse.lisp: Support C11 `_Alignas'.

7 years agosrc/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-{proto,impl,parse}.lisp: Add `storage specifiers' to the model.

A slightly unusual kind of thing.  This is intended to capture things
like storage classes and similar which are determinedly `top level',
unlike qualifiers which stay attached to the base type in the presence
of declarator operators.

Storage specifiers are attached to a special carrier type
`c-storage-specifiers-type' (with all of the necessary trimmings), and
there is new machinery (`wrap-c-type') to arrange that this stays at the
outermost level when deriving new types from existing ones.

There is a pile of additional protocol, mostly mirroring the main types
protocol, for dealing with storage-specifier syntax, in both Lisp and C.

7 years agosrc/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.

This change adds support for both the `_Atomic' type qualifier and the
`_Atomic(...)' type specifier.

7 years agoNew feature: initialization keyword arguments.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: initialization keyword arguments.

Initialization keyword arguments can now be declared in class
definitions.  They become additional keyword arguments accepted by the
object's `init' effective method.  The initialization arguments are
available for use (by name) within slot initializer expressions and
initialization fragments.

  * `User' initargs are otherwise passive.  They may usefully have a
    default value, which is used if the argument is
    omitted.  (Alternatively, user code can test the `suppliedp' flag
    and behave accordingly.)

  * `Slot' initargs are associated with an effective slot.  If one of a
    slot's initargs is provided in the `init' message, then its value is
    used to initialize the slot, instead of the slot initializer.  If
    more than one applicable initarg is provided, then priority is given
    to the initargs defined in more specific superclasses; if this
    doesn't disambiguate, then one of the initargs is chosen
    arbitrarily (this situation is likely an error).

7 years agosrc/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.
Mark Wooding [Tue, 5 Jan 2016 22:43:47 +0000 (22:43 +0000)]
src/method-{proto,impl}.lisp: New `method-keyword-argument-lists' protocol.

In case method classes want to introduce keyword arguments from
somewhere other than the obvious direct methods, there's now a separate
bit of protocol for determining the lists of keyword arguments which
need to be merged together.

7 years agoNew feature: proper object lifecycle protocol; init and teardown fragments.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: proper object lifecycle protocol; init and teardown fragments.

A class definition may contain fragments of C code for initialization
and teardown.  Initialization fragments are invoked from the default
`init' message behaviour, in least-to-most specific order, immediately
after initializing the corresponding class's direct slots (if any);
teardown fragments are included in the default behaviour of a new
`teardown' message, in most-to-least specific order.

Now that we have initialization and teardown, we can implement more
useful object lifecycle functionality around them, e.g., dealing with
dynamically allocated objects.  Appropriate new definitions have been
added to the library.

7 years agosrc/builtin.lisp: Bind `me' around slot initializers, and define the order.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
src/builtin.lisp: Bind `me' around slot initializers, and define the order.

Previously, the `init' method kernel (and the `init' class-slot function
before that) initialized one chain at a time, then down the chains,
because this made for a convenient traversal of the class layout.  But
it sucks for users.

Make this better.  Bind `me' around slot initializers -- to the type of
the direct slot.  This means that initializers can compute their values
based on other previously initialized slots, which is useful because
subclasses can override initializers for their superclasses.

The `me' pointer has the type of the class owning the direct slots being
initialized, which means that referring to substructure belonging to
classes other than the superclasses of the slot owner is hard, even if
the initializer can be sure (because it was defined on some subclass)
that those other classes are available.  This is nonetheless the right
thing because (a) it means that the `me' pointer has a reliable type,
and (b) the slots belonging any other classes which might be of interest
won't have been initialized by this point.

Take the opportunity to clarify the documentation regarding slot
initialization generally.

7 years agoReplace the `init' class-slot function with an `init' message.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
Replace the `init' class-slot function with an `init' message.

The `SodObject' class now defines an `init' message.  This message takes
keywords, which can be collected by methods and used to set up objects
in interesting ways.

The `init' message's default behaviour (unless overridden by a primary
or around method) is to initialize the instance's slots using the most
specific applicable initializers, just as the old `init' function used
to do.

Obviously, one can send an `init' message to an instance before it's
been imprinted, so that has to be done as a separate step now.  The
`SOD_DECL' macro has been adjusted to cope.  It also takes an additional
argument containing keyword arguments to be passed with the `init'
message (which constitutes an additional compatibility break).

The library has grown a new pair of functions `sod_init' and `sod_initv'
which wrap up the initialization protocol, and a macro `SOD_INIT' which
improves type safety a little.

(Some of the new code in `src/builtin.lisp' is a little odd.  This is
intended to accommodate future changes better.)

7 years agoCompatibility: the `init' function no longer calls `imprint' for you.
Mark Wooding [Sat, 7 May 2016 13:45:18 +0000 (14:45 +0100)]
Compatibility: the `init' function no longer calls `imprint' for you.

It will make much less sense later.

7 years agosrc/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.

Previously, the `compute-method-entry-functions' method defined on
`simple-effective-method' would bail out early if there were no primary
methods.  This is unsatisfactory: subclasses of `simple-effective-
method' might want to introduce more complicated method combination
machinery.

Make this a proper part of the protocol: introduce `effective-method-
live-p', which gets to decide whether to make method-entry functions or
just leave the vtable pointers null.  Now `simple-effective-method' can
decide, in the same way, to suppress the method entries based on the
existence of primary methods, but subclasses can apply more (or less)
subtle policy.

7 years agodoc/runtime.tex, lib/sod.3: Restructure the runtime library reference.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
doc/runtime.tex, lib/sod.3: Restructure the runtime library reference.

Reorder the descriptions of the various macros and functions along more
useful thematic lines.  Some of the sections are currently a bit thin
but they'll fill out later.

Mostly this is just moving text about, but some edits have been made.
Most significantly, `SOD_CONVERT' and `sod_convert' are now discussed
together rather than separately.

7 years agodoc/concepts.tex: Reorganize the instance lifecycle material.
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
doc/concepts.tex: Reorganize the instance lifecycle material.

Promote it to its own section and overhaul the text ready for further
improvements.

7 years agodoc/: Miscellaneous clarifications and rewordings.
Mark Wooding [Sat, 7 May 2016 14:32:51 +0000 (15:32 +0100)]
doc/: Miscellaneous clarifications and rewordings.

7 years agodoc/concepts.tex: Don't highlight `primary' as literal, because it's not.
Mark Wooding [Sat, 7 May 2016 09:56:54 +0000 (10:56 +0100)]
doc/concepts.tex: Don't highlight `primary' as literal, because it's not.

7 years agosrc/: Abolish the distinction between different kinds of initializers.
Mark Wooding [Tue, 5 Jan 2016 19:18:55 +0000 (19:18 +0000)]
src/: Abolish the distinction between different kinds of initializers.

It made parsing difficult, both because the kind and value needed to be
carted about together, and just technically because of `scan-c-fragment'
interacts badly with token-level lookahead.

Against that, the formatting benefits are very slim, and more so when
one considers that there are ugly `#line' markers around the value
fragment.

So, the distinction is gone; there are no more `value-kind' slots or
arguments; and the `value-form' is now just plain `value'.

This is a fairly straightforward change (except for the radical
simplification of the `parse-initializer' function, which hardly needs
to exist any more), but somewhat far-reaching.

7 years agosrc/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.
Mark Wooding [Wed, 16 Dec 2015 10:43:47 +0000 (10:43 +0000)]
src/method-{proto,impl}.lisp: Abolish `sod-message-no-varargs-tail'.

This was promised earlier.  All but one of the callers of this method
were lost during the introduction of keyword-argument messages, and it
doesn't seem worth keeping this corner of the method protocol just for
that.

7 years agoNew feature: messages with keyword arguments!
Mark Wooding [Tue, 15 Dec 2015 19:15:23 +0000 (19:15 +0000)]
New feature: messages with keyword arguments!

Let's start with the new functionality.

You can define messages which are meant to be given keyword arguments,
and methods which retrieve and (presumably) act on those keywords.  The
behaviour is as in Common Lisp: the acceptable keywords for a message
sent to an object are precisely those keywords acceptable to any
applicable method, and those listed in the message definition itself.

The Sod translator takes care of picking keyword argument lists apart
and passing actual arguments to the direct methods; arguments can have
default values (and each direct method can have different defaults),
and/or find out whether a keyword was actually provided.  The only picky
rule is that if two methods (or a method and the message itself) each
define an argument with the same keyword, then those arguments must also
have the same type.

The new code -- and there's quite a lot of it -- mostly concerns itself
with coping with messages and methods which accept keyword arguments,
and generating the proper functions and instructions for gathering them
and passing them about.  This is rather annoying and fiddly.

In particular, it seems as if I ought to be able to have factored the
existing machinery much better than I actually did if only I were more
clever, so that this new stuff could slot in neatly; instead, it looks
as if I just turned the program upside-down and shook hard, which is
pretty accurate really.

7 years agolib/: Pure C machinery for handling `keyword arguments' to functions.
Mark Wooding [Sun, 10 Jan 2016 13:51:04 +0000 (13:51 +0000)]
lib/: Pure C machinery for handling `keyword arguments' to functions.

The new `keyword.h' header file defines a bunch of (somewhat nasty)
macros which allow one to define, parse, pass, and access things which
look a bit like Common Lisp's keyword arguments.  There are a few
support functions, mostly for reporting errors.

7 years agodoc/runtime.tex: Demote the object-system support stuff to a section.
Mark Wooding [Sat, 2 Jan 2016 15:29:23 +0000 (15:29 +0000)]
doc/runtime.tex: Demote the object-system support stuff to a section.

There will be more sections later.

7 years agosrc/c-types-*.lisp: New type for functions which take keyword arguments.
Mark Wooding [Sun, 10 Jan 2016 13:51:04 +0000 (13:51 +0000)]
src/c-types-*.lisp: New type for functions which take keyword arguments.

This commit introduces a new `c-keyword-function-type', including
printing and parsing the things, and some utilities for working with
keyword argument lists (most notably merging them while providing useful
diagnostics about type mismatches).  This involves enhancing the
`argument' type to include an optional default value.

The surface syntax uses a `?' to separate the preceding mandatory
positional arguments from the following optional keyword arguments.  I'm
not completely thrilled by this choice, but I can't see many better
options.  The corresponding use of a `:keys' marker in the S-expression
syntax is also somewhat ugly (especially the way that `make-function-
type' acts on it), but better choices seemed thin on the ground.

An earlier experiment introduced a `keyword-argument' subclass, rather
than enhancing the existing `argument' structure, but it made many
things (e.g., commentifying argument lists) unnecessarily painful for
little benefit -- especially when I realised that it's important to
distinguish an ordinary function from one which notionally accepts
keyword arguments but doesn't actually define any (yet).

7 years agosrc/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.
Mark Wooding [Wed, 16 Dec 2015 05:57:20 +0000 (05:57 +0000)]
src/c-types-parse.lisp (parse-declarator): Refactor argument list parsing.

The `argument-list' parser is now less monolithic: the work of parsing
individual arguments is given to new functions `arg-decl' and
`argument'.

Also, the interface between `argument-list' and its parent
`postfix-lparen' is changed.  Instead of simply returning its argument
list, `argument-list' now returns a function which can be applied to a
base type to produce the appropriate function type.

None of this changes any externally observable behaviour.

7 years agosrc/c-types-parse.lisp (parse-declarator): Explain how it works.
Mark Wooding [Wed, 16 Dec 2015 05:49:38 +0000 (05:49 +0000)]
src/c-types-parse.lisp (parse-declarator): Explain how it works.

It's a little confusing, even to me.

7 years agosrc/: New function `reify-variable-argument-tail'.
Mark Wooding [Wed, 16 Dec 2015 04:03:46 +0000 (04:03 +0000)]
src/: New function `reify-variable-argument-tail'.

This does the work behind `sod-message-no-varargs-tail' (only I've
simplified it by using `substitute' rather than pointlessly doing the
work by hand like an idiot).

Heads up: `sod-message-no-varargs-tail' is going to be abolished
entirely soon.