Re: [abc-users] Problem compiling code to generate new extension

From: Pavel Avgustinov <>
Date: Mon Nov 20 2006 - 11:48:52 GMT

On Monday 20 November 2006 11:18, Oram, Damon wrote:
> I am indeed using abc v1.2.1.

Really? Looking at the source for v1.2.1, I'm having trouble matching the line
numbers in your original email to abc.main.Main. What does `abc -version'

> I would think that the issue is more to
> do with my inexperience rather than an abc related problem. Taking the
> example of implementing the global pointcut as a means of extending the
> basic abc compliler, Here is what I have done:
> 1. I have created a folder called global within
> C:\abc-1.2.1-src\abc-1.2.1\src\abc (I am using Windows XP)
> [global] contains ...
> build.xml

Seems sensible, but is there a reason why you create an additional build.xml
rather than adapting abc's default? Anyway, perhaps it's sensible to keep
them separate to make future upgrades easier; I would still recommend copying
C:\abc-1.2.1-src\abc-1.2.1\build.xml to global-build.xml in the same
directory (or somesuch) and using `ant -f global-build.xml' to compile abc,
after modifying it appropriately. If you look through that file for instances
of the string "eaj", it should give you a pretty good idea of the kind of
thing you need to do for a new extension. But then, you've presumably done
that, since you say you can build the new .ppg.

> 2. Within global I have created the following folders and files
> [ast] contains...
> [extension] contains...
> [parse] contains...
> Global.ppg
> Global_ppg.cup
> [types] contains...
> [util] contains...
> [visit] contains...

Looks reasonable.

> 3. I successfully managed to generate the global_ppg.cup,,
> using build.xml and the ant tool.
> 4. I then run the following from the command line: abc -sourceroots
> C:\abc-1.2.1-src\abc-1.2.1\src\abc\global (which is when I am getting
> the error)

Ah, I see. You're trying to compile your extension with abc. Is there a reason
why you don't just use the build.xml file to do that, too?

Clarification: The -sourceroots option specifies a directory which abc should
traverse in search of source files. Thus, the above will instruct abc to
compile every *.java and *.aj file in the given directory, placing the output
in the current directory. I'm not quite sure this is what you want.

If you use build.xml and ant, then the extension should be compiled almost
automatically -- just make sure that the directory with your generated
lexer/parser is in generated/ (or src/, or some other directory specified by
the build file).

Once that completes successfully, you can do `abc -ext -version` to
check that it can be loaded correctly (assuming your prints some
extra stuff), and you can use `abc -ext ${further-abc-options}` to
use your extension.

> I would be very grateful if you could let me know:
> a) If I am missing out a particular step.

I don't think so -- it looks like you've got all the required boilerplate

> b) If I am running the wrong command from the prompt.

Depends -- if you didn't intend to compile your extension with abc, then it's
probably the wrong command. :) See above.

> c) If my directory stucture for global is within the correct location.

Yep, looks fine. In fact, any location will do for an abc extension, and you
run it by giving abc the `-ext ext.package` flag, where ext.package is the
package containing AbcExtension (in your case,

> d) If the files I currently have located within global/parse should
> reside within the abc-1.2.1 generated folder.

Hmm.. By convention we put the .ppg and .flex files in parse/, and have flex
and cup generate and in generated/. The reason for this
is to allow easy cleaning of stale state -- we just need to delete generated/
to get rid of previous versions. I would recommend following that convention;
it is by no means mandatory, though.

> e) Should I be compiling everything within the abc-1.2.1 folder and not
> just within my global sub-folder.

If you use a modified ant build file, as described above, it should compile
everything it needs.

Alternatively, you can keep your extension completely separate from abc. Just
make sure it is compiled, and you have both the extension and abc itself on
the classpath. The thing is, when you give a flag like `-ext`,
this attempts to load by reflection. As long as there
is a suitable version on the classpath, it should work.

> Sorry for the barrage of questions, but I am eager to get to grips with
> the compiler.

Not at all -- we're more than happy to help.

Hm, I still don't see what could have caused the StackOverflowError you
initially reported... slightly worrying. Ah well.

Let us know how you fare.

- Pavel
Received on Mon Nov 20 11:48:21 2006

This archive was generated by hypermail 2.1.8 : Mon Nov 20 2006 - 17:20:09 GMT