1
|
BlockStmt([AssignStmt(IdentifierNode('words'), ListNode([StringNode('HELLO'), StringNode('COMPUTER'), StringNode('KEYBOARD'), StringNode('INTERNET'), StringNode('CORRECT'), StringNode('HORSE'), StringNode('BATTERY'), StringNode('STAPLE')])), AssignStmt(IdentifierNode('word'), CallNode(IdentifierNode('choice'), [IdentifierNode('words')])), AssignStmt(IdentifierNode('user'), BinOpNode(ListNode([StringNode('_')]), CallNode(IdentifierNode('len'), [IdentifierNode('word')]), '*')), AssignStmt(IdentifierNode('tries'), NumberNode(10)), WhileStmt(NumberNode(True), [IfStmt(BinOpNode(IdentifierNode('tries'), NumberNode(0), '<='), [DisplayStmt(StringNode('You lose!'), True), DisplayStmt(BinOpNode(StringNode('The word was: '), IdentifierNode('word'), '+'), True), BreakStmt()]), DisplayStmt(CallNode(IdentifierNode('c_str'), [IdentifierNode('user')]), True), IfStmt(BinOpNode(IdentifierNode('user'), CallNode(IdentifierNode('c_list'), [IdentifierNode('word')]), '=='), [DisplayStmt(StringNode('You win!'), True), BreakStmt()]), DisplayStmt(BinOpNode(IdentifierNode('tries'), StringNode(' tries remaining'), '+'), True), InputStmt(IdentifierNode('current'), StringNode('? '), True), IfStmt(BinOpNode(CallNode(IdentifierNode('len'), [IdentifierNode('current')]), NumberNode(1), '!='), [ContinueStmt()]), AssignStmt(IdentifierNode('found'), NumberNode(False)), ForStmt('i', NumberNode(0), BinOpNode(CallNode(IdentifierNode('len'), [IdentifierNode('user')]), NumberNode(1), '-'), [IfStmt(BinOpNode(ArrayAccessNode(IdentifierNode('word'), IdentifierNode('i')), CallNode(IdentifierNode('upper'), [IdentifierNode('current')]), '=='), [AssignStmt(ArrayAccessNode(IdentifierNode('user'), IdentifierNode('i')), ArrayAccessNode(IdentifierNode('word'), IdentifierNode('i'))), AssignStmt(IdentifierNode('found'), NumberNode(True))])], None), IfStmt(UnaryOpNode(IdentifierNode('found'), 'NOT'), [AssignStmt(IdentifierNode('tries'), BinOpNode(IdentifierNode('tries'), NumberNode(1), '-'))]), DisplayStmt(StringNode(' '), True)])])
|