chiark / gitweb /
sod
5 years agosrc/module-parse.lisp: Improve error recovery for `load' and `import' items.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/module-parse.lisp: Improve error recovery for `load' and `import' items.

5 years agosrc/module-parse.lisp: Improve error recovery for `test' items.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/module-parse.lisp: Improve error recovery for `test' items.

5 years agosrc/module-parse.lisp: Improve error recovery for `code' items.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: Improve error recovery for `code' items.

5 years agosrc/module-parse.lisp: Improve error recovery for `typename' items.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: Improve error recovery for `typename' items.

5 years agosrc/module-parse.lisp (`set'): Parse at least one property if no pset.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp (`set'): Parse at least one property if no pset.

Allow

[foo = "thing"] set;

and

set foo = "thing";

but not plain

set;

5 years agosrc/module-parse.lisp (read-module): Use requested pathname for location.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp (read-module): Use requested pathname for location.

The default behaviour for `charbuf-scanner' is to use the pathname from
its underlying stream; but (at least on some implementations) this is an
absolute pathname which is actually rather annoying in error messages.

Instead, arrange for `read-module' to attach the namestring of the
pathname it was given directly to the scanner.  This will be the correct
possibly-relative pathname to the module file, because `find-file' has
already done that part of the work, but it will be relative if that's
how it was specified on the command line, if it was found by merging
with a relative pathname in the `*module-dirs*' list, or if it was
imported by a name relative to a module with a relative pathname.

5 years agosrc/module-parse.lisp (read-module): Provide sensible default error-recovery.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/module-parse.lisp (read-module): Provide sensible default error-recovery.

By default, if there's an error parsing a module item, skip and consume
until the next `;' or `}'.  This actually seems to work quite well.

5 years agosrc/module-parse.lisp: Don't explicitly ask for default behaviour.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: Don't explicitly ask for default behaviour.

  * Reporting the scanner position as the error location.

  * Setting at-least-one when parsing delimitered lists.

  * Keeping the terminator when skipping to one of several terminator
    tokens.

5 years agosrc/module-parse.lisp: Use newer syntax notation in the commentary.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/module-parse.lisp: Use newer syntax notation in the commentary.

5 years agosrc/module-parse.lisp: Some minor reformattings.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/module-parse.lisp: Some minor reformattings.

5 years agosrc/lexer-{proto,impl}.lisp: Add explicit recovery action to `error'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/lexer-{proto,impl}.lisp: Add explicit recovery action to `error'.

This ends up being an `:action' keyword argument to
`parse-error-recover', and a macro body to the `error' parser macro.

5 years agosrc/lexer-{proto,impl}.lisp: Enhance `skip-until' to match token values.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/lexer-{proto,impl}.lisp: Enhance `skip-until' to match token values.

5 years agosrc/lexer-impl.lisp: Set default `:keep-end' in `%skip-until' function.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/lexer-impl.lisp: Set default `:keep-end' in `%skip-until' function.

The parser-macro set this correctly, but the function didn't.

5 years agosrc/lexer-impl.lisp: Rename internal `skip-until' function.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/lexer-impl.lisp: Rename internal `skip-until' function.

This shouldn't have leaked.

5 years agosrc/class-make-impl.lisp: Forbid slots with function types.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/class-make-impl.lisp: Forbid slots with function types.

Pointer-to-function type is fine, of course.

5 years agosrc/{c-types-impl,method-{proto,impl}}.lisp: Improve `merge-keyword-lists'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/{c-types-impl,method-{proto,impl}}.lisp: Improve `merge-keyword-lists'.

  * Make the overall description of the merging site be a function (a)
    to report a file location and (b) to avoid formatting the thing if
    there isn't actually a problem.

  * Make the per-argument-list descriptions be functions so that they
    can report more than one message each.

  * Change `method-keyword-argument-lists' to report the inheritance
    path for methods involved in keyword argument conflicts.  Add an
    argument to thread through an `inheritance-path-reporter-state'
    object to make this work.

5 years agosrc/c-types-impl.lisp: Reorder `merge-keyword-lists' input lists.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/c-types-impl.lisp: Reorder `merge-keyword-lists' input lists.

Prepend the `what' argument to the front of each argument list, rather
than having a (LIST . WHAT) pair.  Also, internally to
`merge-keyword-lists', keep the entries in the hash table as
(WHAT . ARG) rather than the other way around.

5 years agosrc/method-impl.lisp (method-keyword-argument-lists): Check message type.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-impl.lisp (method-keyword-argument-lists): Check message type.

Check keyword arguments defined in the message as well as all of the
applicable methods.

5 years agosrc/method-impl.lisp (method-keyword-argument-lists): Zap pointless `let'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-impl.lisp (method-keyword-argument-lists): Zap pointless `let'.

5 years agosrc/method-impl.lisp (method-keyword-argument-lists): Fix indentation.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-impl.lisp (method-keyword-argument-lists): Fix indentation.

5 years agosrc/{lexer-{proto,impl},parser/floc-proto}.lisp: Conditionify parse errors.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/{lexer-{proto,impl},parser/floc-proto}.lisp: Conditionify parse errors.

  * Introduce condition classes for parse errors.

  * Introduce `classify-condition' to describe the different reportable
    conditions to the user, and change `count-and-report-errors*' to use
    this rather than having special knowledge.  Now it pretty much just
    counts and prints.

  * Move the complicated error-message printing machinery from the
    `syntax-error' and `lexer-error' functions into the condition
    reporting functions.  (Now they don't actually need to be formatted
    until they're just about to be presented to a user.)

5 years agosrc/**/*.lisp: Use convenience functions to invoke restarts.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/**/*.lisp: Use convenience functions to invoke restarts.

Introduce a new function `noted' to invoke the `noted' restart.  Fiddle
other code to do the right thing.

5 years agosrc/utilities.lisp: New function `invoke-associated-restart'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/utilities.lisp: New function `invoke-associated-restart'.

Does what it says on the tin.  Not really sure why this isn't part of
Common Lisp.

5 years agosrc/class-finalize-impl.lisp: Overhaul `check-sod-class', `compute-chains'.
Mark Wooding [Sun, 26 Mar 2017 13:48:23 +0000 (14:48 +0100)]
src/class-finalize-impl.lisp: Overhaul `check-sod-class', `compute-chains'.

Signal continuable errors so that we can get more useful diagnostics.
Use the `finalization-error' machinery to limit redundant error
reporting.  Report portions of inheritance structure where appropriate.
Improve checking that the things defined by the class don't conflict
with each other.

5 years agosrc/class-finalize-*.lisp: Improve finalization error reporting.
Mark Wooding [Sun, 26 Mar 2017 09:01:28 +0000 (10:01 +0100)]
src/class-finalize-*.lisp: Improve finalization error reporting.

Change the finalization protocol: now, `finalize-sod-class' and its
helpers (notably `check-sod-class') can signal continuable errors and
still have the overall finalization report failure.

Actually make use of the return value in the two callers:
`parse-class-body' and `bootstrap-classes'.

5 years agosrc/method-{impl,proto}.lisp: Add `sod-method-description'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/method-{impl,proto}.lisp: Add `sod-method-description'.

Now we can report on kinds of methods.

5 years agosrc/class-*.lisp: Improve metaclass selection.
Mark Wooding [Sun, 26 Mar 2017 13:41:40 +0000 (14:41 +0100)]
src/class-*.lisp: Improve metaclass selection.

Replace the slightly wobbly (and poorly named) `maximum' function (in
`class-finalize-impl.lisp') with the much more capable
`select-minimal-class-property' (in `class-utilities.lisp').

Use this new function as appropriate.

5 years agosrc/builtin.lisp (method-keyword-argument-lists): Don't `delete-duplicates'.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/builtin.lisp (method-keyword-argument-lists): Don't `delete-duplicates'.

No idea why this was here.  The `merge-keyword-lists' function copes
fine with duplicate names.  And the `:key' argument was hopelessly
wrong, so the code could never have worked.

5 years agosrc/class-finalize-{proto,impl}.lisp (finalize-sod-class): Add `:around'.
Mark Wooding [Sun, 26 Mar 2017 09:24:37 +0000 (10:24 +0100)]
src/class-finalize-{proto,impl}.lisp (finalize-sod-class): Add `:around'.

The `around' method handles the recursiveness and state tracking (and
will accumulate further functionality later).  The primary method
actually does the calculation and checking needed to make a class work.

5 years agosrc/class-finalize-proto.lisp (check-sod-class): Fix docstring.
Mark Wooding [Sun, 26 Mar 2017 09:16:34 +0000 (10:16 +0100)]
src/class-finalize-proto.lisp (check-sod-class): Fix docstring.

Describe the actual, rather unsatisfactory, state of the world.
Fortunately, this will be fixed soon.

5 years agosrc/{class-,}utilities.lisp: Add machinery for showing inheritance paths.
Mark Wooding [Sat, 25 Mar 2017 20:59:40 +0000 (20:59 +0000)]
src/{class-,}utilities.lisp: Add machinery for showing inheritance paths.

To the general utilities collection, we add an implementation of
Dijkstra's distinguished-point shortest-path algorithm.

To the class utilities, we add a new type and function for reporting
inheritance paths, with the notion that this will be useful when
debugging problems where classes turn out to be incompatible with each
other for various reasons.

5 years agosrc/class-{finalize,layout}-*.lisp: Relocate layout interface code.
Mark Wooding [Sun, 26 Mar 2017 14:16:18 +0000 (15:16 +0100)]
src/class-{finalize,layout}-*.lisp: Relocate layout interface code.

Establishing the layout is now the responsibility of the layout code.
Not sure what made me put it anywhere else.

5 years agosrc/final.lisp (test-parser): Set error location after making the scanner.
Mark Wooding [Sat, 25 Mar 2017 18:20:43 +0000 (18:20 +0000)]
src/final.lisp (test-parser): Set error location after making the scanner.

Oops.

5 years agosrc/final.lisp (test-module): By default, just report and count up errors.
Mark Wooding [Sat, 25 Mar 2017 18:17:53 +0000 (18:17 +0000)]
src/final.lisp (test-module): By default, just report and count up errors.

This makes the whole return value thing more useful.  You can still get
a backtrace (or enter the debugger or whatever) by setting the new
BACKTRACE argument.

5 years agosrc/final.lisp (test-module): Optionally clear the decks before parsing.
Mark Wooding [Sat, 25 Mar 2017 18:12:36 +0000 (18:12 +0000)]
src/final.lisp (test-module): Optionally clear the decks before parsing.

5 years agosrc/final.lisp (test-module): Don't try output if parsing failed.
Mark Wooding [Sat, 25 Mar 2017 18:10:46 +0000 (18:10 +0000)]
src/final.lisp (test-module): Don't try output if parsing failed.

5 years agosrc/final.lisp (test-module): Make REASON be a keyword argument.
Mark Wooding [Sat, 25 Mar 2017 18:01:53 +0000 (18:01 +0000)]
src/final.lisp (test-module): Make REASON be a keyword argument.

It's not always wanted, and we'll want to add more keywords soon.

5 years agosrc/final.lisp (test-module): Fix egregiously wrong docstring.
Mark Wooding [Sat, 25 Mar 2017 17:59:39 +0000 (17:59 +0000)]
src/final.lisp (test-module): Fix egregiously wrong docstring.

Make the doc stub match too.

5 years agosrc/utilities: (add partial-order-minima)
Mark Wooding [Sat, 25 Mar 2017 17:35:03 +0000 (17:35 +0000)]
src/utilities: (add partial-order-minima)

5 years agosrc/utilities.lisp: Fix docstring formatting.
Mark Wooding [Sat, 25 Mar 2017 17:28:49 +0000 (17:28 +0000)]
src/utilities.lisp: Fix docstring formatting.

5 years agolib/keyword.3: Fix some minor formatting errors.
Mark Wooding [Sat, 25 Mar 2017 17:25:32 +0000 (17:25 +0000)]
lib/keyword.3: Fix some minor formatting errors.

5 years agosrc/c-types-class-impl.lisp (find-sod-class): Improve error reporting.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-class-impl.lisp (find-sod-class): Improve error reporting.

The built-in simple type names are now properly baked in, in the
`*simple-type-map*' hash table, rather than being exported by the
`builtin' module, so check there before reporting a type as `unknown'.

5 years agosrc/c-types-class-impl.lisp (find-class-type): Don't repeat type name.
Mark Wooding [Thu, 26 May 2016 08:26:09 +0000 (09:26 +0100)]
src/c-types-class-impl.lisp (find-class-type): Don't repeat type name.

It turns out that if some type name isn't a class, then it doesn't
usually have a very interesting description which is different from its
name.

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.