def testTokenListIterability( self ): """TokenList should be iterable""" tokens = TokenList() the_tokens = [ Token( 'IDENTIFIER', 'first'), Token( 'IDENTIFIER', 'second' ) ] tokens.append( the_tokens ) for token in tokens: self.assertEqual( token, tokens.next() )
def testTokenListAppendTuple( self ): """TokenList.append should append a tuple correctly""" tokens = TokenList() the_tokens = ( Token( 'IDENTIFIER', 'first'), Token( 'IDENTIFIER', 'second' ) ) tokens.append( the_tokens ) self.assertEqual( the_tokens[0], tokens.next() ) self.assertEqual( the_tokens[1], tokens.next() )
import argparse import logging from AST import AST from code_generator import Generator from tokenizer import TokenList if __name__ == '__main__': parser = argparse.ArgumentParser(description='F-Stroke Language Compiler') parser.add_argument('input', type=str, help='File to input with F-Stroke code', default='input.fst') parser.add_argument('-o', type=str, help='File to output with Ethereum Byte Code', default='output.ebc') parser.add_argument('--hex-size', type=int, help='Size of hex numbers in bytes (max 32)', default=32) args = parser.parse_args() code = open(args.input).read() tokens = TokenList(code) tree = AST(tokens) output = open(args.o, 'w+') output.write(str(Generator(tree, args.hex_size).run())) output.flush() output.close()
def __init__(self, tokenList=TokenList()): self.tokens = tokenList
def testTokenListAppendSingle( self ): """TokenList.append should append a single Token correctly""" tokens = TokenList() the_token = Token( 'IDENTIFIER', 'x') tokens.append( the_token ) self.assertEqual( the_token, tokens.next() )