javacc

Tips for speeding up build time on Linux using ANT, Javacc, JUnit and compiling Java classes

We have a large codebase that takes approx 12 minutes on the developer machines to auto-generate some Java 5 classes using JavaCC and then compiles all the classes as well as running the units test. The project consists of multiple projects which can be built in groups, but we are aiming for a full a build in under 10 minutes What tips...

What's better, ANTLR or JavaCC?

Concerns are documentation/learnability, eclipse integration, tooling, community support and performance (in roughly that order). ...

NULL token in JavaCC

I have strange problem with token < NULL: "null" > in my JavaCC parser. In expression like String IsNullClause(): { String res = ""; } { <IS> {res += " IS ";} [<NOT> {res += " NOT ";} ] <NULL> {res += " NULL ";} { return res; } } parser doesn't see NULL token and throws exception that "null" expected. If I chang...

Recognizing extended characters using JAVACC

I'm creating a grammar using JavaCC and have run across a small problem. I'm trying to allow for any valid character within the ASCII extended set to be recognized by the resulting compiler. After looking at the same JavaCC examples (primarily the example showing the JavaCC Grammer itself) I set up the following token to recognize my cha...

Explanation and solution for JavaCC's warning "Regular expression choice : FOO can never be matched as : BAR"?

I am teaching myself to use JavaCC in a hobby project, and have a simple grammar to write a parser for. Part of the parser includes the following: TOKEN : { < DIGIT : (["0"-"9"]) > } TOKEN : { < INTEGER : (<DIGIT>)+ > } TOKEN : { < INTEGER_PAIR : (<INTEGER>){2} > } TOKEN : { < FLOAT : (<NEGATE>)? <INTEGER> | (<NEGATE>)? <INTEGER> "." <...

Parser, Generator for Java with the following requirements...

I am looking for a parser generator for Java that does the following: My language project is pretty simple and only contains a small set of tokens. Output in pure READABLE Java code so that I can modify it (this why I wouldn't use ANTLR) Mature library, that will run and work with at least Java 1.4 I have looked at the following and t...

JavaCC - Parse math expressions into a class structure

I'm using this grammar to calculate math expressions: // Konfiguration (JavaCC-Manual konsultieren) options { STATIC = true; // alle Parser-operationen sind static // verwende zwei Token um zu entscheiden, was passieren soll LOOKAHEAD = 2; } // hier beginnt unsere Parser Klasse ("MathParse") PARSER_BEGIN(MathParse) // h...

Parsing RTF Documents with Java/JavaCC

Is anybody familiar with the the RTF document format and parsing using any Java libaries. The standard way people have done this is by using the RTFEditorKit in the JDK Swing API: Swing RTFEditorKit API but it isn't that accurate when it comes to parsing RTF documents. In fact there's a comment in the API: The RTF support was not...

Handling Token Ambiguity in JavaCC

I'm attempting to write a parser in JavaCC that can recognize a language that has some ambiguity at the token level. In this particular case the language supports the "/" token by itself as a division operator while it also supports regular expression literals. Consider the following JavaCC grammar: TOKEN : { ... < VAR : "var...

javacc parseException... lookahead problem?

I'm writing a parser for a very simple grammar in javacc. It's beginning to come together but at the moment I'm completely stuck on this error: ParseException: Encountered "" at line 4, column 15. Was expecting one of: The line of input in question is z = y + z + 5 and the production that is giving me problems is my expression w...

Anybody has some links to javacc tutorials?

It's very difficult to find this kind of document online. I found one in JAVAWORLD, but this one does not cover the jjTree and visiter one. Does anybody happen to have some links to the tutorials? ...

What do people do with Parsers, like antlr javacc?

Out of curiosity, I wonder what can people do with parsers, how they are applied, and what do people usually create with it? I know it's widely used in programming language industry, however I think this is just a tiny portion of it, right? ...

Format ParseException with JavaCC

I was wondering how could it be possible to format in a human-readable format a ParseException thrown by JavaCC: in fact it includes fields such asbeginLine, beginColumn, endColumn, endLine in the token reference of the exception, but not the reference to the source parsed. Thanks! :) ...

JavaCC: I wish to generate java classes from dymanicly generated jj files and to compile them at runtime...

Hi all, I am refactoring a project which uses javaCC to create a proprietary language parser during compile time. Due to the fact that different variations of languages can exist at the same time, it has been decided to dynamically generate the java source code from the jj files during runtime, to then compile the java files into class ...

JavaCC Problem - Generated code doesn't find all parse errors

Just started with JavaCC. But I have a strange behaviour with it. I want to verify input int the form of tokens (letters and numbers) wich are concatenated with signs (+, -, /) and wich can contain parenthesis. I hope that was understandable :) In the main method is a string, which should produce an error, because it has one opening but...

What's JavaCC's ADVANTAGE versus ANTLR

Too many people have told me about the disadvantages, but what is its advantage if any? ...

Preprocessing with Javacc/ push front some chars in the stream ?

Hi all, Using javacc can I push some new characters in front of the inputstream ? for example let's say that my parser parses the following syntax: #define Paragraphs "Paragraph+" #define Volume "(Title,(Chapter,${Paragraphs})+)" Book=${Volume}+; How can I tell javacc that its scanner should preprocess ${Volume} to (Title,(Chapter...

Print matched token in JavaCC

I need to print the token that was matched by javacc, but I don't know how to "store it". Let's say my token definition is: TOKEN : { < BLAH: ["0"-"9"]> } and my parser.input() function is: void Input(): {} { (<BLAH> { System.out.println("I recognize BLAH"); } ) } However what I really want to output, given some input, let's ...

Javacc parser option LOOKAHEAD, Java

I've recently started to play around with grammatical analyzers using javacc and one of the fields is the options one...I have a code like the folowing: options { LOOKAHEAD=1; } PARSER_BEGIN(Calculator) public class Calculator { ... } PARSER_END(Calculator) What exactly does it mean the LOOKAHEAD option? Thanks ...

'Rational' token in Javacc

Hello, How does one create a 'Rational' token in javacc that takes a rational number and calculates its value. Foe example '2/5' value =0.4. I know how to write a regex for this, but don't know, and have never been properly taught, how to/where to incorporate java methods in javacc code. I have been advised that: Note that rational num...