Beispiel #1
0
def test_multiple_statements5():
    lexer = Lexer.CreateLexer()
    parser = Parser.CreateParser()

    try:
        program = parse_string("\tnop : bra :")
    except Parser.ParseError:
        pass
Beispiel #2
0
def test_multiple_statements4():
    lexer = Lexer.CreateLexer()
    parser = Parser.CreateParser()

    try:
        program = parse_string("\tnop : jmp $03: 1234 : bra : bcc")
    except Parser.ParseError:
        pass
Beispiel #3
0
def test_lexer_hex1():
    lexer = Lexer.CreateLexer()
    for i in range(0, 1000):
        tokens = list(lexer.lex("${:x}".format(i)))
        assert tokens[0].gettokentype() == 'HEX_NUMBER'
        assert tokens[0].getstr() == "${:x}".format(i)
        tokens = list(lexer.lex("0x{:X}".format(i)))
        assert tokens[0].gettokentype() == 'HEX_NUMBER'
        assert tokens[0].getstr() == "0x{:X}".format(i)
Beispiel #4
0
def test_multiple_statements2():
    lexer = Lexer.CreateLexer()
    parser = Parser.CreateParser()

    tokens = lexer.lex("\tnop jmp bra bcc")
    try:
        program_ast = parser.parse(tokens)
    except Parser.ParseError:
        pass
Beispiel #5
0
def test_lexer_dec1():
    lexer = Lexer.CreateLexer()
    for i in range(0, 1000):
        tokens = list(lexer.lex("{}".format(i)))
        assert tokens[0].gettokentype() == 'DEC_NUMBER'
        assert tokens[0].getstr() == "{}".format(i)
Beispiel #6
0
def test_lexer_bin1():
    lexer = Lexer.CreateLexer()
    for i in range(0, 256):
        tokens = list(lexer.lex("0b{:b}".format(i)))
        assert tokens[0].gettokentype() == 'BIN_NUMBER'
        assert tokens[0].getstr() == "0b{:b}".format(i)
Beispiel #7
0
def test_lexer_oct1():
    lexer = Lexer.CreateLexer()
    for i in range(0, 1000):
        tokens = list(lexer.lex("0o{:o}".format(i)))
        assert tokens[0].gettokentype() == 'OCT_NUMBER'
        assert tokens[0].getstr() == "0o{:o}".format(i)
Beispiel #8
0
def test_multiple_statements3():
    lexer = Lexer.CreateLexer()
    parser = Parser.CreateParser()

    program = parse_string("\tnop : jmp $03:1234 : bra : bcc")
Beispiel #9
0
def test_comment1():
    lexer = Lexer.CreateLexer()
    tokens = list(lexer.lex("; This is a comment"))
    assert len(tokens) == 0, tokens