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
2
votes
1 answer

Getting JFlex and Cup to work together

I'm trying to implement a parser with JFlex and Cup. Right now I'm just trying to get them to compile the simple example program found at the link below. http://www.cs.rit.edu/~pal6640/cup-example/simple-expr.html To create the parser.java and…
Ryan
  • 43
  • 1
  • 6
2
votes
1 answer

Not able to run JFlex generated lexer Java file

So I used JFlex to generate a file called Yylex.java without any problems. When I try to compile it with the command javac Yylex.java, I get 30 errors, originating with this one: Yylex.java:13: error: package java_cup.runtime does not exist import…
John Roberts
  • 5,885
  • 21
  • 70
  • 124
2
votes
1 answer

simple JFflex parser translates to java OK. Error when compiling java code

I have this simple Bison JFLEX parser : http://pastebin.com/SNB20y7G I ran jflex parser.flex ( this is how my file is called) obtained a class called TuringLexer.java When I try to compile it with javac TuringLexer.java I get this: $ javac…
pAndrei
  • 383
  • 6
  • 19
2
votes
1 answer

How to comment code in jflex

Unlike in flex, /* */ and \\ don't seem to work in jlex. They give the error, "Missing brace at start of lexical action."
Rose Perrone
  • 61,572
  • 58
  • 208
  • 243
1
vote
0 answers

Negated pattern in JFlex

I am using JFlex to parse strings. I have state VARIABLE where I want to parse everything between <...> For that I defined this in my .flex file: { [^>]+ { return symbol(sym.VARIABLE, new String(yytext())); } ">" { …
Vojtěch
  • 11,312
  • 31
  • 103
  • 173
1
vote
1 answer

LookAhead not working in JFlex

I am trying to use JFlex to build a parser but encounter a very basic issue. I want to have this token [A-Za-z]+_N$ { System.out.println("Noun"); } and have it recognize "car_N" as a "Noun" and NOT recognize "car_NN". but it does not work, if I…
Freddy Chua
  • 113
  • 1
  • 1
  • 11
1
vote
2 answers

JetBrains Language Support Plugin

I am trying to implement language support plugin for a basic language. I am following jetbrains's tutorial for simple language support (.properties file support basically) and on the side I have rust plugin for reference. However the complexity gap…
Levan Apakidze
  • 221
  • 2
  • 6
1
vote
0 answers

How to make expression for grammar rule in Bison with Jflex

I've been trying to make a parser which takes tokens from a lexer (jflex), and ive used Java with bison for the parser. Here is my code so far for the parser: %define api.prefix {EXAMPLE} %define api.parser.class {EXAMPLE} %define…
Chronicle
  • 11
  • 2
1
vote
2 answers

jflex: Why does this regex match?

in my lexer I wrote the following regex: "///"\s*[^@\s].* I executed byacc/j in debug mode and it states that the following line matched the regex. But why does this regex match this line? /// @Service( version="1.0.0" ) I also tried…
Marc-Christian Schulze
  • 3,154
  • 3
  • 35
  • 45
1
vote
1 answer

Java tool for matching multiple regular expressions with priorities to multiple strings

I have an unlimited sequence of strings and numerous regular expressions ordered by priorities. For each string in a sequence I have to to find the first matching regular expression and the matched substring. Strings are not very long (<1Kb) while…
depthofreality
  • 579
  • 6
  • 14
1
vote
1 answer

Regular expressions representing BNF

I am working on a lexer. I need to identify patterns in BNF and specify them using Regular expressions. I know there are TOKENS e.g. keywords, identifiers, operators etc. So far I have defined Regular expressions: digit=[0-9] integer={digit}+ …
1
vote
0 answers

Highlight / parse PSI elements inside another PSI element

I developed a Custom Language plugin based on this this tutorial. My plugin parses key/value language files with format like below. Values can contain some HTML tags like
, , , and \n. So I want to highlight these tags as separate…
schmidt9
  • 4,436
  • 1
  • 26
  • 32
1
vote
0 answers

How to wrap composite PsiElement on top of Lexer recognized elements in Grammar-Kit

I am new to intellij plugin writing. I started writing a intellij plugin for one of our custom language. I am following the tutorial given in intellij official site. Also I downloaded their Grammar-Kit repo from github to understand the code…
Subhojit
  • 11
  • 1
1
vote
0 answers

Shift Reduce Conflict (CUP)

I am trying define my grammar in my cup file and I'm getting the following errors. Warning : *** Shift/Reduce conflict found in state #4 between fielddecls ::= (*) and type ::= (*) INT under symbol INT Resolved in favor of…
1
vote
0 answers

How can Jflex return multiple terminals at once

This question about Flex gives an example of a nonblock do-loop in fortran: DO 20 I=1, N ! line 1 DO 20 J=1, N ! line 2 ! more codes 20 CONTINUE ! line 4 As the question elaborates, on line 4 the label 20 serves as the end of…
Zeke Medley
  • 111
  • 7