cdc

Implement the Unix 'dc' utility in C


I am just hoping on getting some tips on how to get started on my assignment. It reads as follows:

"Implement a program that behaves similarly to the 'dc' utility, which evaluates expressions in a postfix notation, and also supports additional computations using variables and macro strings. Feel free to experiment with the existing utility and consulting its manual pages. The assignment will support only a subset of the complete utility: -- all numeric values will be integers, only using radix 10

-- numbers may be assumed to be within the range of 32-bit signed numbers

-- all register names will be alphanumeric (a subset of those dc allows)

-- no command line options or arguments will be required

-- only the following commands are are required (listed in the same order as the manual) p n f + - * / % ^ c d r s l S L x > !> < !< = != q #

Some key differences between the assignment and the existing utility: -- all input will be through standard input only (but not necessarily keyboard)

-- register stacks are initially not empty, but filled with infinite zeros

-- the q command will exit the program, regardless of macro call nesting level

-- additional spaces may appear between input tokens for legibility (the space is not a command or a value or a register name)"

I honestly don't know where to start... Any help is greatly appreciated, thanks guys.


Solution

  • As it is an assignment and you do not know where to start here are some hints: