The fast scanner generator for Java™ with full Unicode support
Alternatives To Jflex
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Jflex523194322 months ago12May 03, 202025otherJava
The fast scanner generator for Java™ with full Unicode support
a year agoPython
Go Library Demo65
2 years agoGo
Go Library / Golang Library
21 days ago1C++
C++14 version of lexertl
3 years ago1otherC#
GPLEX is a scanner generator which produces lexical scanners written in C# V2 or higher. The input language is similar to the original LEX specification language, but allows full 21-bit Unicode scanners to be specified.
5 years ago1Python
Libraries and command-line tools for metrical analysis of epic Greek hexameter
8 years ago2otherHaskell
Haskell ctags/etags generator
5 years agobsd-3-clauseJava
An annotation-based code generator for lexical scanners
Unicode Ranger3
6 years agomitJavaScript
A utility that scans URL contents and returns a unicode-range value!
4 years agoC
Sample isolation tool for PSF1 files
Alternatives To Jflex
Select To Compare

Alternative Project Comparisons



JFlex is a lexical analyzer generator (also known as scanner generator) for Java.

JFlex takes as input a specification with a set of regular expressions and corresponding actions. It generates Java source of a lexer that reads input, matches the input against the regular expressions in the spec file, and runs the corresponding action if a regular expression matched. Lexers usually are the first front-end step in compilers, matching keywords, comments, operators, etc, and generating an input token stream for parsers.

JFlex lexers are based on deterministic finite automata (DFAs). They are fast, without expensive backtracking.


For documentation and more information see the JFlex documentation and the wiki.

Usage with Maven

Maven central

You need Maven 3.5.2 or later, and JDK 8 or later.

  1. Place grammar files in src/main/flex/ directory.

  2. Extend the project POM build section with the maven-jflex-plugin

  3. Voilà: Java code is produced in target/generated-sources/ during the generate-sources phase (which happens before the compile phase) and included in the compilation scope.

Usage with ant

You need ant, the binary JFlex jar and JDK 8 or later.

  1. Define ant task

    <taskdef classname="jflex.anttask.JFlexTask" name="jflex"
  2. Use it

    <jflex file="src/grammar/parser.flex" destdir="build/generated/"/>
    <javac srcdir="build/generated/" destdir="build/classes/"/>

Usage with Bazel

We provide a jflex rule

load("@jflex_rules//jflex:jflex.bzl", "jflex")

    name = "",           # Choose a rule name
    srcs = [],           # Add input lex specifications
    outputs = [],        # List expected generated files

See the sample simple BUILD file.

Usage in CLI

You need the binary jflex jar and JDK 8 or later.

You can also use JFlex directly from the command line:

jflex/bin/jflex src/grammar/parser.flex


java -jar jflex-full-1.9.0.jar -d output src/grammar/parser.flex

Other build tools

See Build tool plugins.


Have a look at the sample project: simple and other examples.



JFlex is free software, contributions are welcome. See the Contributing page for instructions.

Source layout

The top level directory of the JFLex git repository contains:

  • cup A copy of the CUP runtime
  • cup-maven-plugin A simple Maven plugin to generate a parser with CUP.
  • docs the Markdown sources for the user manual
  • java Java sources [WIP, Bazel]
  • javatests Java sources of test [WIP, Bazel]
  • jflex JFlex, the scanner/lexer generator for Java
  • jflex-maven-plugin the JFlex maven plugin, that helps to integrate JFlex in your project
  • jflex-unicode-plugin the JFlex unicode maven plugin, used for compiling JFlex
  • testsuite the regression test suite for JFlex,
  • third_party third-party libraries used by examples of the Bazel build system

Build from source

Build with Bazel

JFlex can be built with Bazel. Migration to Bazel is still work in progress, concerning the test suite, for instance.

You need Bazel.

bazel build //jflex:jflex_bin

This builds bazel-bin/jflex/jflex_bin, that you can use

bazel-bin/jflex/jflex_bin --info


bazel run //jflex:jflex_bin -- --info

Build uberjar (aka fatjar aka deploy jar)

bazel build jflex/jflex_bin_deploy.jar

Build with Maven

You need JDK 8 or later.

./mvnw install

This generates jflex/target/jflex-full-1.9.1-SNAPSHOT.jar that you can use, e.g.

java -jar jflex-full-1.9.1-SNAPSHOT.jar --info
Popular Unicode Projects
Popular Scanner Projects
Popular Text Processing Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Maven Plugin
Bazel Rules