Preview

Jlex

Good Essays
Open Document
Open Document
1777 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Jlex
JLex
[pic]

Contents

• Overview • Format of a JLex Specification o Regular Expression Rules ▪ Test Yourself #1 o JLex Directives ▪ Test Yourself #2 o Comments • yyline and yytext • A Small Example • Quick Reference Guide

Overview

JLex is a scanner generator that produces Java code. Here's a picture illustrating how to create and run a program using JLex:

+-----------+

JLex specification ---> | JLex.Main | ---> Java source code

(xxx.jlex) +-----------+ (xxx.jlex.java)

+------------------+

xxx.jlex.java ---> | jikes (or javac) | ---> Yylex.class

+------------------+

+--------+

Yylex.class-------> | java | ---> output of Main

Main.class--------> | |

+--------+

The input to Jlex is a specification that includes a set of regular expressions and associated actions. The output of Jlex is a Java source file that defines a class named Yylex. Yylex includes a constructor that is called with one argument: the input stream (an InputStream or a Reader). It also includes a method called next_token, which returns the next token in the input.
The picture above assumes that a class named Main has been defined that contains the main program of interest. That program will declare an object of type Yylex, and will include calls to the Yylex constructor and its next_token method.

Format of a JLex Specification

A JLex specification has three parts, separated by double percent signs: 1. User code: this part of the specification will not be discussed here. 2. JLex directives: This includes macro definitions (described below). See the JLex Reference Manual for more information about this part of the specification. 3. Regular expression rules: These rules specify how to divide up the input into

You May Also Find These Documents Helpful

  • Satisfactory Essays

    LAb1Ecet230

    • 221 Words
    • 3 Pages

    4. What is “JTAG” and why is it used? Be sure to cite your sources.…

    • 221 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    In this phase a token is generated against all the lexemes in the source code. These lexemes and tokens are stored in the Symbol Table. Tokens against the lexemes are generated based on some patterns or rules.…

    • 703 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Homework Week 2

    • 743 Words
    • 3 Pages

    A compiler translates one computer language into another. It also pics up errors in the program being put together.…

    • 743 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Some similarities in these programs are that there are specific words you cannot use in each language. These words are generally reserved for some other part of the language and if the is not some kind of distinction between the words this will cause an error. Though these languages have minor similarities they differ in the same way, some are case sensitive while others are not. They also say that most variables should begin with a letter but in two of these programs they can begin with an underscore and in Java you can use a dollar sign as well. Another key difference is the length of the variable name, in Visual Basic you are limited to a length of 255 characters while the other two have no restrictions on length. So for each language there are minor similarities and differences but in order to program in any of these languages you must know these rules in order to prevent errors from…

    • 878 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Intro the Programming

    • 386 Words
    • 5 Pages

    The ________ is a collection of statements enclosed inside a set of curly braces that are performed when the method is…

    • 386 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Jhnlk

    • 276 Words
    • 2 Pages

    In what ways did religion and economic influence the development of medieval Europe and Japan?…

    • 276 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    II. The general syntax for defining a class is shown here. It may look complicated, because it’s written in very general form here, but it’s very simple.…

    • 939 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    Deitel, H.M., & Deitel, P.J. (2002). Java: How to program (6th ed.). Upper Saddle River, NJ: Pearson…

    • 253 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    dasjdasdnafndsafna

    • 1601 Words
    • 7 Pages

    G54SIM (Spring 2012/2013) Lecture 01 Introduction to Modelling and Simulation Peer-Olaf Siebers pos@cs.nott.ac.uk Container Terminal of Novorossiysk G54SIM 2 Module Mission Statement • This module will explain the main systems simulation methods in detail so that students will be competent in choosing and implementing the right method for their particular problem. • Students will learn the general principles and techniques used in modelling and simulation and will gain some practical experience of how to develop and implement their own simulation models.…

    • 1601 Words
    • 7 Pages
    Satisfactory Essays
  • Good Essays

    Computing Test Questions

    • 1469 Words
    • 6 Pages

    10. To view a Java Applet in a Web browser, the Web browser requires a…

    • 1469 Words
    • 6 Pages
    Good Essays
  • Satisfactory Essays

    Core Java Vol Ii 8th Ed.

    • 21466 Words
    • 86 Pages

    Core Java Volume II-Advanced Features, Eighth Edition - Graphically Rich Book ....................... 1 Table of Contents ................................................................................................................................................................................. 2 Copyright ..................................................................................................................................................................................................... 5 Preface .......................................................................................................................................................................................................... 7 Acknowledgments ............................................................................................................................................................................. 10 Chapter 1. Streams and Files .................................................................................................................................................. 11 Streams ................................................................................................................................................................................................ 22 Text Input and Output .................................................................................................................................................................... 33 Reading and Writing Binary Data ............................................................................................................................................. 43 ZIP Archives ....................................................................................................................................................................................... 51 Object Streams and Serialization…

    • 21466 Words
    • 86 Pages
    Satisfactory Essays
  • Powerful Essays

    8085

    • 2083 Words
    • 10 Pages

    instruction JC (Jump on Carry) is implemented to change the sequence of a program when the CY…

    • 2083 Words
    • 10 Pages
    Powerful Essays
  • Satisfactory Essays

    s.executeUpdate("UPDATE studentdetails SET stname= '"+jTextField2.getText()+"' , stage= '"+jTextField3.getText()+"', sttel= '"+jTextField4.getText()+"', stresult= '"+jTextField4.getText()+"' WHERE stid = '"+jTextField1.getText()+"' ");…

    • 2413 Words
    • 17 Pages
    Satisfactory Essays
  • Powerful Essays

    corba

    • 4045 Words
    • 17 Pages

    In this section, you will write a simple IDL interface for the Hello World program. The IDL interface defines the contract between the client and server parts of your application, specifying what operations and attributes are available. OMG IDL is programming-language independent. You must map it to Java before writing any of the implementation code. (Running idltojava on the IDL file does this for you automatically.) Here's the complete Hello.idl file:…

    • 4045 Words
    • 17 Pages
    Powerful Essays
  • Good Essays

    Exception Handling

    • 879 Words
    • 4 Pages

    Exception is an abnormal condition that arises when executing a program. In the languages that do not support exception handling, errors must be checked and handled manually, usually through the use of error codes. In contrast, Java: 1) provides syntactic mechanisms to signal, detect and handle errors 2) ensures a clean separation between the code executed in the absence of errors and the code to handle various kinds of errors 3) brings run-time error management into object-oriented programming…

    • 879 Words
    • 4 Pages
    Good Essays