This homework is due at 11 PM on Sep 24. It will not be accepted late.
Make sure to follow the submission instructions. Link
Draw a deterministic finite state machine
that accepts the language of file paths.
A file path consists of optional directory names and one file name, separated by "/".
The path must start with "/"
A directory name can include letters and digits
A file name can include letters, digits and dots
A file name cannot have two dots in a row
A file name cannot end with a dot
CLARIFICATION: Both file name and directory name should contain at least one character
Write a regular expression for a UsernameTag. A UsernameTag is of the following format : UserName#Number
UserName and Number are separated by "#"
UserName can include letters, digits and "-"
UserName must start with a letter, and cannot end with "-"
UserName cannot have two "-" in a row
Number can only include digits, and should contain at least one digit
You may use hyphen to represent "-", digit to represent any digit, and letter to represent any letter.
Java (as well as C and C++) allows comments delimited by "/*" and "*/". This kind of comment can be defined in English as follows:A comment consists of three parts:
a slash followed by a star, followed by
Note that the body of a comment can include stars and slashes, just not "*/".
Assume that the following JLex macros have been defined:
SLASH = [/]
STAR = [*]
Label each of the following JLex patterns as being correct/incorrect for the type of the comment described above.
Give a correct JLex pattern for single-line comments in Java (and also C and C++). Note that single-line comments begin with // and end with a newline character.
For the purposes of this homework you may assume that \n is the newline character.
You may define and use additional macros. Make your pattern as readable as possible.