This simple example uses JLex -- the Java-version of unix "lex" utility for generation of scanners.
In this example, we calculate the numbers of words, characters, and lines in the given file. Of course, you need JLex to be installed on your computer (see JLex manual).
To compile from the JLex-source (file CalcWord.l), perform the command
makeIt firstly calls JLex, that creates the "CalcWord.l.java" file:
java JLex.Main CalcWord.lThen (in case of no errors) it compiles the resulting Java-file:
javac CalcWord.l.javaIt creates Yylex.class and some other classes.
To run the resulting program, perform the command
java Yylex filenamewhere "filename" is a name of input file.