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

From: Oram, Damon <d.oram@lancaster.ac.uk>
Date: Mon Nov 20 2006 - 17:15:22 GMT

Pavel

Your reply has proved most helpful. I amended the build.xml to include
the references to global and ran ant -f build.xml. Compilation
succeeded generating the required jar files. Once I referenced these in
my classpath, I was able to utilise using abc -ext abc.global Test.java.

I can now turn my attention to writing a 'real' extension of my own.

Again, many thanks.

Damon

-----Original Message-----
From: Majordomo list server [mailto:majordomo@comlab.ox.ac.uk] On Behalf
Of Pavel Avgustinov
Sent: 20 November 2006 11:49
To: abc-users@comlab.ox.ac.uk
Subject: Re: [abc-users] Problem compiling code to generate new
extension

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'
report?

> 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 ...
> AbcExtension.java
> ExtensionInfo.java
> Topics.java
> Version.java
> 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...
> GLOBALNodeFactory.java
> GLOBALNodeFactory_c.java
> GlobalPointcutDecl.java
> GlobalPointcutDecl_c.java
>
> [extension] contains...
> GLOBALAdviceDecl.java
> GLOBALAdviceDecl_c.java
>
> [parse] contains...
> Global.ppg
> Global_ppg.cup
> Grm.java
> Sym.java
>
> [types] contains...
> GLOBALTypeSystem.java
> GLOBALTypeSystem_c.java
>
> [util] contains...
> ToReceiver.java
>
> [visit] contains...
> GlobalPointcuts.java

Looks reasonable.

> 3. I successfully managed to generate the global_ppg.cup, grm.java,
> sym.java 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 abc.global
-version` to check that it can be loaded correctly (assuming your
Version.java prints some extra stuff), and you can use `abc -ext
abc.global ${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 code.

> 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, abc.global).

> 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 Lexer.java and Grm.java 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
abc.global`, this attempts to load abc.global.AbcExtension 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.

Cheers,
- Pavel
Received on Mon Nov 20 17:16:00 2006

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