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

JFlex maximum read length

Given a positional language like the old IBM RPG, we can have a line such as CCCCCDIDENTIFIER E S 10 Where characters 1-5: comment 6: specification type 7-21: identifier name ...And so on Now, given that JFlex is based on…
LppEdd
  • 20,274
  • 11
  • 84
  • 139
0
votes
1 answer

Ambiguous Context-free grammar? / Shift/Reduce conflict in CUP

I have the following context-free grammar for a simplified version of C++. When I run it with JFLEX and CUP I get a list of errors like that: Warning : *** Reduce/Reduce conflict found in state #173 between especificador ::= (*) and …
Rômulo Borges
  • 127
  • 1
  • 3
  • 9
0
votes
0 answers

OCaml parser for ANTLR or JFlex

I'm looking for grammar files of the OCaml language written in ANTLR4 or JFlex. If they already exist somewhere, where I can find them? Else, how can I generate or write one of them by myself?
Nathan Fallet
  • 321
  • 2
  • 16
0
votes
1 answer

Is there an alternative to \b and/or negative lookahead for JFLEX?

I am building a Scanner and can't seem to find a way to identify operators like "if" or "else" using JFlex & Regex. Since JFlex doesn't fully conform I can't use word-boundary or (?<=\s|^) + (?=\s|$) because neither ? or $ are allowed. The idea is…
JoseSG
  • 3
  • 3
0
votes
1 answer

Jflex get input filename

In Jflex, how does one extract the input filename? DisplayFilename.jflex: %% %class DisplayFilename %eof{ /* code to print the input filename goes here */ %eof} %% \n { /* do nothing */ } . { /* do nothing */ } Commands ran jflex…
Heinrich
  • 340
  • 1
  • 4
  • 12
0
votes
1 answer

Macro contains a cycle

So I'm trying to make a lexical analyzer for scheme and when I run JFlex to convert the lever.flex file I get an error similar to this one for example: Reading "lexer.flex" Macro definition contains a cycle. 1 error, 0 warnings. the macro it's…
0
votes
1 answer

How do I fix this syntax issue with my .flex file?

Is my first time using jflex, I'm following a tutorial i found on the internet in my native language (portuguese), I installed and assembled everything. But when I try to generate the "Lexer" class, it shows a syntax error in my ".flex" file, I…
Seji evan
  • 3
  • 1
0
votes
1 answer

BYACCJ: How do I include line number in my error message?

This is my current error handling function: public void yyerror(String error) { System.err.println("Error: "+ error); } This is the default error function I found on the BYACC/J homepage. I can't find any way to add the line number. My question…
Hari
  • 143
  • 1
  • 13
0
votes
1 answer

JFlex signed integer regular expression

I'm trying to create regex that will match integer value which starts from -2,147,483,648 to 2,147,483,647. As I noticed, JFlex not support \w, \d, ^, $. I tried to write some regex like this in flex file. It compiles, but not working. INTEGER =…
ROBO-KY
  • 37
  • 8
0
votes
1 answer

Why do Symbol's fields (left and right) always return 0?

I'm working on a pascal compiler using CUP and JFLEX. One of the requirements is to recover from errors and show where the errors are. I've been using CUP's method of syntax_error and unrecovered_syntax_error This is the parser code in my…
0
votes
2 answers

Regex in jFlex with hardcoded exceptions

I need a regex in jFlex to match a string literal, containing some characters, followed by a hyphen which is followed by a word. However, there are a few hardcoded exceptions. My jFlex version is 1.6.1 My regexes are: SUFFIXES =…
matwasilewski
  • 384
  • 2
  • 11
0
votes
1 answer

Can I use only GrammarKit to generate both parser and lexer for Intellij Plugin development (custom lang)

In the tutorial of custom language support for Intellij Plugin development, it uses GrammarKit to generate the Parser and JFlex (patched) to generate the Lexer. On this page the author says we can "use the GrammarKit plugin to generate lexer and…
Devs love ZenUML
  • 11,344
  • 8
  • 53
  • 67
0
votes
1 answer

Is inheritance possible in JFlex?

I'm fairly new to JFlex and JSyntaxPane although I have managed to hack together a lexer for XPath. The problem I find myself in is that I'm working on a project that supports a subset of XPath with a few proprietary features. Nasty I know. If this…
Tom Martin
  • 2,498
  • 3
  • 29
  • 37
0
votes
1 answer

FileInputStream cannot be converted to Reader

I am trying to read my text file "inputFile.txt" but system shows the error below. Can anyone help me to solve this error? Thank you! error: incompatible types: FileInputStream cannot be converted to Reader Yylex yy = new…
Sakura Hui
  • 13
  • 1
  • 3
0
votes
1 answer

Parsing blocks as Python

I am writing a lexer + parser in JFlex + CUP, and I wanted to have Python-like syntax regarding blocks; that is, indentation marks the block level. I am unsure of how to tackle this, and whether it should be done at the lexical or sintax level. My…
Jsevillamol
  • 2,425
  • 2
  • 23
  • 46