]> git.draconx.ca Git - cdecl99.git/log
cdecl99.git
12 years agoAdd support for parsing English-like declarations.
Nick Bowler [Wed, 13 Jul 2011 23:53:37 +0000 (19:53 -0400)]
Add support for parsing English-like declarations.

I think that makes the parser almost feature-complete.

12 years agoFix return value of typespec checks.
Nick Bowler [Sat, 16 Jul 2011 17:30:10 +0000 (13:30 -0400)]
Fix return value of typespec checks.

Returning -1 here means "true"; we actually want to return "false".

12 years agoForbid arrays of functions.
Nick Bowler [Fri, 15 Jul 2011 00:34:42 +0000 (20:34 -0400)]
Forbid arrays of functions.

12 years agoFix error name of ellipsis token.
Nick Bowler [Thu, 14 Jul 2011 23:40:39 +0000 (19:40 -0400)]
Fix error name of ellipsis token.

So it says unexpected ... instead of unexpected .

12 years agoFix rendering of non-prototype function declarations.
Nick Bowler [Thu, 14 Jul 2011 23:21:55 +0000 (19:21 -0400)]
Fix rendering of non-prototype function declarations.

When there are no parameters, the closing parenthesis was not printed.
Fix that up.

12 years agoAvoid modifying the input command string.
Nick Bowler [Wed, 13 Jul 2011 00:41:15 +0000 (20:41 -0400)]
Avoid modifying the input command string.

This gives the individual command functions access to the entire
(unadultered) input from the user.

12 years agoFix yyerror's signature.
Nick Bowler [Tue, 12 Jul 2011 22:20:12 +0000 (18:20 -0400)]
Fix yyerror's signature.

This only worked because we ignore those parameters.

12 years agoAdd support for --execute and --file options.
Nick Bowler [Sun, 10 Jul 2011 16:48:27 +0000 (12:48 -0400)]
Add support for --execute and --file options.

For useful non-interactive invocation.

12 years agoSplit up interactive/noninteractive loops.
Nick Bowler [Sun, 10 Jul 2011 16:25:37 +0000 (12:25 -0400)]
Split up interactive/noninteractive loops.

Readline isn't well suited for non-interactive loops since it tends to
print stuff to standard output.  So use two loops: a readline-based one
and a getline-based one.

12 years agoAdd support for outputting declarations as C code.
Nick Bowler [Sat, 9 Jul 2011 00:00:44 +0000 (20:00 -0400)]
Add support for outputting declarations as C code.

This permits us to define a nifty "simplify" function.

12 years agoAdd support for imaginary types.
Nick Bowler [Fri, 8 Jul 2011 01:04:19 +0000 (21:04 -0400)]
Add support for imaginary types.

Somehow these got forgotten.

12 years agoReject mixed type names / declarations.
Nick Bowler [Thu, 7 Jul 2011 23:45:04 +0000 (19:45 -0400)]
Reject mixed type names / declarations.

Things like int,; make little sense.  Reject it.

12 years agoMove advance/advance_ into common code.
Nick Bowler [Thu, 7 Jul 2011 23:35:56 +0000 (19:35 -0400)]
Move advance/advance_ into common code.

These will be useful for other output routines.

12 years agoUse the reentrant scanner API.
Nick Bowler [Thu, 7 Jul 2011 22:33:44 +0000 (18:33 -0400)]
Use the reentrant scanner API.

12 years agoAdd initial support for non-interactive modes to cdecl99.
Nick Bowler [Thu, 7 Jul 2011 22:32:07 +0000 (18:32 -0400)]
Add initial support for non-interactive modes to cdecl99.

12 years agoValidate function return types.
Nick Bowler [Thu, 7 Jul 2011 02:31:48 +0000 (22:31 -0400)]
Validate function return types.

12 years agoCheck specifiers for type names.
Nick Bowler [Thu, 7 Jul 2011 01:44:12 +0000 (21:44 -0400)]
Check specifiers for type names.

Type names cannot have storage-class or function specifiers.

12 years agoValidate declspecs in function parameters.
Nick Bowler [Thu, 7 Jul 2011 00:51:31 +0000 (20:51 -0400)]
Validate declspecs in function parameters.

12 years agoDon't gratuitously reject inline specifiers.
Nick Bowler [Thu, 7 Jul 2011 00:39:47 +0000 (20:39 -0400)]
Don't gratuitously reject inline specifiers.

We actually do support functions now, so we need to handle inline.
Turns out the last user of the old output routines (the code that
prints "inline") didn't actually work properly, so port it over to
the new interface.

12 years agoReject declarations of void objects.
Nick Bowler [Thu, 7 Jul 2011 00:38:57 +0000 (20:38 -0400)]
Reject declarations of void objects.

12 years agoInitial support for function declarators.
Nick Bowler [Wed, 6 Jul 2011 23:58:35 +0000 (19:58 -0400)]
Initial support for function declarators.

Wow.  That was way harder than I thought it would be.

12 years agoAdd missing copyright headers.
Nick Bowler [Wed, 6 Jul 2011 23:51:39 +0000 (19:51 -0400)]
Add missing copyright headers.

12 years agoKill the "horizontal" declarator chain.
Nick Bowler [Wed, 6 Jul 2011 02:43:42 +0000 (22:43 -0400)]
Kill the "horizontal" declarator chain.

The "next" pointer in declarators is used in exactly one place: the list
of declarators of a declaration.  Move this chain to the toplevel so
that we get a list of declarations instead: now every struct cdecl has
exatly one declarator.

This helps eliminate the nasty hack in "explain" to print multiple
declarators.

12 years agoMake an explicit null declarator type.
Nick Bowler [Wed, 6 Jul 2011 01:12:59 +0000 (21:12 -0400)]
Make an explicit null declarator type.

Now that we have a child pointers in every declarator, this is way
cleaner than abusing the identifier type.

12 years agoFix broken include guard.
Nick Bowler [Tue, 5 Jul 2011 23:20:37 +0000 (19:20 -0400)]
Fix broken include guard.

12 years agoAdd a child pointer to cdecl_declarator.
Nick Bowler [Tue, 5 Jul 2011 22:23:52 +0000 (18:23 -0400)]
Add a child pointer to cdecl_declarator.

This eliminates the need for separate child pointers for each
declarator type.

12 years agoFix pointer declarators.
Nick Bowler [Tue, 5 Jul 2011 22:23:01 +0000 (18:23 -0400)]
Fix pointer declarators.

Support for parsing pointer types like int ** was broken a while back.
Fix it up.

12 years agoSplit advance into two parts.
Nick Bowler [Tue, 5 Jul 2011 00:17:51 +0000 (20:17 -0400)]
Split advance into two parts.

We need to avoid printing spaces after things on occasion.  This makes
the code a little simpler, too.

12 years agoAdd support for empty declarators.
Nick Bowler [Mon, 4 Jul 2011 22:11:51 +0000 (18:11 -0400)]
Add support for empty declarators.

This allows the parser to recognize type names which are required for
function prototypes, as well as actual declarations.  This also makes it
easy to let the user ask for an explanation of types.  For instance:

  explain int *(*[])[];

prints

  type array of pointer to array of pointer to int.

12 years agoUse assert(0) instead of abort for exceptional cases.
Nick Bowler [Mon, 4 Jul 2011 22:11:48 +0000 (18:11 -0400)]
Use assert(0) instead of abort for exceptional cases.

assert prints helpful context info to stderr.  These cases should never
be reached except by programmer error.

12 years agoAdd support for explaining multiple declarators.
Nick Bowler [Mon, 4 Jul 2011 22:10:49 +0000 (18:10 -0400)]
Add support for explaining multiple declarators.

12 years agoFix error handling in explain.
Nick Bowler [Mon, 4 Jul 2011 22:10:30 +0000 (18:10 -0400)]
Fix error handling in explain.

On a memory allocation failure, we leak the decl allocated by the
parser.  Fix that up.

12 years agoAdd support for array declarators.
Nick Bowler [Sat, 25 Jun 2011 13:45:16 +0000 (09:45 -0400)]
Add support for array declarators.

Currently there is a (I think quite reasonable) restriction that the
array length either be unspecified, a positive integer constant, an
identifier, or *.

12 years agoAdd support for pointer declarators.
Nick Bowler [Sat, 25 Jun 2011 13:41:41 +0000 (09:41 -0400)]
Add support for pointer declarators.

12 years agoFix comment about automatic generation in typenames.sed.
Nick Bowler [Sat, 25 Jun 2011 13:34:09 +0000 (09:34 -0400)]
Fix comment about automatic generation in typenames.sed.

Last I checked, typenames.sed is not validtypes.sed.

12 years agoRestrict the contexts in which typedef names can appear.
Nick Bowler [Sat, 25 Jun 2011 12:52:17 +0000 (08:52 -0400)]
Restrict the contexts in which typedef names can appear.

This should resolve a rather nasty ambiguity in the C grammar:

  [declaration] -> [declaration-specifiers] ;
                -> [type-specifier] [declaration-specifiers] ;
                -> int [declaration-specifiers] ;
                -> int [type-specifier] ;
                -> int [typedef-name] ;
                -> int [identifier] ;
                -> int x ;

versus

  [declaration] -> [declaration-specifiers] [init-declarator-list] ;
                -> [type-specifier] [init-declarator-list] ;
                -> int [init-declarator-list] ;
                -> int [init-declarator] ;
                -> int [declarator] ;
                -> int [direct-declarator] ;
                -> int [identifier] ;
                -> int x ;

The standard resolves this ambiguity by having a constraint that is not
part of the context-free grammar.  This ambiguity gets really nasty with
things like int f (x); -- is it a declaration of x with two type
specifiers or a declaration of f (a function with one parameter) with
with one type specifier?

A side-effect of this change is that the parser will now reject
declarations without any type specifiers at all, which probably makes
the error messages a bit less informative.

12 years agoFix VPATH builds from git.
Nick Bowler [Sat, 25 Jun 2011 00:26:25 +0000 (20:26 -0400)]
Fix VPATH builds from git.

In such builds, C source files (that are normally distributed) get
generated, which means they end up in the build tree.  Building them
subsequently fails because headers (in the source tree) are not found.

12 years agoSplit out qualifier explanations from explain_post_specs.
Nick Bowler [Fri, 24 Jun 2011 13:42:53 +0000 (09:42 -0400)]
Split out qualifier explanations from explain_post_specs.

They'll be needed on their own for pointer explanations.

12 years agoFix the distribution.
Nick Bowler [Fri, 24 Jun 2011 00:50:02 +0000 (20:50 -0400)]
Fix the distribution.

Now make distcheck passes.

12 years agoInitial support for explaining declarations.
Nick Bowler [Fri, 24 Jun 2011 00:24:50 +0000 (20:24 -0400)]
Initial support for explaining declarations.

This should support everything that the parser currently does.

12 years agoAdd a function to turn a typemap into a string.
Nick Bowler [Fri, 24 Jun 2011 00:24:32 +0000 (20:24 -0400)]
Add a function to turn a typemap into a string.

12 years agoAllow (and ignore) underscores in the list of type names.
Nick Bowler [Thu, 23 Jun 2011 00:30:53 +0000 (20:30 -0400)]
Allow (and ignore) underscores in the list of type names.

This allows the "true" keywords to be used in the list.

12 years agoKill typemap_is_valid.
Nick Bowler [Thu, 23 Jun 2011 00:30:52 +0000 (20:30 -0400)]
Kill typemap_is_valid.

Just do the check when building the map in the first place.  This
enables more useful error messages, too: the case where there are no
type specifiers at all is certainly worth diagnosing separately from
other kinds of nonsense.

12 years agoAdd initial command parser.
Nick Bowler [Thu, 23 Jun 2011 00:30:50 +0000 (20:30 -0400)]
Add initial command parser.

12 years agoImplement the interactive cdecl99 loop.
Nick Bowler [Thu, 23 Jun 2011 00:30:41 +0000 (20:30 -0400)]
Implement the interactive cdecl99 loop.

Bring in gnulib for getopt_long and readline support.

12 years agoMake cdecl_free more robust by handling a NULL argument.
Nick Bowler [Thu, 23 Jun 2011 00:30:17 +0000 (20:30 -0400)]
Make cdecl_free more robust by handling a NULL argument.

While we're at it, split the function into two so that the parser
doesn't have to call the exported version.

12 years agoMove typemap stuff into a separate file.
Nick Bowler [Tue, 21 Jun 2011 22:29:30 +0000 (18:29 -0400)]
Move typemap stuff into a separate file.

These functions will be generally useful.  They are not part of the
public API, so we use the cdecl__ prefix for internal functions.

While we're at it, make the code easier to understand by automatically
generating the huge switch statement and eliminating the silly macros.

12 years agoRename libcdecl.c to parse-decl.c
Nick Bowler [Tue, 21 Jun 2011 22:29:12 +0000 (18:29 -0400)]
Rename libcdecl.c to parse-decl.c

Paving the way for having more than one source file.

12 years agoDon't use missing for flex.
Nick Bowler [Tue, 21 Jun 2011 22:29:02 +0000 (18:29 -0400)]
Don't use missing for flex.

Oops, that was a leftover from early testing.

12 years agoFix Makefile dependencies.
Nick Bowler [Tue, 21 Jun 2011 22:28:32 +0000 (18:28 -0400)]
Fix Makefile dependencies.

Dependencies of foo.$(OBJEXT) are not honoured when building a libtool
library; instead we need to use foo.lo.

12 years agoAdd m4/.gitignore.
Nick Bowler [Tue, 21 Jun 2011 22:28:18 +0000 (18:28 -0400)]
Add m4/.gitignore.

This ensures that the m4 directory exists in the git checkout.

12 years agoDon't touch unchanged flex/bison headers.
Nick Bowler [Tue, 21 Jun 2011 01:35:13 +0000 (21:35 -0400)]
Don't touch unchanged flex/bison headers.

This prevents some spurious rebuilds.

12 years agoAdd an initial declaration parser.
Nick Bowler [Tue, 21 Jun 2011 01:34:45 +0000 (21:34 -0400)]
Add an initial declaration parser.

12 years agoInitial commit
Nick Bowler [Sun, 19 Jun 2011 17:21:17 +0000 (13:21 -0400)]
Initial commit