Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

JFlex

< >

JFlex is an open source grammar language created in 2003.

#465on PLDB 21Years Old 2Repos
Download source code:
git clone https://github.com/jflex-de/jflex
Homepage · Source Code

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


Example from Linguist:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (C) 1998-2015 Gerwin Klein <lsf@jflex.de> * * All rights reserved. * * * * License: BSD * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Java 1.2 language lexer specification */ /* Use together with unicode.flex for Unicode preprocesssing */ /* and java12.cup for a Java 1.2 parser */ /* Note that this lexer specification is not tuned for speed. It is in fact quite slow on integer and floating point literals, because the input is read twice and the methods used to parse the numbers are not very fast. For a production quality application (e.g. a Java compiler) this could be optimized */ import java_cup.runtime.*; %% %public %class Scanner %implements sym %unicode %line %column %cup %cupdebug %{ StringBuilder string = new StringBuilder(); private Symbol symbol(int type) { return new JavaSymbol(type, yyline+1, yycolumn+1); } private Symbol symbol(int type, Object value) { return new JavaSymbol(type, yyline+1, yycolumn+1, value); } /** * assumes correct representation of a long value for * specified radix in scanner buffer from <code>start</code> * to <code>end</code> */ private long parseLong(int start, int end, int radix) { long result = 0; long digit; for (int i = start; i < end; i++) { digit = Character.digit(yycharat(i),radix); result*= radix; result+= digit; } return result; } %} /* main character classes */ LineTerminator = \r|\n|\r\n InputCharacter = [^\r\n] WhiteSpace = {LineTerminator} | [ \t\f] /* comments */ Comment = {Tradi

Language features

Feature Supported Example Token
Comments /* A comment */
MultiLine Comments /* A comment */ /* */
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v164.7.0