PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

JFlex

JFlex

JFlex is a grammar language created in 2003.

#349on PLDB 19Years Old 974Users
0Books 0Papers 2Repos

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 ϴ
befunge.html · jflex.html · algol-68.html

View source

PLDB - Build the next great programming language · v2022 · Day 31 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com