kc++1
Generate c++ code from kimwitu++ input
Usage
kc++ [options]
file ...
Overview
kc++ reads the abstract syntax definition, function definitions, rewrite rules and unparse rules from the files given on the command line, or from the standard input if no file arguments were given. It generates for each file.k input file a pair of file.cc and file.h files that contain the translation of the functions defined in the corresponding file.k.
Additionally the following files are generated: csgiok.{h,cc}, rk.{h,cc} and unpk.{h,cc}, that contain the CSGIO-, the rewrite- and the unparse-functions, respectively, and the k.cc and k.h files that contain the grammar tables and the remaining `default' functions as well as the declaration of the classes for each phylum in the definition of the abstract syntax.
If no command line file arguments are given, the translation of the user-defined functions will be generated in stdin.{h,cc} files.
kc++ does not unnecessarily overwrite a file: if a file would be overwritten with its own (identical) contents, it will not be touched. This makes it easy to write an efficient Makefile.
Options
Kimwitu++ features
-
-c, --no-csgio -
no read/write functions (csgio.{h,cc}) are generated.
-
-r, --no-rewrite -
no code for rewrite rules (rk.{h,cc}) is generated.
-
-u, --no-unparse -
no code for unparse rules (unpk.{h,cc}) is generated.
-
-d, -no-printdot -
no printdot functions for printing dot-files (input for the graphviz package) are generated.
-
-t, -no-hashtables -
no code for hastables is generated (works only when both
--no-csgioand--no-printdotare specified).
-
--operator-cast -
generate
operatork.hfor operator_cast<>
C++ compiler options
-
-n, --covariant=C -
use covariant return types; options are
yes(use them),no(don't use them, requires explicit casting), orpre(use preprocessor symbol NO_COVARIANT_RETURN to guard the definitions).
-
--stdafx[=FILE] -
include for Microsoft precompiled header files is generated (default stdafx.h).
-
-e, --dllexport=STRING -
generates string between keyword class and the class name of all operators and phyla (used eg. for DLL export definitions for Windows).
-
-m, --smart-pointer -
generates code for smart pointers (does reference counting).
-
-w, --weak-pointer -
generates code for weak pointers (implies
--smart-pointer).
Options for file generation
-
-s, --suffix=EXT -
extension for generated source files (default cc).
-
-f, --file-prefix=PREF -
prefix for generated files.
-
-o, --overwrite -
always write generated files even if not changed.
-
-y,--yxx-union -
generates file yxx_union.h for yacc++.
Advanced options
-
-l, --no-linedirec -
does not emit line directives (`#line'). This is sometimes handy when you need to debug your program.
-
--comment-line -
prints line comments (`//line') instead of line directives. This may aid debugging when the bugs are not in your code but in Kimwitu++.
-
--dir-line -
prepends the current working directory to the file name in line directives.
-
--rw-loop -
generates a non recursive rewrite function.
-
-p, --pipe=CMD -
filter every input file through CMD. The programm will be called as CMD file
.kand must deliver its output to standard output.
General options
-
-M, --msg-format=PATTERN -
specifies format of (error) messages. The actual message is appended. PATTERN can contain:
-
%p (program name)
%s (severity)
%f (file name)
%d (current working directory)
%l (line number)
%c (column)
-
-q, --quiet -
be quite quiet about warnings etc., give only return status (not implemented).
-
-v, --verbose -
print additional status information while processing.
-
-W[what] -
enable all warnings; use comma-seperated list for detailed control (can be prefixed with `no')
-
drop – dropped rule bodies (no code generated)
equiv – equivalent patterns (cannot match)
overlap – possibly overlapping patterns
-
-h, --help -
give a short help message.
-
-V, --version -
print the version number of
kc++and exit.
Generated files
- k.{h,cc}
-
the grammar and default functions
- rk.{h,cc}
-
the rewrite view declarations and rewrite functions
- csgiok.{h,cc}
-
the CSGIO functions
- unpk.{h,cc}
-
the unparse view declarations and unparsing functions
- file.{h,cc}
-
translation of user-provided Kimwitu++ functions.
- stdin.{h,cc}
-
translation of user-provided Kimwitu++ functions if no command line file arguments were given.
- yystype.h
-
(or any other name you specify) the YYSTYPE union.
- yxx_union.h
-
the (anonymous?) union (for yacc++, apparently).
Diagnostics
If an error is encountered in the Kimwitu++ input, an appropriate error message will be written on standard error, code generation will be suppressed and a non-zero exit value will be returned. The error messages should be self-explanatory.
Releases
7 releases since Debian 3.0 (Woody); the text changed 3 times.
--comment-line since Debian 5.0 (Lenny);
--dir-line since Debian 5.0 (Lenny);
--dllexport since Debian 5.0 (Lenny);
--msg-format since Debian 5.0 (Lenny);
--operator-cast since Debian 5.0 (Lenny);
--pipe since Debian 5.0 (Lenny);
--rw-loop since Debian 5.0 (Lenny);
--stdafx since Debian 5.0 (Lenny);
-M since Debian 5.0 (Lenny);
-V since Debian 5.0 (Lenny);
-W since Debian 5.0 (Lenny);
-e since Debian 5.0 (Lenny);
-no-hashtables since Debian 5.0 (Lenny);
-no-printdot since Debian 5.0 (Lenny).
--no-hashtables until Debian 4.0 (Etch);
--no-printdot until Debian 4.0 (Etch);
--yystype until Debian 4.0 (Etch);
-b until Debian 4.0 (Etch).