Questions tagged [jflex]

JFlex — The Fast Scanner Generator for Java. JFlex is a flex-like lexer generator for Java.

JFlex is a lexical analyzer generator (also known as scanner generator) for Java, written in Java. It is also a rewrite of the very useful tool JLex which was developed by Elliot Berk at Princeton University. As Vern Paxson states for his C/C++ tool flex: They do not share any code though.

JFlex is designed to work together with the LALR parser generator CUP by Scott Hudson, and the Java modification of Berkeley Yacc BYacc/J by Bob Jamison. It can also be used together with other parser generators like ANTLR or as a standalone tool.

Related Links:

196 questions
3
votes
1 answer

The most efficient lookahead substitute for jflex

I am writing tokenizer in jflex. I need to match words like interferon-a as one token, and words like interferon-alpha as three. Obvious solution would be lookaheads, but they do not work in jflex. For a similar task, I wrote a function matching one…
matwasilewski
  • 384
  • 2
  • 11
3
votes
1 answer

JFlex: Negative look-ahead inside regex

My problem can be broken down to the following which can happen inside a large regex: 1. is a number, but 1.. are two token consisting of 1 as number and .. as an operator. The definition of a number in the Wolfram Language is very complex (I append…
halirutan
  • 4,281
  • 18
  • 44
3
votes
1 answer

JFlex String Regex Strange Behaviour

I am trying to write a JSON string parser in JFlex, so far I have string = \"((\\(\"|\\|\/|b|f|n|r|t|u[0-9a-fA-F]{4})) | [^\"\\])*\" which I thought captured the specs (http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). I…
3
votes
1 answer

Setting up Cup/JLex parsing properly

I have a very basic lexer here: import java_cup.runtime.*; import java.io.IOException; %% %class AnalyzerLex %function next_token %type java_cup.runtime.Symbol %unicode //%line //%column // %public %final // %abstract %cupsym…
user2192677
  • 327
  • 1
  • 5
  • 12
2
votes
0 answers

JFlex complaining about caret character

I'm trying to produce a simple standalone scanner with the use of JFlex. What I want to do now is to simply recognize the beginning of a line with the use of the caret (^) symbol. From the Semantics section of the user manual: In a lexical rule, a…
beeblebrox
  • 21
  • 2
2
votes
0 answers

Syntaxic analysis and parser

I want to parse something like that : path.to.variable "path" and "to" are object named "Instance" and variable reference a double. I've got the following grammar : expr ::= instancePath:i INSTANCE_SEPARATOR SHORTCUT:s …
Jerome Cance
  • 8,103
  • 12
  • 53
  • 106
2
votes
1 answer

Significance of yy in scanner/lexer such as jflex

Whats is the significance of the prefix yy in lexers? I see methods/fields such as yyline, yycolumn, yytext, e.t.c Is there some historical significance to the prefix yy in the world of lexers? PS: I am completely new to compilers
Ashok Koyi
  • 5,327
  • 8
  • 41
  • 50
2
votes
1 answer

jflex regular expression any number except zero

I'm new in JFlex and I ran into a problem with regular expression. I'm trying to write in .flex file regex that will recognize any number except zero. The thing is, when I tried my regex in .bnf file everything works fine in live-preview, but when…
ROBO-KY
  • 37
  • 8
2
votes
0 answers

JFlex parametrized token

I want to parse expressions of the following structure: compositeKey ::= key (separator key)* Here is the flex code fragment: KEY_CHARACTER=[^:\s] KEY_SEPARATOR=[:] %state WAITING_KEY ... {KEY_CHARACTER}+ {…
Nyavro
  • 8,806
  • 2
  • 26
  • 33
2
votes
1 answer

Regex match everything except three consecutive double quotes

I am trying to match everything except """ in Regex. My attempt includes: [^\"]{3} This only includes everything except a double quote. I want to also include one double quotes and two double quotes, so that, for instance, this entire string would…
adhdj
  • 352
  • 4
  • 17
2
votes
1 answer

JFlex Scanner ArrayIndexOutOfBoundsException: 769

I am trying to create a Scanner with JFlex. I created my .jflex file and it compiles and everything. The problem is that when I try to prove it, some times it gives me and error of ArrayIndexOutOfBoundsException: 769 in the .java class that JFlex…
2
votes
1 answer

How to invoke multiple lexical analyzers for the same text?

Let's say we have two code snippets: long l = 0L; string sqlStr = "SELECT Column1, Column2 FROM Table ORDER BY Column3 DESC"; int i = 0; // ... C# code goes on and /// /// This method does something. /// /// The…
Giorgi Chakhidze
  • 3,351
  • 3
  • 22
  • 19
2
votes
2 answers

How to match something not defined

if I have defined something like that COMMAND = "HI" | "HOW" | "ARE" | "YOU" How can i say "if u match something that is not a COMMAND"?.. I tried with this one [^COMMAND] But didn't work..
2
votes
1 answer

Multiline comment in JFlex - EOF error

I'm trying to recognize multiline comments using JFlex. It works well with end-of-line comments but I get an error with the comments of the type /*Comment...*/. I am using states to recognize this type of comment, as follows import…
Luis
  • 65
  • 7
2
votes
2 answers

[[:jletterdigit:]] to classical regex

What caracters are in [[:jletterdigit:]] in JFlex ? I need to translate [[:jletterdigit:]] to classical regex.
JaneNY
  • 65
  • 1
  • 4
1
2
3
13 14