Hw2 - token as a pair as in the example below Use the terminology from the http/java.sun.com/docs/books/jls second_edition/html/lexical.html#48198

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
VERSION Sep 8, 2009 CS-441 Fall 2010 JWJ CS UK Homework Assignment # 2 —This material is only for use in CS441-Fall 2010 in the Department of Computer Science at the University of Kentucky.— —Please, do not distribute.— Due: solve by Tuesday, Sep 7, 2010 Learning outcomes: Lexical analysis and tokens. Lexical structure of a high-level programming language (Java). Tokenizing Java programs. Tasks and Questions The first part is a reading assignment to get familiar with the lexical structure of Java. The second part gives a Java program for tokenization. The assignment does not require Java programming or knowing Java. hw2.1: Read (at least ) the following two sections from a Java manual available at http://java.sun.com/docs/ books/jls/ : Section 2.2 and Chapter 3. Pay particular attention to token types. hw1.2 List all the types and subtypes of tokens in Java (based on the manual). Are comments in Java programs considered to be tokens? hw1.3 This part pertains to identifying tokens in a Java program; tokenize the following Java program. Present each
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: token as a pair, as in the example below. Use the terminology from the http://java.sun.com/docs/books/jls/ second_edition/html/lexical.doc.html#48198 for token types. Make sure that comments are handled correctly. (The below code is taken from http://www.leepoint.net/notes-java/ . public static void reverse(int b) { for (int left=0, int right=b.length-1; left<right; left++, right--) { // exchange the first and last int temp = b[left]; b[left] = b[right]; b[right] = temp; }//endmethod reverse Example: (one line from a Java program) public static void example_h2(int x) { The corresponding tokens are: <keyword, public> <keyword, static> 1 VERSION Sep 8, 2009 <keyword, void> <identifier, example_h2> <seperator, (> <keyword, int> <seperator, [> <seperator, ]> <identifier, x> <seperator, )> <seperator, {> 2...
View Full Document

This document was uploaded on 12/14/2010.

Page1 / 2

Hw2 - token as a pair as in the example below Use the terminology from the http/java.sun.com/docs/books/jls second_edition/html/lexical.html#48198

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online