|
|
@ -64,38 +64,39 @@ var primitivesTests = []struct {
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_object_end, "}"},
|
|
|
|
{t_object_end, "}"},
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
{`0`, []token{{t_number, "0"}}},
|
|
|
|
{`0`, []token{{t_real_number, "0"}}},
|
|
|
|
{`-0`, []token{{t_number, "-0"}}},
|
|
|
|
{`-0`, []token{{t_real_number, "-0"}}},
|
|
|
|
{`+0`, []token{{t_number, "+0"}}},
|
|
|
|
{`+0`, []token{{t_real_number, "+0"}}},
|
|
|
|
{`+125`, []token{{t_number, "+125"}}},
|
|
|
|
{`+125`, []token{{t_real_number, "+125"}}},
|
|
|
|
{`-125`, []token{{t_number, "-125"}}},
|
|
|
|
{`-125`, []token{{t_real_number, "-125"}}},
|
|
|
|
{`.0`, []token{{t_number, ".0"}}},
|
|
|
|
{`.0`, []token{{t_real_number, ".0"}}},
|
|
|
|
{`15`, []token{{t_number, "15"}}},
|
|
|
|
{`15`, []token{{t_real_number, "15"}}},
|
|
|
|
{`0x0`, []token{{t_number, "0x0"}}},
|
|
|
|
{`0x0`, []token{{t_real_number, "0x0"}}},
|
|
|
|
{`0xa`, []token{{t_number, "0xa"}}},
|
|
|
|
{`0xa`, []token{{t_real_number, "0xa"}}},
|
|
|
|
{`0xc0dea5cf`, []token{{t_number, "0xc0dea5cf"}}},
|
|
|
|
{`0xc0dea5cf`, []token{{t_real_number, "0xc0dea5cf"}}},
|
|
|
|
{`12.345`, []token{{t_number, "12.345"}}},
|
|
|
|
{`12.345`, []token{{t_real_number, "12.345"}}},
|
|
|
|
{`12.345 name`, []token{{t_number, "12.345"}, {t_name, "name"}}},
|
|
|
|
{`12.345 name`, []token{{t_real_number, "12.345"}, {t_name, "name"}}},
|
|
|
|
{`[12.345]`, []token{
|
|
|
|
{`[12.345]`, []token{
|
|
|
|
{t_list_start, "["},
|
|
|
|
{t_list_start, "["},
|
|
|
|
{t_number, "12.345"},
|
|
|
|
{t_real_number, "12.345"},
|
|
|
|
{t_list_end, "]"},
|
|
|
|
{t_list_end, "]"},
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
{`[1, 2, 3]`, []token{
|
|
|
|
{`[1, 2, 3]`, []token{
|
|
|
|
{t_list_start, "["},
|
|
|
|
{t_list_start, "["},
|
|
|
|
{t_number, "1"},
|
|
|
|
{t_real_number, "1"},
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_number, "2"},
|
|
|
|
{t_real_number, "2"},
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_list_separator, ","},
|
|
|
|
{t_number, "3"},
|
|
|
|
{t_real_number, "3"},
|
|
|
|
{t_list_end, "]"},
|
|
|
|
{t_list_end, "]"},
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
// an imaginary number generates two lexemes; one for its real component,
|
|
|
|
{`1i`, []token{{t_imaginary_number, "1i"}}},
|
|
|
|
|
|
|
|
// a complex number generates two lexemes; one for its real component,
|
|
|
|
// and one for its imaginary component.
|
|
|
|
// and one for its imaginary component.
|
|
|
|
{`1+2i`, []token{{t_number, "1"}, {t_number, "+2i"}}},
|
|
|
|
{`1+2i`, []token{{t_real_number, "1"}, {t_imaginary_number, "+2i"}}},
|
|
|
|
{`1e9`, []token{{t_number, "1e9"}}},
|
|
|
|
{`1e9`, []token{{t_real_number, "1e9"}}},
|
|
|
|
{`1e+9`, []token{{t_number, "1e+9"}}},
|
|
|
|
{`1e+9`, []token{{t_real_number, "1e+9"}}},
|
|
|
|
{`1E-9`, []token{{t_number, "1E-9"}}},
|
|
|
|
{`1E-9`, []token{{t_real_number, "1E-9"}}},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestLexPrimities(t *testing.T) {
|
|
|
|
func TestLexPrimities(t *testing.T) {
|
|
|
|