FAQ Database Discussion Community


How to exclude character " in a token JavaCC

bnf,javacc
Hello i´m working with JavaCC and I am writing a token that put one String between " ". Context: void literalString(): {} { """ (characteresString())? """ } void characteresString(): {} { <characterString> | characteresString() <characterString> } So i made this token to put one String: TOKEN : {<characterString : ~["\",...

superfluous LOOKAHEAD in javacc causes error?

java,parsing,javacc,lookahead
I have the following TT.jj, if I uncomment the SomethingElse part below, it successfully parses a language of the form create create blahblah or create blahblah. But if I comment out the SomethingElse part below, but retain the LOOKAHEAD, javacc complains that the lookahead is not necessary and "ignored", but...

JavaCC: Matching an empty string

java,regex,tokenize,javacc
I am having trouble with ambiguous tokens. My grammar defines two productions, a numeric constant of the form 2e3 or 100e1, and identifiers of the form abc or uvw123. The problem is that e1 is a valid identifier, but also constitutes part of a numeric constant. So for example, if...

Choice Conflict Involving Two Expansions:

java,parsing,javacc,left-recursion
I'm trying to create my own analyser/parser. I have a problem which I understand why it doesn't work but I'm unsure of how to solve it. This is the code for the problem part of my parser. void Expression() : {}{ Term() ((<PLUS> | <MINUS>) Term())* } void Term() :...

How to match 0 tokens in JavCC

parsing,grammar,javacc
I'm fairly new at javaCC and I'm trying to create a miniJava parser but I dont know how to skip a semantic action. SKIP : /* Definition of white-space and comments here */ { " " | "\t" | "\n" | "\r" | "\f" | < "//" (~["\n","\r"])* ("\n"|"\r"|"\r\n") >...

parsing multiple files in javaCC

javacc
I want to parse multiple files. I have JavaCC code which generates the parser. It works fine when I parse the first file (a.txt). But, I want to parse multiple files. because the first file (a.txt) call many files. Thanks in advance....

JavaCC and Unicode issue. Why \u696d cannot be managed in JavaCC although it belong to the range “\u4e00”-“\u9fff”

java,unicode,compiler-construction,antlr,javacc
We're trying to use JavaCC as a parser to parse source code which is in UTF-8( the language is Japanese). In JavaCC, we have a declaration like: < #LETTER: [ "\u0024", "\u0041"-"\u005a", "\u005f", "\u0061"-"\u007a", "\u00c0"-"\u00d6", "\u00d8"-"\u00f6", "\u00f8"-"\u00ff", "\u0100"-"\u1fff", "\u3040"-"\u318f", "\u3300"-"\u337f", "\u3400"-"\u3d2d", "\u4e00"-"\u9fff", "\uf900"-"\ufaff" ] > If it meets a string...

count lines of Function that don't consist solely of comments

javacc
I want to count lines of Function that don't consist solely of comments. extrait of .jj file : options { …….. COMMON_TOKEN_ACTION = true ; LOOKAHEAD= 2; } PARSER_BEGIN(MyParseur) …………… PARSER_END(MyParseur) TOKEN_MGR_DECLS: { static int interestingLineCount=0; static int lineNumberOfLastInterestingLine=0; static Map <Integer, Integer> f = new HashMap<Integer, Integer>(); void CommonTokenAction(Token...

parsing variable composed with lettre and numbers like “ JAVAC 1.7.0.XXX”

javacc
I'm trying to parse regular expressions using JavaCC but I encountered a problem with variable " Y " composed of lettre and number for exemple : " JAVA 1.7.1.XXX" . knowing that I have already defined the Token <id > = < lettre > | <number> < #lettre : [...

javacc java.lang.NullPointerException

parsing,grammar,javacc
im trying to make a miniJava parser but im having trouble figuring out a way to parse method declarations that have no formal parameters. e.g public int getNumber() The code that i have right now works for parameters of one or more, but im not sure how to return an...