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.
IndexProgramming Questions & HelpPrograms › manually parsing javacode for a Processing Tool
Page Index Toggle Pages: 1
manually parsing javacode for a Processing Tool (Read 309 times)
manually parsing javacode for a Processing Tool
Aug 28th, 2008, 12:33am
 
I've been playing a lot with the new Tools addition for processing 0148.
I've almost finished up a PDE Useless Statistics Generator.
Counts things like, chars, words, lines, functions, classes, if(), for(), and functioncalls.
I'd like to improve it, and as of now I'm using regex.

Anybody else got a better idea for picking apart a PDE?

I'm also making a Nibbles clone, for those times when you're stuck, and need a little break. Smiley

seltar
Re: manually parsing javacode for a Processing Too
Reply #1 - Aug 29th, 2008, 7:49am
 
Unlike some languages like JavaScript or Lua, which have a clear 'function' declaration, C and Java functions are not obvious to find.
Regex is an approach, used by some syntax highlighter.
Scintilla lexers use a parsing automaton (state machine), going char by char, keeping track of the context (in a comment, in a string...), which can avoid some false positives.
Processing uses a more robust method: it do a real parsing of the code, using Antlr, to perform its pre-processing (like converting #AAF00D to an int). It uses a grammar for Java provided by the Antlr site.
The learning curve might be step (I haven't dug this field myself) but the result is probably reliable.
Page Index Toggle Pages: 1