JFlex Regular Expressions
[Pages:47]JFlex Regular Expressions
Lecture 17 Section 3.5, JFlex Manual
Robb T. Koether
Hampden-Sydney College
Wed, Feb 25, 2015
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 1 / 32
1 Running JFlex
2 JFlex Rules
3 Example Identifiers Numbers Strings Comments Keywords
4 Assignment
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 2 / 32
Outline
1 Running JFlex
2 JFlex Rules
3 Example Identifiers Numbers Strings Comments Keywords
4 Assignment
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 3 / 32
The JAR Files
JFlex uses a number of Java class. These classes have been compiled and are stored in the Java archive file flex-1.6.0.jar. Assignment 6 will have instructions on how to download and install this file.
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 4 / 32
Running JFlex
The lexical analyzer generator is the Main class in the JFlex folder. To create a lexical analyzer from the file filename.flex, type
java jflex.Main filename.flex This produces a file Yylex.java (or whatever we named it), which must be compiled to create the lexical analyzer.
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 5 / 32
Running the Lexical Analyzer
Example (Using the Yylex Class)
InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); Yylex lexer = new Yylex(br); token = lexer.yylex();
To run the lexical analyzer, a Yylex object must first be created. The Yylex constructor has one parameter, specifying a Reader. We will convert standard input, which is an input stream, to a buffered reader. Then call the function yylex() to get the next token.
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 6 / 32
Outline
1 Running JFlex
2 JFlex Rules
3 Example Identifiers Numbers Strings Comments Keywords
4 Assignment
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 7 / 32
JFlex Rules
Each JFlex rule consists of a regular expression and an action to be taken when the expression is matched. The associated action is a segment of Java code, enclosed in braces { }. Typically, the action will be to return the appropriate token.
Robb T. Koether (Hampden-Sydney College)
JFlex Regular Expressions
Wed, Feb 25, 2015 8 / 32
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- regular expressions umd
- introduction to tregex
- regular expressions in jlex edu
- lecture 18 theory of computation regular expressions and
- cs351 intro to unix java regular expressions
- jflex regular expressions
- java regular expressions
- regular expressions the complete tutorial
- microsoft visual studio
- george mason university
Related searches
- regular monthly payment formula
- offset cane vs regular cane
- regular monthly payment calculator
- regular past tense verb worksheet
- how much does a regular doctor make
- regular and irregular verbs exercises
- regular past tense verb activities
- regular past tense worksheet
- word that means regular employment
- school uniforms vs regular clothes
- regular expressions js
- using regular expressions in java