Hello World Example

/** * This is a simple scanner written with AnnoFlex. */ public class MyScanner { /** @expr "Hello World" */ String createToken() { return "Hello World"; } //%%LEX-MAIN-START%% // This is the code area into which the code is generated. //%%LEX-MAIN-END%% }

Tutorial

AnnoFlex provides for beginners a simple and short tutorial consisting of three parts each in the form of a scanner. Part one starts with a minimal scanner which shows how a scanner definition is structured in principle. Part two is based on part one and additionally contains the generated code of the scanner. Part three shows how this code can be customized. All tutorial scanners are located in the "examples" folder of the repository.

Tutorial Part 1 Tutorial Part 2 Tutorial Part 3

Scanners used by AnnoFlex

AnnoFlex uses its own parsers for Java source code files and regular expressions. The scanners of both parsers are written with AnnoFlex and thus well-suited for the use as examples.

Java Source Code Scanner

The JavaScanner is used by AnnoFlex to scan Java source code files. It is a very simple scanner which mainly consists of lexical rules for keywords and special symbols. Only comments and literals step out of line and are more difficult to understand.

Java Scanner

Regular Expression Scanner

The RegExScanner is used by AnnoFlex to scan regular expressions. This scanner makes use of lexical states and state stacks. It is a good reference if you want to investigate how this technique works.

RegEx Scanner