def initialize(sourceText): """ """ global scanner # initialize the scanner with the sourceText scanner.initialize(sourceText) # use the scanner to read the first character from the sourceText getChar()
def main(sourceText): global f f = open(outputFilename, "w") writeln("Here are the characters returned by the scanner:") writeln(" line col character") Scanner.initialize(sourceText) character = Scanner.get() while True: writeln(character) if character.cargo == Scanner.ENDMARK: break character = Scanner.get() f.close()
def main(sourceText): global f f = open(outputFilename, "w") # open the ouput file writeln("Here are the characters returned by the scanner:") writeln(" line col character") # create a scanner (an instance of the Scanner class) scanner.initialize(sourceText) #------------------------------------------------------------------ # Call the scanner's get() method repeatedly # to get the characters in the sourceText. # Stop when we reach the ENDMARK. #------------------------------------------------------------------ character = scanner.get() # getfirst Character object from the scanner while True: writeln(character) if character.cargo == scanner.ENDMARK: break character = scanner.get() # getnext f.close() # close the output file
def main(sourceText): global f f = open(outputFilename, "w") # open the ouput file #fragment start core writeln("Here are the characters returned by the scanner:") writeln(" line col character") # create a scanner (an instance of the Scanner class) scanner.initialize(sourceText) #------------------------------------------------------------------ # Call the scanner's get() method repeatedly # to get the characters in the sourceText. # Stop when we reach the ENDMARK. #------------------------------------------------------------------ character = scanner.get() # getfirst Character object from the scanner while True: writeln(character) if character.cargo == scanner.ENDMARK: break character = scanner.get() # getnext #fragment stop core f.close() # close the output file
def initialize(sourceText): Scanner.initialize(sourceText) getChar()