Search for question
Question

Problem 1. Consider the list of tokens T1 = { "supper", "abcdle" } T2 = { "abd" } SUPPERID = strings that are ID (see below) and that have “supper” as prefix. For example, “supper123”, “supper”, “supperabc” are SUPPERID, but “supper_” is not SUPPERID because "supper_" is not an ID " " 11 ID = Set of strings that consist of a letter or underscore that is followed by zero or more letters and/or digits. For example, ‘_11”, “_1alb” are IDs, but "_ and "a_" are not IDs according to this definition CRAZYID = Set of strings that consist of an ID followed by "_crazy". For example, "a_crazy" is a CRAZYID, but “a_CRAZY", "acrazy" and "a_crazy" (two underscores) are not a CRAZYID NUM=Set of strings that consist of a non-zero digit that is followed by 1 or more digits or the string "0". For this problem, when identifying tokens in the input, we treat & and ! as separators. This means that getToken() should stop when it reaches & or ! and returns the longest matching prefix up to but not including the separator. The separator itself (& or !) cannot be part of a token, so the next token starts after the separators. & and ! are the only separator. Space characters are not separators for this problem. Consider the input: supper22 crazyabc!!&d1_11&_supper_11&123abcdle and the following sequence of calls: t1 = lexer.GetToken(); t2 = lexer.GetToken(); t3 = lexer.peek(1); t4 = lexer.peek(3); t5 = lexer.peek(5); t6 = lexer.peek(7); t7=lexer.GetToken(); t8 = lexer.GetToken(); What are the values of t1, t2, t3, t4, t5, t6, t7 and t8? You are only asked to give the values and not to explain how you obtained them.