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 requirements for a valid file path are:
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
Directory names and file names must contain at least one character
Label the edges of your FSM with words slash, dot, letter, and digit.
Examples of valid file paths:
/P1.java /a/very/long/directory/.file /foo/I.have.many.many.dots /bar/NoDot
Examples of invalid file paths:
P1.java /bad/file..name /another/bad/filename.
Write a regular expression for a UsernameTag.
A UsernameTag has the following format : UserName#Number
and must meet the following requirements:
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 must contain at least one digit
Examples of valid UsernameTags:
hello-world#45 life4compiler#0102
Examples of invalid UsernameTags:
not-a-user-tag# also-not-a-user-tag#number123 invalid--usertag#319 32invalid-#987
You may use hyphen to represent "-", digit to represent any digit, and letter to represent any letter.
Last Updated: 2/1/2024 © 2024 CS 536