Skip to content

Commit

Permalink
merge macros and macros-core (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhrr committed Dec 29, 2016
1 parent 904da26 commit a738372
Show file tree
Hide file tree
Showing 33 changed files with 5,501 additions and 1,323 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Expand Up @@ -393,9 +393,8 @@ standard_library (modules/ctime.dt ctime macros)
standard_library (modules/clocale.dt clocale drt)
standard_library (modules/cstdio-core.dt cstdio-core drt)
standard_library (modules/introspection.dt introspection drt)
standard_library (modules/macros-core.dt macros-core cstdio-core)
standard_library (modules/stdlib.dt stdlib macros-core introspection)
standard_library (modules/macros.dt macros cstdio-core macros-core introspection)
standard_library (modules/macros.dt macros cstdio-core introspection)
standard_library (modules/stdlib.dt stdlib macros introspection)
standard_library (modules/operator-macros.dt operator-macros macros stdlib)
standard_library (modules/assert.dt assert macros cstdio cstdlib stdlib)
standard_library (modules/concepts-core.dt concepts-core macros assert unistd cstring)
Expand Down
10 changes: 4 additions & 6 deletions README.md
Expand Up @@ -196,10 +196,8 @@ able to be built. It has been tested on the following:
0)))
```
```
> Struct: Point
> Member count: 2
> Member 1: x
> Member 2: y
> ./introspection.dt:8:7: error: not in scope: 'let'
> ./introspection.dt:18:6: error: not in scope: 'show-struct-details'
```

**error-reporting**
Expand All @@ -221,8 +219,8 @@ able to be built. It has been tested on the following:
0)))
```
```
> ./error-reporting.dt:13:23: error: struct type does not exist (see macro at 13:5)
> ./error-reporting.dt:13:5: error: macro expansion error (see previous)
> ./error-reporting.dt:6:6: error: not in scope: 'let'
> ./error-reporting.dt:13:6: error: not in scope: 'assert-is-struct'
```

**derivations**
Expand Down
11 changes: 5 additions & 6 deletions doc/1-7-macros.md
Expand Up @@ -95,12 +95,11 @@ a pointer to a `DNode` (static). For example:

(def const-string (macro extern (void) (q (p (const char)))))

There are two principal standard libraries that deal with macros:
[`macros-core`](./2-4-macros-core.md) and [`macros`](./2-6-macros.md).
The former provides many functions that ease macro authorship. The
latter provides the quasiquotation (`qq`) macro, which is one of the
more useful macro-writing macros. For example, an `unless` (opposite
of `if`) macro would look like so, when using `qq`:
The standard library for dealing with macros is (unsurprisingly)
[`macros`](./2-6-macros.md). It provides many functions that ease
macro authorship, as well as the quasiquotation (`qq`) macro, which is
one of the more useful macro-writing macros. For example, an `unless`
(opposite of `if`) macro would look like so, when using `qq`:

(def unless (macro extern (expr tc fc)
(qq if (not (uq expr)) (uq tc) (uq fc))))
Expand Down
225 changes: 225 additions & 0 deletions doc/2-10-utility.md
@@ -0,0 +1,225 @@
# Dale

[Previous](./2-9-concepts.md) | [Next](./2-11-derivations.md)

## 2.10 utility

### Details

Module: utility

### Description

Provides the common functions and macros used by the container and
algorithm modules.



### Functions

#### `make-type-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type string prefix.
* `(T (p DNode))`: The type node.
* `(buf (p char))`: The buffer for the type string.


Writes the prefix, and the internal string representation of the type
node, to the provided buffer. If the type node is a token that begins
with a digit, then the token's contents are written to the buffer
instead.


#### `make-type-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type string prefix.
* `(T1 (p DNode))`: The first type node.
* `(T2 (p DNode))`: The second type node.
* `(buf (p char))`: The buffer for the type string.


As per the earlier implementation, except that it takes two type
nodes.


#### `make-type-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type string prefix.
* `(T1 (p DNode))`: The first type node.
* `(T2 (p DNode))`: The second type node.
* `(T3 (p DNode))`: The third type node.
* `(buf (p char))`: The buffer for the type string.


As per the earlier implementation, except that it takes three type
nodes.


#### `make-type-display-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type display string prefix.
* `(T (p DNode))`: The type node.
* `(buf (p char))`: The buffer for the type display string.


Similar to `make-type-string`, except that it adds the display
representation (i.e. the one set by way of `register-type`, if
applicable) to the buffer, rather than the internal representation.


#### `make-type-display-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type display string prefix.
* `(T1 (p DNode))`: The first type node.
* `(T2 (p DNode))`: The second type node.
* `(buf (p char))`: The buffer for the type display string.


As per the earlier implementation, except that it takes two type
nodes.


#### `make-type-display-string`

Linkage: `extern`
Returns: `bool`
Parameters:

* `(mc (p MContext))`: An MContext.
* `(prefix (p (const char)))`: The type display string prefix.
* `(T1 (p DNode))`: The first type node.
* `(T2 (p DNode))`: The second type node.
* `(T3 (p DNode))`: The third type node.
* `(buf (p char))`: The buffer for the type display string.


As per the earlier implementation, except that it takes two type
nodes.




### Concept macros

#### `Pair`

Linkage: `extern`
Parameters:

* `(T1 Type)`: The first type node.
* `(T2 Type)`: The second type node.


Expands to a struct definition with two members, named `first` and
`second`.


#### `Triple`

Linkage: `extern`
Parameters:

* `(T1 Type)`: The first type node.
* `(T2 Type)`: The second type node.
* `(T3 Type)`: The third type node.


Expands to a struct definition with three members, named `first`,
`second` and `third`.




### Macros

#### `def-type-macro`

Linkage: `extern`
Parameters:

* `name`: The type macro name.


Takes a node as its single argument. Constructs a macro with that
name that takes one arbitrary type and expands to the concatenation of
that name and the stringification of the type.


#### `Iterator`

Linkage: `extern`
Parameters:

* `T`: The type node.


Expands to a string that can be used as the `Iterator` type name for
the argument type.


#### `ReverseIterator`

Linkage: `extern`
Parameters:

* `T`: The type node.


Expands to a string that can be used as the `Iterator` type name for
the argument type.


#### `Pair`

Linkage: `extern`
Parameters:

* `T1`: The first type node.
* `T2`: The second type node.


Expands to the concrete type name of the `Pair` generated by way of
the concept macro.


#### `Triple`

Linkage: `extern`
Parameters:

* `T1`: The first type node.
* `T2`: The second type node.
* `T3`: The third type node.


Expands to the concrete type name of the `Triple` generated by way of
the concept macro.


[Previous](./2-9-concepts.md) | [Next](./2-11-derivations.md)

0 comments on commit a738372

Please sign in to comment.