/usr/share/doc/jflex/examples/simple-maven/src/site/apt/usage.apt is in jflex 1.4.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | ------
Usage
------
Gerwin Klein <lsf37@users.sf.net>
Régis Décamps <decamps@users.sf.net>
------
November 2, 2007
------
About this project
This sample project parses a grammar with JFlex.
The project management is done with Maven.
The project contains a simple grammar for the "Toy programming language".
It is the example from the JLex web site with some small
modifications, to make it a bit more readable.
It does nothing really useful, because there is no parser for
the toy programming language. It's just a demonstration how a
small simple scanner looks like.
* JFlex
JFlex is a parser generator. Given a grammar, JFlex generate
Java (TM) code to parse documents that follow this grammar.
* Maven
Maven is a project management framework.
The project is described in as a POM (project object model,
stored into <<<pom.xml>>>).
This document isn't intended to be a tutorial on the use of Maven 2,
you should consult the {{{http://maven.apache.org/}Maven web site}}.
The integration of JFlex and Maven is done with
{{{http://jflex.sourceforge.net/maven-flex-plugin/}maven-flex-plugin}}.
Usage
* mvn generate-sources
The maven-jflex-plugin will read the grammar
<<<src/main/jflex/simple.jflex>>>
and generate a Java scanner <<<Yylex.java>>>
in <<<target/generated-sources/flex>>>
This is defined by the following section
+---------
<build>
<plugins>
<plugin>
<groupId>de.jflex.maven.plugin</groupId>
<artifactId>maven-jflex-plugin</artifactId>
<version>0.2</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
+------------
By default, the maven-jflex-plugin generates a scanner/parser for every file
in <<<src/main/jflex/>>>.
* mvn test
This goal test the generated scanner (if required, the lexer will be
generated and all Java classes will be compiled)
by running all tests in <<<src/test/java>>>.
There is only one test in <<<src/test/java/YylexTest.java>>>.
In this test,
the scanner is run with the input file <<<src/test/resources/test.txt>>>.
By default, the scanner outputs debugging information about each
returned token to <<<System.out>>> until the end of file is reached,
or an error occurs.
But in the test, the output is redirected into <<<target/output.actual>>>.
The test is successful if every line match
with <<<src/test/resources/output.good>>>,
which is the expected scanner debugging information.
References
* {{{http://jflex.sourceforge.net/maven-flex-plugin/}maven-flex-plugin}}
* {{{http://maven.apache.org/}Maven web site}}.
|