The main routine of javaCup is in the jar file that Makefile
java -classpath \
java_cup/Main < csx_lite.cup
I am getting the following error in Project 3:
parser.java:122: error: incompatible types: Symbol cannot be converted to java_cup.runtime.Symbol
I assume that somewhere we need Symbol to be of type
You must remove any declaration of Symbol in the
jlex file. It's commented out in the startup
package. Symbol is defined by java_cup.runtime and you must not re-declare it.
The assignment says that the semantics of CSX Go allow the programmer
to use a variable/function that's declared later in the program. The
grammar doesn't seem to allow that, though.
You can invoke a function that has not yet been declared. But it is not
possible in the syntax to declare a variable before it is declared. I
simplified the syntax (it used to allow variable declarations anywhere)
after I wrote the note about semantics.
Should the unparser include any parentheses the programmer provides,
or only those needed to disambiguate arithmetic expressions?
It's not necessary (or wise) to remember exactly what parentheses the
programmer provides. You can decide how much you want to parenthesize
the output, so long as it is unambiguous. Extra parentheses don't hurt.
When there are variable length of arguments for read
and display, should I print them one line during
That's completely up to you. You can waste enormous amounts of time trying to
wrap at 80 columns if you wish, but you won't get extra credit for it. But a
single read with multiple parameters should unparse as
a single read, not as multiple read statements.
Program 4: Semantics checker
Does CSX_go allow functions that have same name but different input
No. Rule 9 says: "An identifier may only be declared once within a
scope. However, an identifier already declared outside a scope may be
Rule 31 says that local variables have to be assigned before using
them. Are global variables OK to be used without checking whether they
were assigned or not?
Yes. It's infeasible to check at compile time.
In Project 2, we scanned a minus sign as ~. However,
in the test files for Project 4 minus is written as –.
Should we go back and change the parser?
No. Unary minus is ~, but binary minus is –. The test files are correct in this regard. Input (the
read statement), however, will generate code that
uses some Java libraries, and negative numbers entered as input to test-18.csx_go, for instance, will use – and not ~.
May our program ignore cascading errors?
Yes. You should generate a message for the "prime" error, that is, the
first one you encounter, but you should avoid, if possible, messages for
errors resulting directly from that first error.
If there is a duplicate declaration, should the previously declared
variable be re-interpreted as having the "error" type?
That's up to you. I think it better to ignore the second declaration
entirely (after generating an error message) and leave the first one in
Program 5: Code generator