Search for question
Question

Requirements: 1. You need to create two ruby files: dot_lexer.rb where you have a DotLexer class that performs all the token recognition logic and token.rb where you have a Token class

that uses text and type to describe a token. In class DotLexer, you must implement the method next token that returns recognized tokens. prog2_main.rb is provided. 2. All supported token types are listed below. All other tokens are considered as Token::INVALID. All token types should be defined in class Token as constants including the token EOF that indicates the end of file. 3. Invalid characters should be recognized and taken care of. Please refer to the sample output for "Ca#t" in the sample input to get an idea how to deal with an illegal character. 4. The name of a node in dot can be an ID, an INT, or a STRING. An ID starts with a letter followed by letters or digits. An INT contains only digits. A STRING is recognized by double quotes within which all characters are valid. 5. There are only two keywords: digraph (or DIGRAPH) and subgraph (or SUBGRAPH). 6. For whitespaces, such as ", "\r, \t, and '\n', recognize and skip them without printing out.

Fig: 1