We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentCore,  Processing Development Environment (PDE) › Ant, Java 5, and where is PdeLexer/PdeRecognizer
Page Index Toggle Pages: 1
Ant, Java 5, and where is PdeLexer/PdeRecognizer (Read 3997 times)
Ant, Java 5, and where is PdeLexer/PdeRecognizer
Dec 5th, 2008, 1:35am
 
Hey all,
I'm thinking about using processing for a work project, and needed tighter Java integration, so I started poking around at the source.

First things :
* I checked out trunk, loaded the project up in Eclipse, and for some reason I can't find PdeRecognizer or PdeLexer.  I'm going to just assume these are Antlr classes that need to be generated by Antlr?
* I noticed the bug about Ant now says "Give it a whirl".  I happen to be pretty good with Ant, so I figure I'll give this a shot.
* I see that you're already compiling with 1.5 as the target.  What Java are you guys targetting ultimately?  Have you switched to 1.5+ yet?  Is this in the cards?

UPDATE:
What the hell is preproc.pl doing?  It looks like it's scraping methods and modifying the java code.  Frankly, can you just tell me what you're trying to do with that?
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #1 - Dec 5th, 2008, 2:47am
 
Here's the ant file I have so far.  I'll look through the other scripts at some point. I think this does most of what the current make.sh does :
<project name="processing">

<path id="core.classpath">


<fileset dir="app/lib">



<include name="*.jar" />


</fileset>

</path>


<path id="pde.classpath">


<path refid="core.classpath" />


<pathelement path="bin/core" />

</path>


<path id="library.classpath">


<path refid="pde.classpath" />


<fileset dir="build/shared/">



<include name="**/*.jar" />


</fileset>

</path>


<target name="clean">


<delete dir="bin" />

</target>


<target name="init">


<mkdir dir="bin/core" />


<mkdir dir="bin/pde" />


<mkdir dir="bin/jars" />

</target>


<target name="compile-core" depends="init">


<javac srcdir="core/src" destdir="bin/core" />

</target>


<target name="create-antlr-classes" depends="compile-core">


<java classpathref="core.classpath" classname="antlr.Tool">



<arg value="-o" />



<arg value="app/src/antlr/java" />



<arg value="app/src/antlr/java/java.g" />


</java>


<copy file="app/src/antlr/java/JavaTokenTypes.txt" todir="app/src/processing/app/preproc" />


<java classpathref="core.classpath" classname="antlr.Tool" fork="true">



<arg value="-o" />



<arg value="app/src/processing/app/preproc" />



<arg value="-glib" />



<arg value="app/src/antlr/java/java.g" />



<arg value="app/src/processing/app/preproc/pde.g" />


</java>

</target>


<target name="compile-pde" depends="create-antlr-classes">


<javac srcdir="app/src/antlr" destdir="bin/pde" classpathref="pde.classpath" />


<javac srcdir="app/src/processing/app" destdir="bin/pde" classpathref="pde.classpath">



<include name="*.java" />



<include name="debug/*.java" />



<include name="macosx/*.java" />



<include name="preproc/*.java" />



<include name="syntax/*.java" />



<include name="tools/*.java" />


</javac>

</target>


<target name="compile-qt-library">

</target>


<target name="compile-libraries" depends="compile-pde, compile-qt-library">


<compile-library library-name="serial" />


<compile-library library-name="net" />


<compile-library library-name="pdf" />


<compile-library library-name="opengl" />


<compile-library library-name="dxf" />

</target>


<target name="create-library-jars" depends="compile-libraries">


<jar-library library-name="serial" />


<jar-library library-name="net" />


<jar-library library-name="pdf" />


<jar-library library-name="opengl" />


<jar-library library-name="dxf" />

</target>


<target name="create-core-jars" depends="compile-pde">


<jar destfile="bin/jars/processing-core.jar" basedir="bin/core" />


<jar destfile="bin/jars/processing-pde.jar" basedir="bin/pde" />

</target>


<target name="dist" depends="create-core-jars,create-library-jars" />


<macrodef name="compile-library">


<attribute name="library-name" />


<sequential>



<mkdir dir="bin/libraries/@{library-name}" />



<javac srcdir="@{library-name}/src/processing" destdir="bin/libraries/@{library-name}">




<classpath>





<path refid="pde.classpath" />





<fileset dir="build/shared/">






<include name="**/*.jar" />





</fileset>





<fileset dir="@{library-name}/library">






<include name="**/*.jar" />





</fileset>




</classpath>




<include name="**/*.java" />



</javac>


</sequential>

</macrodef>


<macrodef name="jar-library">


<attribute name="library-name" />


<sequential>



<jar destfile="bin/jars/processing-@{library-name}.jar" basedir="bin/libraries/@{library-name}" />


</sequential>

</macrodef>
</project>
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #2 - Dec 5th, 2008, 1:18pm
 
mreynolds wrote on Dec 5th, 2008, 1:35am:
I'm thinking about using processing for a work project, and needed tighter Java integration, so I started poking around at the source.
You need it at sketch level or deeper

Quote:
I can't find PdeRecognizer or PdeLexer.  I'm going to just assume these are Antlr classes that need to be generated by Antlr
Probably...

Quote:
I see that you're already compiling with 1.5 as the target.  What Java are you guys targetting ultimately  Have you switched to 1.5+ yet  Is this in the cards
Look at the changelog, it is targeting 1.5 (and distributed with 1.6) for quite some months now.
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #3 - Dec 5th, 2008, 7:16pm
 
PhiLho  wrote on Dec 5th, 2008, 1:18pm:
You need it at sketch level or deeper


More data integration.  I don't like the way that the current Java integration is suggested (basically by bootstrapping the Java core, passing in the classname as a String, which is then loaded by the core, it seems).  I wanted a more direct way of controlling Processing.

PhiLho  wrote on Dec 5th, 2008, 1:18pm:
Look at the changelog, it is targeting 1.5 (and distributed with 1.6) for quite some months now.


Sorry, I was reading from the FAQ where it says : "We currently only support Java 1.4 (and earlier) syntax."  I guess this applies to the Processing syntax only
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #4 - Dec 5th, 2008, 11:11pm
 
Yes, it applies to the syntax: Processing does some pre-processing of the given code, so it needs to understand the syntax for that. It hasn't be updated yet to support generics, annotations, for (:) loops, enums, etc.
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #5 - Jan 6th, 2009, 7:05am
 
I've actually been working on updating the ANTLR grammar myself, and I've run into a problem with the pre-processing.

I changed the grammar in PdeExtended.g grammar file in the preproc directory to support enhanced for loops, and re-compiled processing.

Yet when I try an enhanced for loop, I get a Syntax Error message in the strip above the console, because it wants me to use the old for loop. If i add the semicolons to make it proper, then I get an error in the console (expecting RPAREN, found ';'), which suggests that it wants an enhanced for loop (I temporarily disabled the grammar for the old loop in the PdeExtended.g file, in order to test this).

So it seems that some part of the PDE is using the new grammar, but another part isn't being updated, and expects the old for loop. The thing is, I've grepped the entire source tree for the error string that I'm getting above the console ('Syntax error, insert "; ; ) Statement" to complete forStatement'), and I can't find it anywhere. Where is this error message coming from?
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #6 - Jan 6th, 2009, 12:23pm
 
Don't quote me on this, but I think the syntax errors can come either from the pre-processor or from the Java compiler itself.
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #7 - Jan 7th, 2009, 7:01am
 
Yeah, I think that's what I'm observing. I believe that the error I get in the console is coming from the Java Compiler, since it seems to know about enhanced for loop grammer. The error above the console, that doesn't recognized the enhanced for loop, I think is from some part of the pre-processor.

What I'm wondering is, if I changed the grammar in PdeExtended.g, why do I still get the Syntax error in the PDE? Is PdeExtended.g not the only grammar file the the pre-proc uses? Am I doing something wrong? Or is the syntax error in the strip above the console not from the pre-processor?
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #8 - Jan 7th, 2009, 2:42pm
 
I know only superficially Antlr, so I can't help much. Just the obvious question (which can be overlooked, somehow): after modifying the .g file, did you re-generated the corresponding Java files?
Re: Ant, Java 5, and where is PdeLexer/PdeRecogniz
Reply #9 - Jan 8th, 2009, 1:10am
 
Yes, they are being regenerated by the make.sh script (It reports Antlr grammar generation, and when I look at the java files, the rules I added are are there).
Page Index Toggle Pages: 1