RL Assignment

This is generic information about the RL (Resistor Language) assignment. Specific tasks for the assignment are given in other files.


RL (Resistor Language) consists of a series of assignments, separated by newlines. Each assigment is of the form:
    var = term oper term
where term is either a variable var or a constant const. To make things a little easier, variables are composed only of letters and are ten or fewer letters in length. Variables are also "upcased" so that AbCdE and ABCDE are considered the same. Constants are composed only of digits and are ten or fewer digits in length.

There are two operators + and | which correspond to the series and parallel configuration of resistors.

In an RL program, there can be an arbitrary number of whitespace between the operators, variables, and constants. No other characters are allowed.

To make the programming a bit easier, if a variable appears in the right-hand side of an assignment that has never been defined on the left-hand side, that variable is assumed to have a value of 0.

The reference RL implementation

In the referencer RL implmentation: (1) an RL program is input; (2) the RL program is reprinted; (3) the RL program is interpreted to determine the value of the RL variables; (4) the RL variables and their values are printed ordered by variable name; and (4) the RL variables and their values are printed ordered by values.

Here is a sample run of the reference edition. In this example, the input program is ended by typing a ^D character. However, typing any "illegal" RL character (such as #) will also terminate the input process.

bash-3.2$ rl_solution
Reading RL program
A = 10 + 0
B = A + A
C = A | A
D = 1000005 + A
E = D | D
Listing RL program
A          =         10 +          0 
B          = A          + A          
C          = A          | A          
D          =    1000005 + A          
E          = D          | D          

Interpreting RL

Printing RL variables by name
A         :         10
B         :         20
C         :          5
D         :    1000015
E         :     500008

Printing RL variables by value
C         :          5
A         :         10
B         :         20
E         :     500008
D         :    1000015


You need to download some programs so get started. You can try downloading a ZIP-ed image of a NetBeans project directory in either Cygwin format or GNU Linux format but you may find it difficult to "port" that between platforms.

If that doesn't work out, try the individual files given below.

During the course of this multi-part assignment, three of these files, RLparse.c, RLvartab.c, and RLexec.c

All of these modifications are small and are designed to be done in a couple of days. Individual assignment descriptions will present these modifications.