-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.html
69 lines (65 loc) · 4.1 KB
/
examples.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="This page contains examples for AnnoFlex-based scanners.">
<meta name="keywords" content="examples, hello world example, tutorial, java scanner, regular expression scanner, annoflex, scanner, lexer, generator, java, annotations">
<meta name="author" content="Stefan Czaska">
<title>AnnoFlex - Examples</title>
<link href="css/annoflex.css" rel="stylesheet">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="index.html">AnnoFlex</a></li>
<li class="selected"><a href="examples.html">Examples</a></li>
<li><a href="documents.html">Documents</a></li>
<li><a href="download.html">Download</a></li>
<li><a href="support.html">Support</a></li>
<li><a href="license.html">License</a></li>
<li><a href="source-code.html">Source Code</a></li>
</ul>
</nav>
</header>
<main>
<h1>Hello World Example</h1>
<code class="javaBaseColor"><span class="javaDocComment">/**
* This is a simple scanner written with AnnoFlex.
*/</span>
<span class="javaKeyword">public class</span> MyScanner {
<span class="javaDocComment">/** @expr "Hello World" */</span> String createToken() { <span class="javaKeyword">return</span> "Hello World"; }
<span class="javaLineComment">//%%LEX-MAIN-START%%</span>
<span class="javaLineComment">// This is the code area into which the code is generated.</span>
<span class="javaLineComment">//%%LEX-MAIN-END%%</span>
}
</code>
<h1>Tutorial</h1>
<p>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.</p>
<p class="centered"><a href="https://github.com/annoflex/annoflex/blob/master/examples/TutorialPart1.java" class="linkButton">Tutorial Part 1</a>
<a href="https://github.com/annoflex/annoflex/blob/master/examples/TutorialPart2.java" class="linkButton">Tutorial Part 2</a>
<a href="https://github.com/annoflex/annoflex/blob/master/examples/TutorialPart3.java" class="linkButton">Tutorial Part 3</a></p>
<h1>Scanners used by AnnoFlex</h1>
<p>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.</p>
<h2>Java Source Code Scanner</h2>
<p>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.</p>
<p class="centered"><a href="https://github.com/annoflex/annoflex/blob/master/source/org/annoflex/jdt/parser/JavaScanner.java" class="linkButton">Java Scanner</a></p>
<h2>Regular Expression Scanner</h2>
<p>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.</p>
<p class="centered"><a href="https://github.com/annoflex/annoflex/blob/master/source/org/annoflex/regex/parser/RegExScanner.java" class="linkButton">RegEx Scanner</a></p>
</main>
<footer>
<p>© 2018 Stefan Czaska. All rights reserved.</p>
</footer>
</body>
</html>