Você está na página 1de 3

CSL302: Assignment: Lexical Analysis

CSL302 - Programming Languages ◄ Jump to...


courseDatabase► CSL302► Assignments► Lexical Analysis

Programming Languages Assignment 1

Due date: Feb 12, 2010

Lex: Use ML-Lex or OCaml-lex to recognize the following tokens:

Identifiers: which can be

▪ Variables, alphanumeric strings (digits, letters) which begin with a Capital letter

('A'..'Z') and which may have underscores and apostrophes as well (in the middle or

end). Examples A1_a, A1', A1_', but not _A, a1, 1A, etc.

▪ Constant and Function symbols, again alphanumeric strings (digits, letters) which

begin with a lower case letter ('a'-'z'), and which may have underscores and

apostrophes.

▪ Numerical constants:

▪ Integers: Sequences of digits that do not have redundant 0's at the beginning, and

which can be preceded by an optional + or ~ sign. examples: 37, +8, 0, -9, etc but not

007, +0, -), etc.

▪ Real constants: Integer numeral followed by a decimal point and then at least one

http://jaijaivanti.cse.iitd.ernet.in/moodle/mod/assignment/view.php?id=365 (1 of 3) [2/10/2010 12:54:45 AM]


CSL302: Assignment: Lexical Analysis

digit but no unnecessary zeroes at the end. examples: -3.0, 4.0034 but not 4., .3 or

0.30

▪ Boolean constants: true and false.

Operators: Arithmetic: +, *, div, mod, -, abs

boolean: not, \/, /\

comparisons: =, >=, <=, >, <

Separators: whitespace (space, tab, newline, new page)

Punctuation: ; (semicolon) , (comma) . (period). left "(" and right ")" parentheses.

Keywords: if, then, else, define

Assignment: Convert a sequence of characters into a sequence of tokens represented

in ML or OCaml, giving appropriate error messages.

Available from: Sunday, 31 January 2010, 01:15 PM

Due date: Friday, 12 February 2010, 11:55 PM

Submission draft

http://jaijaivanti.cse.iitd.ernet.in/moodle/mod/assignment/view.php?id=365 (2 of 3) [2/10/2010 12:54:45 AM]


CSL302: Assignment: Lexical Analysis

No files submitted yet

Upload a file (Max size: 1MB)

Browse...

Upload this file

You are logged in as simranjit kohli (Logout)

CSL302

http://jaijaivanti.cse.iitd.ernet.in/moodle/mod/assignment/view.php?id=365 (3 of 3) [2/10/2010 12:54:45 AM]

Você também pode gostar