UPCDECL(1)
β¨ NAME β¨
okay so bestie, meet upcdecl β thatβs UPCDECL(1) on the User Commands page β the UPC type explanation and construction tool, version 0.6. Itβs your text-based bestie for translating English versions of UPC declarations into UPC code and vice versa, and it is lowkey iconic for making confusing declarations make sense. π
π¦ SYNOPSIS π¦
upcdecl [options] [ explain | declare | cast | files... ]
π DESCRIPTION π
upcdecl is a simple tool based off the original cdecl tool written in the late 80βs by Graham Ross et al. Itβs a text-based tool with two main modes of operation: translating English versions of UPC declarations to UPC code, and vice versa. It accepts commands using a very simple grammar, such as explain int c or declare c as pointer to shared int. Typing help with no arguments inside upcdecl will display a simplified version of the grammar the tool uses, or see the mygram.txt file in the installation directory for the full grammar. See the EXAMPLES section for more example usage. β¨
If files given on the command line start with explain, declare, cast, or set, the rest of the input on the command line is interpreted as a command instead of a set of filenames. Otherwise, each file is opened and the contents of the file are interpreted as upcdecl commands.
There are six statements in the language. bestie, hereβs the whole lineup:
- The
declarestatement composes a UPC type declaration from a verbose description. - The
caststatement composes a UPC type cast as might appear in an expression. - The
explainstatement decodes a UPC type declaration or cast, producing a verbose description. - The
help(or?) statement provides a help message. - The
quit(orexit) statement (or the end of file) exits the program. - The
setstatement allows the command line options to be set interactively.
Each statement is separated by a semicolon or a newline. π
π OPTIONS π
-hβ see this message β¨-qβ suppress theupcdecl>prompt. Equivalent to thequietset option.-rβ donβt useTerm::ReadLinefor input. Use this option if you have problems with the Perl-based ReadLine that is bundled with the program. Typingsetwith no arguments at theupcdeclprompt will tell you which module is being used for input.-pβ disable spaces around pointers in C output. (Eg,declare f as pointer to pointer to int->int **finstead ofint * * f.) Equivalent to thenopointerspacesset option.-cβ create compilable output. Adds;to variable declarations and{}to function declarations indeclareoutput. Equivalent to thecreateset option.-t <test file>β test using file as input. The test file should have the following format for each line:input | expected output. Not useful for end users.-vβ verbose UPC english explanations. Include implicitlocalin english output (explain int c->declare c as local int). Equivalent to theupcverboseset option.-Vβ showupcdeclversion and exit.
πΈ EXAMPLES πΈ
To have upcdecl display UPC code for an English description, use the declare statement:
upcdecl> declare f as const int
const int f
You can use pointer to, array of, and function returning to make arbitrarily complex definitions:
upcdecl> declare f as pointer to array of function returning pointer to volatile int
volatile int * (* f)[]()
Use the shared keyword to have upcdecl return UPC declarations:
upcdecl> declare f as shared array 55 of int
shared [1] int f[55]
When followed by blocksize, the shared keyword also takes arbitrary numerical blocksizes or one of automatic, cyclic, indefinite:
upcdecl> declare f as shared blocksize 5 pointer to shared blocksize indefinite pointer to function returning shared blocksize cyclic int
shared [1] int (* shared [] * shared [5] f)()
Additionally, the cast statement may be used to show how to perform a cast:
upcdecl> cast c into shared blocksize indefinite int
(shared [] int)c
To make sense of a UPC declaration, use the explain command:
upcdecl> explain shared [4] int (*f)(int, int, int)
declare f as pointer to function (int, int, int) returning shared (blocksize 4) int
upcdecl> explain shared [] int *const shared c
declare c as const shared (blocksize cyclic) pointer to shared (blocksize indefinite) int
π BUGS π
- As in the original
cdecltool, the English syntax is very verbose. π - There are even less semantic checks done for
upcdeclthan the originalcdecl. - The tool accepts
shared void fas a valid C declaration. not me side-eyeing that one π - The
cdeclgrammar used as a basis forupcdeclwas written before the ANSI C standard was completed (and well before ISO C99 was finished). Some attempt has been made to update the grammar to accept valid ISO C99 code, but there are undoubtedly bits of valid code that will be rejected by the parser. upcdeclwill parse many simple arithmetic expressions inside blocksize declarations or array dimensions, but does not understand function calls,sizeofoperators, struct accesses, relational/boolean operators, bitwise operators, conditional expressions, increment/decrement operators, floating point literals or type cast sub-expressions.- There should be an array visualization feature to show how a shared array will be distributed among threads. one day, bestie, one day π«Ά
π AUTHORS π
Adam Leko, with significant contributions and guidance from Dan Bonachea and the rest of the Berkeley UPC team. π
π«Ά ACKNOWLEDGEMENTS π«Ά
upcdecl is heavily based on the grammar specified in the original cdecl man page.
Credits for the original cdecl tool:
- Originally written by Graham Ross, improved and expanded by David Wolverton, Tony Hansen, and Merlyn LeRoy.
- GNU readline support and Linux port by David R. Conrad,
<conrad@detroit.freenet.org>.
π REPORTING BUGS π
We are interested in fixing any bugs that exist in upcdecl. For bug reporting instructions, please go to https://upc.lbl.gov. π
okay thatβs the whole vibe, bestie π«Ά β this UPCDECL(1) page comes from Berkeley UPC and is dated October 2026; upcdecl itself is version 0.6 as mentioned up top. slay β¨
π¦ where this page comes from
- nixos 26.05: berkeley_upc 2022.10.0
- nixpkgs unstable: berkeley_upc 2022.10.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms