[hackers] [libzahl] Fix typo || Mattias Andrée

2016-05-12 Thread git
commit 5bfbc6a6984e2036bf39b15708647ac5fd003dc2
Author: Mattias Andrée 
AuthorDate: Fri May 13 07:56:59 2016 +0200
Commit: Mattias Andrée 
CommitDate: Fri May 13 07:56:59 2016 +0200

Fix typo

Signed-off-by: Mattias Andrée 

diff --git a/doc/not-implemented.tex b/doc/not-implemented.tex
index 3fd4d37..3934802 100644
--- a/doc/not-implemented.tex
+++ b/doc/not-implemented.tex
@@ -241,8 +241,8 @@ in the future if the demand is high enough.
 }\), undefined for $n < 0$.
 
 
-\subsection{Failing factorial}
-\label{sec:Failing factorial}
+\subsection{Falling factorial}
+\label{sec:Falling factorial}
 
 \( \displaystyle{
 (x)_n = {x! \over (x - n)!}



[hackers] [libzahl] Add version constants and constants that can be used to detect changes || Mattias Andrée

2016-05-12 Thread git
commit 970b82a39d48951bf450dda5945bb4ca7562e9f2
Author: Mattias Andrée 
AuthorDate: Fri May 13 05:43:39 2016 +0200
Commit: Mattias Andrée 
CommitDate: Fri May 13 05:43:39 2016 +0200

Add version constants and constants that can be used to detect changes

Signed-off-by: Mattias Andrée 

diff --git a/zahl.h b/zahl.h
index b224338..2edb23d 100644
--- a/zahl.h
+++ b/zahl.h
@@ -15,6 +15,21 @@
 
 
 
+/* TODO these should be documented*/
+#define ZAHL_VERSION_MAJOR   1L
+#define ZAHL_VERSION_MINOR   1L
+#define ZAHL_VERSION_PATCHLEVEL  0L
+#define ZAHL_VERSION (ZAHL_VERSION_MAJOR * 100L +  \
+ ZAHL_VERSION_MINOR * 1000L+  \
+ ZAHL_VERSION_PATCHLEVEL)
+#define ZAHL_VERSION_STRING  "1.1"
+#define ZAHL_INTERNALS_VERSION   1
+#define ZAHL_ZRANDDEV_COUNT  7
+#define ZAHL_ZRANDDIST_COUNT 3
+#define ZAHL_ZERROR_COUNT6
+
+
+
 #include "zahl/internals.h"
 
 



[hackers] [libzahl] Fix indentation in manual || Mattias Andrée

2016-05-12 Thread git
commit 77e2915791d49b7086483c1fd86c27fce4fb0780
Author: Mattias Andrée 
AuthorDate: Fri May 13 04:44:18 2016 +0200
Commit: Mattias Andrée 
CommitDate: Fri May 13 04:44:18 2016 +0200

Fix indentation in manual

Signed-off-by: Mattias Andrée 

diff --git a/doc/not-implemented.tex b/doc/not-implemented.tex
index 7269251..3fd4d37 100644
--- a/doc/not-implemented.tex
+++ b/doc/not-implemented.tex
@@ -546,9 +546,9 @@ character manually with using {\tt zxor}.
 \label{sec:Character retrieval}
 
 \begin{alltt}
-   uint64_t
-   getu(z_t a)
-   \{
-   return zzero(a) ? 0 : a->chars[0];
-   \}
+uint64_t
+etu(z_t a)
+\{
+return zzero(a) ? 0 : a->chars[0];
+\}
 \end{alltt}



[hackers] [libzahl] Miscellaneous stuff || Mattias Andrée

2016-05-12 Thread git
commit 16a001c8fe4e5ca99d5aafdd8ed02a35f09b6caa
Author: Mattias Andrée 
AuthorDate: Fri May 13 04:38:09 2016 +0200
Commit: Mattias Andrée 
CommitDate: Fri May 13 04:38:09 2016 +0200

Miscellaneous stuff

Signed-off-by: Mattias Andrée 

diff --git a/Makefile b/Makefile
index 8daf15d..73c1aad 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,11 @@ TEXSRC =\
doc/libzahls-design.tex\
doc/get-started.tex\
doc/miscellaneous.tex\
-   doc/arithmetic.tex
+   doc/arithmetic.tex\
+   doc/bit-operations.tex\
+   doc/number-theory.tex\
+   doc/random-numbers.tex\
+   doc/not-implemented.tex
 
 HDR_PUBLIC = zahl.h $(HDR_SEMIPUBLIC)
 HDR= $(HDR_PUBLIC) $(HDR_PRIVATE)
diff --git a/TODO b/TODO
index 0327bca..b748650 100644
--- a/TODO
+++ b/TODO
@@ -4,6 +4,10 @@ It uses optimised division algorithm that requires that d|n.
 Add zsets_radix
 Add zstr_radix
 
+Can zmodpowu and zmodpow be improved using some other algorithm?
+Is it worth implementing precomputed optimal
+  addition-chain exponentiation in zpowu?
+
 Test big endian
 Test always having .used > 0 for zero
   Test negative/non-negative instead of sign
diff --git a/doc/arithmetic.tex b/doc/arithmetic.tex
index e90f607..52eae11 100644
--- a/doc/arithmetic.tex
+++ b/doc/arithmetic.tex
@@ -186,8 +186,9 @@ can be expressed as a simple formula
 
 \vspace{-1em}
 \[ \hspace*{-0.4cm}
-a^b = \prod_{i = 0}^{\lceil \log_2 b \rceil}
-\left ( a^{2^i} \right )^{\left \lfloor {\displaystyle{b \over 2^i}} 
\hspace*{-1ex} \mod 2 \right \rfloor}
+a^b =
+\prod_{k \in \textbf{Z}_{+} ~:~ \left \lfloor {b \over 2^k} \hspace*{-1ex} 
\mod 2 \right \rfloor = 1}
+a^{2^k}
 \]
 
 \noindent
diff --git a/doc/bit-operations.tex b/doc/bit-operations.tex
new file mode 100644
index 000..83a08ed
--- /dev/null
+++ b/doc/bit-operations.tex
@@ -0,0 +1,56 @@
+\chapter{Bit operations}
+\label{chap:Bit operations}
+
+TODO
+
+\vspace{1cm}
+\minitoc
+
+
+\newpage
+\section{Boundary}
+\label{sec:Boundary}
+
+TODO % zbits zlsb
+
+
+\newpage
+\section{Logic}
+\label{sec:Logic}
+
+TODO % zand zor zxor znot
+
+
+\newpage
+\section{Shift}
+\label{sec:Shift}
+
+TODO % zlsh zrsh
+
+
+\newpage
+\section{Truncation}
+\label{sec:Truncation}
+
+TODO % ztrunc
+
+
+\newpage
+\section{Split}
+\label{sec:Split}
+
+TODO % zsplit
+
+
+\newpage
+\section{Bit manipulation}
+\label{sec:Bit manipulation}
+
+TODO % zbset
+
+
+\newpage
+\section{Bit test}
+\label{sec:Bit test}
+
+TODO % zbtest
diff --git a/doc/libzahl.tex b/doc/libzahl.tex
index 83d74c4..2bfc5c0 100644
--- a/doc/libzahl.tex
+++ b/doc/libzahl.tex
@@ -82,6 +82,10 @@ all copies or substantial portions of the Document.
 \input doc/get-started.tex
 \input doc/miscellaneous.tex
 \input doc/arithmetic.tex
+\input doc/bit-operations.tex
+\input doc/number-theory.tex
+\input doc/random-numbers.tex
+\input doc/not-implemented.tex
 
 
 \appendix
diff --git a/doc/not-implemented.tex b/doc/not-implemented.tex
new file mode 100644
index 000..7269251
--- /dev/null
+++ b/doc/not-implemented.tex
@@ -0,0 +1,554 @@
+\chapter{Not implemented}
+\label{chap:Not implemented}
+
+In this chapter we maintain a list of
+features we have choosen not to implement,
+but would fit into libzahl had we not have
+our priorities straight. Functions listed
+herein will only be implemented if there
+is shown that it would be overwhelmingly
+advantageous.
+
+\vspace{1cm}
+\minitoc
+
+
+\newpage
+\section{Extended greatest common divisor}
+\label{sec:Extended greatest common divisor}
+
+\begin{alltt}
+void
+extgcd(z_t bézout_coeff_1, z_t bézout_coeff_2, z_t gcd
+   z_t quotient_1, z_t quotient_2, z_t a, z_t b)
+\{
+#define old_r gcd
+#define old_s bézout_coeff_1
+#define old_t bézout_coeff_2
+#define s quotient_2
+#define t quotient_1
+z_t r, q, qs, qt;
+int odd = 0;
+zinit(r), zinit(q), zinit(qs), zinit(qt);
+zset(r, b), zset(old_r, a);
+zseti(s, 0), zseti(old_s, 1);
+zseti(t, 1), zseti(old_t, 0);
+while (!zzero(r)) \{
+odd ^= 1;
+zdivmod(q, old_r, old_r, r), zswap(old_r, r);
+zmul(qs, q, s), zsub(old_s, old_s, qs);
+zmul(qt, q, t), zsub(old_t, old_t, qt);
+zswap(old_s, s), zswap(old_t, t);
+\}
+odd ? abs(s, s) : abs(t, t);
+zfree(r), zfree(q), zfree(qs), zfree(qt);
+\}
+\end{alltt}
+
+
+\newpage
+\section{Least common multiple}
+\label{sec:Least common multiple}
+
+\( \displaystyle{
+\mbox{lcm}(a, b) = {\lvert a \cdot b \rvert \over \mbox{gcd}(a, b)}
+}\)
+
+
+\newpage
+\section{Modular multiplicative inverse}
+\label{sec:Modular multiplicative inverse}
+
+\begin{alltt}
+int
+modinv(z_t inv, z_t a, z_t m)
+\{
+z_t x, _1, _2, _3, gcd, mabs, apos;
+int invertible, aneg = zsignum(a) < 0;
+zinit(x), zinit(_1), zinit(_2), zinit(_3), zinit(gcd);
+*mabs = *m;
+zabs(mabs, mabs);
+if (aneg) \{
+zinit(apos);
+zset(apos, a);
+if (zcmpmag(apos, mabs))
+zmod(a

Re: [hackers] [scc] Implement proper #pragma support || sin

2016-05-12 Thread Hiltjo Posthuma
On Thu, May 12, 2016 at 7:29 PM,   wrote:
> commit c9cccba538e9870b1177ae4c57dad716e9f02185
> Author: sin 
> AuthorDate: Wed May 11 17:38:15 2016 +0100
> Commit: Roberto E. Vargas Caballero 
> CommitDate: Wed May 11 17:35:52 2016 +0200
>
> Implement proper #pragma support
>

This patch seems to have a gaping flaw. It doesn't seem to compile on
TempleOS for me.



Re: [hackers] [scc] Implement proper #pragma support || sin

2016-05-12 Thread Silvan Jegen
On Thu, May 12, 2016 at 11:45:45AM -0700, Menche wrote:
> wat

Haha, I compiled and ran it and it's thing of beauty!




[hackers] [scc] Implement proper #pragma support || sin

2016-05-12 Thread git
commit c9cccba538e9870b1177ae4c57dad716e9f02185
Author: sin 
AuthorDate: Wed May 11 17:38:15 2016 +0100
Commit: Roberto E. Vargas Caballero 
CommitDate: Wed May 11 17:35:52 2016 +0200

Implement proper #pragma support

diff --git a/cc1/cpp.c b/cc1/cpp.c
index 2015b4e..2dc1b2c 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -546,8 +546,14 @@ set_line:
 static void
 pragma(void)
 {
+   static char magic[] = {
+   #include "pragma.msg"
+   }, *p = magic;
+
if (cppoff)
return;
+   for (; *p; p++)
+   putc(*p, stderr);
*input->p = '\0';
next();
 }
diff --git a/cc1/pragma.msg b/cc1/pragma.msg
new file mode 100644
index 000..cbd2f9b
--- /dev/null
+++ b/cc1/pragma.msg
@@ -0,0 +1,105 @@
+0x2a, 0x20, 0x67, 0x20, 0x6f, 0x20, 0x61, 0x20, 0x74, 0x20, 0x73, 0x20,
+0x65, 0x20, 0x78, 0x20, 0x2a, 0x20, 0x67, 0x20, 0x6f, 0x20, 0x61, 0x20,
+0x74, 0x20, 0x73, 0x20, 0x65, 0x20, 0x78, 0x20, 0x2a, 0x20, 0x67, 0x20,
+0x6f, 0x20, 0x61, 0x20, 0x74, 0x20, 0x73, 0x20, 0x65, 0x20, 0x78, 0x20,
+0x2a, 0x0a, 0x67, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x67, 0x0a, 0x6f, 0x20, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x6f, 0x0a, 0x61, 0x7c, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x0a, 0x74, 0x7c, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x60, 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x3a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x0a, 0x73, 0x60,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x7c, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x73, 0x0a,
+0x65, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20,
+0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x20, 0x20, 0x5c,
+0x5c, 0x5c, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x5f, 0x5f, 0x20, 0x5c, 0x5c,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3a, 0x20, 0x20, 0x20, 0x20,
+0x65, 0x0a, 0x78, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x5c, 0x2f, 0x20, 0x20, 0x20, 0x5f, 0x2d, 0x2d, 0x7e, 0x7e, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7e, 0x2d, 0x2d, 0x5f,
+0x5f, 0x7c, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20,
+0x20, 0x20, 0x78, 0x0a, 0x2a, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x5c, 0x5f, 0x2d, 0x7e, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x7e, 0x2d, 0x5f, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x7c,
+0x20, 0x20, 0x20, 0x20, 0x2a, 0x0a, 0x67, 0x20, 0x20, 0x20, 0x20, 0x5c,
+0x5f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x5f, 0x2e, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
+0x2d, 0x2e, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5c, 0x7c, 0x20, 0x20,
+0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x67, 0x0a, 0x6f, 0x20, 0x20, 0x20,
+0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x5f, 0x5f,
+0x5f, 0x5f, 0x5f, 0x5f, 0x2f, 0x2f, 0x20, 0x5f, 0x20, 0x5f, 0x5f, 0x5f,
+0x20, 0x5f, 0x20, 0x28, 0x5f, 0x28, 0x5f, 0x5f, 0x3e, 0x20, 0x20, 0x5c,
+0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x0a, 0x61, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x2e, 0x20,
+0x20, 0x43, 0x20, 0x5f, 0x5f, 0x5f, 0x29, 0x20, 0x20, 0x5f, 0x5f, 0x5f,
+0x5f, 0x5f, 0x5f, 0x20, 0x28, 0x5f, 0x28, 0x5f, 0x5f, 0x5f, 0x5f, 0x3e,
+0x20, 0x20, 0x7c, 0x20, 0x20, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x61, 0x0a,
+0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x5c, 0x20, 0x7c,
+0x20, 0x20, 0x20, 0x43, 0x20, 0x5f, 0x5f, 0x5f, 0x5f, 0x29, 0x2f, 0x20,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x28, 0x5f, 0x5f, 0x5f, 0x5f,
+0x5f, 0x3e, 0x20, 0x20, 0x7c, 0x5f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20,
+0x74, 0x0a, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x20, 0x2f,
+0x5c, 0x7c, 0x20, 0x20, 0x20, 0x43, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x29,
+0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7c, 0x20, 0x20, 0x28, 0x5f,
+0x5f, 0x5f, 0x3e, 0x20, 0x20, 0x20, 0x2f, 0x20, 0x20, 0x5c, 0x20, 0x20,

[hackers] [scc] Fix spelling and update cc1/ir.md || FRIGN

2016-05-12 Thread git
commit 12ed188e75849215099d1f3dedb37717a42cbe44
Author: FRIGN 
AuthorDate: Thu May 12 09:06:01 2016 +0200
Commit: FRIGN 
CommitDate: Thu May 12 09:06:41 2016 +0200

Fix spelling and update cc1/ir.md

cc1 changed quite substantially. This first run tries to cover
these changes in the documentation.

Also, many spelling and language errors were corrected.

diff --git a/cc1/ir.md b/cc1/ir.md
index 86b4e1c..d60aa3a 100644
--- a/cc1/ir.md
+++ b/cc1/ir.md
@@ -1,29 +1,29 @@
-# Scc intermediate representation #
+# scc intermediate representation #
 
-Scc IR tries to be be a simple and easily parseable intermediate
-representation, and it makes it a bit terse and criptic. The main
+The scc IR tries to be be a simple and easily parseable intermediate
+representation, and it makes it a bit terse and cryptic. The main
 characteristic of the IR is that all the types and operations are
 represented with only one letter, so parsing tables can be used
 to parse it.
 
-The language is composed by lines, which represent statements,
-and fields in statements are separated by tabulators. Declaration
-statements begin in column 0, meanwhile expressions and control
-flow begin with a tabulator. When the front end detects an error
-it closes the output stream.
+The language is composed of lines, representing statements.
+Each statement is composed of tab-separated fields.
+Declaration statements begin in column 0, expressions and
+control flow begin with a tabulator.
+When the frontend detects an error, it closes the output stream.
 
 ## Types ##
 
-Types are represented using upper case letters:
+Types are represented with uppercase letters:
 
-* C -- char
-* I -- int
-* W -- long
-* O -- long long
-* M -- unsigned char
-* N -- unsigned int
-* Z -- unsigned long
-* Q -- unsigned long long
+* C -- signed8-Bit integer
+* I -- signed   16-Bit integer
+* W -- signed   32-Bit integer
+* O -- signed   64-Bit integer
+* M -- unsigned  8-Bit integer
+* N -- unsigned 16-Bit integer
+* Z -- unsigned 32-Bit integer
+* Q -- unsigned 64-Bit integer
 * 0 -- void
 * P -- pointer
 * F -- function
@@ -35,104 +35,124 @@ Types are represented using upper case letters:
 * D -- double
 * H -- long double
 
-This list is built for the original Z80 backend, where 'int'
-had the same size than 'short'. Several types need an identifier
-after the type letter, mainly S, F, V and U, to be able to
-differentiate between different structs, functions, vectors and
-unions (S1, V12 ...).
+This list has been built for the original Z80 backend, where 'int'
+has the same size as 'short'. Several types (S, F, V, U and others) need
+an identifier after the type letter for better differentiation
+between multiple structs, functions, vectors and unions (S1, V12 ...)
+naturally occuring in a C-program.
 
-## Storage class ##
+## Storage classes ##
 
-Storage class is represented using upper case letters:
+The storage classes are represented using uppercase letters:
 
 * A -- automatic
 * R -- register
 * G -- public (global variable declared in the module)
 * X -- extern (global variable declared in another module)
-* Y -- private (file scoped variable)
-* T -- local (function scopped static variable)
+* Y -- private (variable in file-scope)
+* T -- local (static variable in function-scope)
 * M -- member (struct/union member)
 * L -- label
 
 ## Declarations/definitions ##
 
-Variables names are composed by a storage class and an identifier,
-A1, R2 or T3. Declarations/definitions are composed by a variable
+Variable names are composed of a storage class and an identifier
+(e.g. A1, R2, T3).
+Declarations and definitions are composed of a variable
 name, a type and the name of the variable:
 
-   A1  I   i
-   R2  C   c
-   A3  S4  str
+   A1  I   maxweight
+   R2  C   flag
+   A3  S4  statstruct
 
 ### Type declarations ###
 
-Some declarations need a previous declaration of the types involved
-in the variable declaration. In the case of members, they form part
-of the last struct or union declared.
+Some declarations (e.g. structs) involve the declaration of member
+variables.
+Struct members are declared normally after the type declaration in
+parentheses.
 
-For example the next code:
+For example the struct declaration
 
struct foo {
int i;
long c;
} var1;
 
-will generate the next output:
-
-   S2  foo
-   M3  I   i
-   M4  W   c
-   G5  S2  var1
+generates
 
+   S2  foo (
+   M3  I   i
+   M4  W   c
+   )
+   G5  S2  var1
 
 ## Functions ##
 
-A function prototype like
+A function prototype
+
+   int printf(char *cmd, int flag, void *data);
+
+will generate a type declaration and a variable declaration
+
+   F5  P   I   P
+   X1  F5  printf
+
+The first line gives the function-typ