bject Compiler var curren t Token String = \"\" var fileContents : String = \"\"
ID: 3601069 • Letter: B
Question
bject Compiler var curren t Token String = "" var fileContents : String = "" val scanner = new MyLexica!Analyzer val Parser= new MysyntaxAnalyzer val Semant1cAnalyzer = new MySyntaxAnalyzer def main (args: Array [String]): Unit { checkFile (args) readFile(args (0)) Scanner.getNextToken () def readFile (file : String) = { val source scala. io. source. fromFile ( file) fileContents = try source.mkstring finally source.close() def checkFile (args : Array [String]) = { if (args.length != 1) println ("USAGE ERROR: wrong number of args fool!") System. exit(1) else if args (0) .endsWith (" .mkd"f println ("USAGE ERROR: wrong extension fool!") System. exit(1)Explanation / Answer
The Scanner class is used to read in tokens from an input stream. A token is a sequence of characters of some form that correspond to valid values of certain Java types. For example:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.