Running the supplied compiler

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Running the supplied compiler

Keith
This post was updated on .
EDIT: Long story short, the compiler has trouble working with spaces in directory names. The zip file for project 9 creates a directory called "project 09", so be sure to change this before compilation!

----------------------------------------------------------------------
Hi all,

I'm having a lot of trouble getting the supplied compiler to run through the terminal on a mac. No matter what input I give the compiler (running JackCompiler.sh), it prints out the contents of bin/help/compiler.txt followed by "Usage: java JackCompiler <Jack-dir or Jack-file-name>".

This is quite a confusing message as the shell file includes code to run the compiler's java class files inside the bin/lib/Compilers.jar file. There is no JackCompiler class file inside the tecs-software-suite-2.5 directory, making "java JackCompiler Jack-dir-path" invalid.

I've checked that the inputs are either valid directories or individual .jack files and tried using absolute paths. I've also unsuccessfully tried manually running the classes in the jar file. I took a look at the thread

http://tecs-questions-and-answers-forum.32033.n3.nabble.com/JackCompiler-doesn-t-work-on-Mac-td3788999.html

which just explains how to run a shell file on a different directory. As a last resort, I re-downloaded the software suite, but got the same results.

Here's the exact output given when I run the shell file as described. The same output occurs when using absolute paths. ("project 09" is a directory in the same folder as tecs-software-suite-2.5, Square is a directory in project 09 holding several .jack files)

==================================================
(terminal):tecs-software-suite-2.5 USER$ ./JackCompiler.sh ../project\ 09/Square

Jack Compiler, Version 2.5

This program is part of the software suite that accompanies the book:

The Elements of Computing Systems
by Noam Nisan and Shimon Schocken
MIT Press, 2005
Book site: www.idc.ac.il/tecs

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

Usage instruction and tips can be found in the relevant book chapters.

Usage: java JackCompiler <Jack-dir or Jack-file-name>
==================================================

Any help would be much appreciated! -Keith
Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

ybakos
Hi Keith,
What result do you get when using an absolute path? For example:

JackCompiler.sh /absolute/path/to/project09/Square

Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

Keith
Thanks for the reply ybakos. I get the same thing:

(terminal) tecs-software-suite-2.5 USER$ ./JackCompiler.sh /Users/$USER/Desktop/--bunch of intermediate folders---/project\ 09/Square

===========================================
Jack Compiler, Version 2.5

This program is part of the software suite that accompanies the book:

The Elements of Computing Systems
by Noam Nisan and Shimon Schocken
MIT Press, 2005
Book site: www.idc.ac.il/tecs

Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski

Usage instruction and tips can be found in the relevant book chapters.

Usage: java JackCompiler <Jack-dir or Jack-file-name>
===========================================

Running the shell file from an absolute path produces the same result.
I've confirmed that absolute paths to a jack file/directories of jack files are accurate (eg by autofilling, ls'ing).

It's not the compiler itself that is faulty; for example, I can copy the directory I want to compile into the software suite and successfully run the compiler:

======================================================
(terminal):tecs-software-suite-2.5 USER$ ls Square_Clone/
Main.jack Square.jack SquareGame.jack
(terminal):tecs-software-suite-2.5 USER$ ./JackCompiler.sh Square_Clone
(terminal):tecs-software-suite-2.5 USER$ ls Square_Clone/
Main.jack Main.vm Square.jack Square.vm SquareGame.jack SquareGame.vm
======================================================

I just want to be able to compile files/directories not in the same working directory.

EDIT: Moved some files around and it looks like the compiler has trouble interpreting spaces or the space escape sequence character in directory names. This is slightly problematic, since the default download folder is called "project 09"! Oh well, easy enough to fix.

Thanks for the help.
-Keith
Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

cadet1620
Administrator
I just checked the project 9 page in the study plan. It says:

"To help you get started, we provide a sample Jack program, stored in project 09.zip.
Start by creating a directory named projects/09 on your computer, and extract this zip file into it (preserving the directory structure embedded in the zip file)."

Spaces in file names are generally bad news for command line programs.

--Mark

Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

dd-b
I hate to disagree with anybody using a sliderule as their icon and a handle commemorating my first computer, but it's pretty common these days to handle spaces in directory names (and file names) properly in command-line programs, including complex bash scripts and such.  With filename completion in most major shells, the quoting is even applied automatically at the user level.

In my case, I've wasted over a day trying to get the dratted compiler to run or at least produce a meaningful error message.  If that *is* my problem I'm kinda in a bind -- the space in the path that may be causing me trouble is coming from %CLASSPATH%, which points to C:\Program Files (x86)\Java\jre7\lib (two spaces in the first path component there -- which is the standard installation location for Java on Windows).  So, are you saying that this compiler won't function on a Windows system with Java installed in the default location?  That seems kind of a problem to me.  (Yes, of course I can copy it elsewhere and try that out.  If that *is* the problem, then I have to do a special modification on the classroom computer each week before teaching the rest of this, since we're using Jack for the rest of the term.)
Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

ybakos
The issue is not about executing Java, irrespective of its installation location.

This thread is about how the JackCompiler script may need some massaging to handle the compilation of .jack files that exist in a directory hierarchy that includes spaces. I believe this may have been fixed.
Reply | Threaded
Open this post in threaded view
|

Re: Running the supplied compiler

cadet1620
Administrator
In reply to this post by dd-b
dd-b wrote
In my case, I've wasted over a day trying to get the dratted compiler to run or at least produce a meaningful error message.  If that *is* my problem I'm kinda in a bind -- the space in the path that may be causing me trouble is coming from %CLASSPATH%, ...
Spaces in CLASSPATH should be fixed in the new batch files and scripts in the post
*** Announcements *** › New and Updated Files > Tools: Updated batch and script files

If you have problems with those batch files, please email me directly so I can fix them.

--Mark