All Projects → jflex-de → Jflex

jflex-de / Jflex

Licence: other
The fast scanner generator for Java™ with full Unicode support

Programming Languages

java
68154 projects - #9 most used programming language
grammar
57 projects

Projects that are alternatives of or similar to Jflex

Moo
Optimised tokenizer/lexer generator! 🐄 Uses /y for performance. Moo.
Stars: ✭ 434 (+14.21%)
Mutual labels:  tokenizer, lexer, regexp
pascal-interpreter
A simple interpreter for a large subset of Pascal language written for educational purposes
Stars: ✭ 21 (-94.47%)
Mutual labels:  scanner, tokenizer, lexer
Chevrotain
Parser Building Toolkit for JavaScript
Stars: ✭ 1,795 (+372.37%)
Mutual labels:  tokenizer, lexer, parsing
snapdragon-lexer
Converts a string into an array of tokens, with useful methods for looking ahead and behind, capturing, matching, et cetera.
Stars: ✭ 19 (-95%)
Mutual labels:  tokenizer, lexer
Lex
Replaced by foonathan/lexy
Stars: ✭ 137 (-63.95%)
Mutual labels:  tokenizer, lexer
lexertk
C++ Lexer Toolkit Library (LexerTk) https://www.partow.net/programming/lexertk/index.html
Stars: ✭ 26 (-93.16%)
Mutual labels:  tokenizer, lexer
SwiLex
A universal lexer library in Swift.
Stars: ✭ 29 (-92.37%)
Mutual labels:  tokenizer, lexer
flex-bison-indentation
An example of how to correctly parse python-like indentation-scoped files using flex (and bison).
Stars: ✭ 32 (-91.58%)
Mutual labels:  flex, scanner
lex
Lex is an implementation of lex tool in Ruby.
Stars: ✭ 49 (-87.11%)
Mutual labels:  tokenizer, lexer
PSStringScanner
Provides lexical scanning operations on a String
Stars: ✭ 45 (-88.16%)
Mutual labels:  parsing, scanner
librxvm
non-backtracking NFA-based regular expression library, for C and Python
Stars: ✭ 57 (-85%)
Mutual labels:  parsing, regexp
bredon
A modern CSS value compiler in JavaScript
Stars: ✭ 39 (-89.74%)
Mutual labels:  tokenizer, lexer
Works For Me
Collection of developer toolkits
Stars: ✭ 131 (-65.53%)
Mutual labels:  tokenizer, lexer
re-typescript
An opinionated attempt at finally solving typescript interop for ReasonML / OCaml.
Stars: ✭ 68 (-82.11%)
Mutual labels:  parsing, lexer
Snl Compiler
SNL(Small Nested Language) Compiler. Maven jUnit Tokenizer Lexer Syntax Parser. 编译原理 词法分析 语法分析
Stars: ✭ 19 (-95%)
Mutual labels:  tokenizer, lexer
sb-dynlex
Configurable lexer for PHP featuring a fluid API.
Stars: ✭ 27 (-92.89%)
Mutual labels:  parsing, lexer
Flex
The Fast Lexical Analyzer - scanner generator for lexing in C and C++
Stars: ✭ 2,338 (+515.26%)
Mutual labels:  lexer, flex
Php Parser
🌿 NodeJS PHP Parser - extract AST or tokens (PHP5 and PHP7)
Stars: ✭ 400 (+5.26%)
Mutual labels:  tokenizer, lexer
compiler
Implementing a complete Compiler for a simple C-like language using the C-tools Flex and Bison
Stars: ✭ 106 (-72.11%)
Mutual labels:  flex, lexer
Re Flex
The regex-centric, fast lexical analyzer generator for C++ with full Unicode support. Faster than Flex. Accepts Flex specifications. Generates reusable source code that is easy to understand. Introduces indent/dedent anchors, lazy quantifiers, functions for lex/syntax error reporting, and more. Seamlessly integrates with Bison and other parsers.
Stars: ✭ 274 (-27.89%)
Mutual labels:  lexer, flex

Build Bazel build status

JFlex

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.

Usage

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

  <build>
    <plugins>
      <plugin>
        <groupId>de.jflex</groupId>
        <artifactId>jflex-maven-plugin</artifactId>
        <version>1.8.2</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  1. 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"
         classpath="path-to-jflex.jar"/>
  1. 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")

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

Or:

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

Other build tools

See Build tool plugins.

Examples

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

Contributing

Javadoc

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 librairies 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

Or:

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

Build uberjar (aka fatjar aka deploy jar)

bazel build jflex/jflex_bin_deploy.jar

Continuous integration is done with Cirrus CI.

Build with Maven

You need JDK 8 or later.

./mvnw install

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

java -jar jflex-full-1.9.0-SNAPSHOT.jar --info

Continuous Integration is made with Travis.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].