graphics
This commit is contained in:
@@ -50,13 +50,15 @@ pub const Lexer = struct {
|
||||
return self.lexString(start);
|
||||
}
|
||||
|
||||
// Directives: #import, #insert, #run, #builtin
|
||||
// Directives: #import, #insert, #run, #builtin, #foreign, #library
|
||||
if (c == '#') {
|
||||
const directives = .{
|
||||
.{ "#import", Tag.hash_import },
|
||||
.{ "#insert", Tag.hash_insert },
|
||||
.{ "#run", Tag.hash_run },
|
||||
.{ "#builtin", Tag.hash_builtin },
|
||||
.{ "#foreign", Tag.hash_foreign },
|
||||
.{ "#library", Tag.hash_library },
|
||||
};
|
||||
inline for (directives) |d| {
|
||||
const keyword = d[0];
|
||||
@@ -370,6 +372,25 @@ test "lex hash_insert" {
|
||||
try std.testing.expectEqual(Tag.invalid, lex2.next().tag);
|
||||
}
|
||||
|
||||
test "lex hash_foreign" {
|
||||
var lex = Lexer.init("#foreign");
|
||||
try std.testing.expectEqual(Tag.hash_foreign, lex.next().tag);
|
||||
try std.testing.expectEqual(Tag.eof, lex.next().tag);
|
||||
|
||||
var lex2 = Lexer.init("#foreignx");
|
||||
try std.testing.expectEqual(Tag.invalid, lex2.next().tag);
|
||||
}
|
||||
|
||||
test "lex hash_library" {
|
||||
var lex = Lexer.init("#library \"raylib\"");
|
||||
try std.testing.expectEqual(Tag.hash_library, lex.next().tag);
|
||||
try std.testing.expectEqual(Tag.string_literal, lex.next().tag);
|
||||
try std.testing.expectEqual(Tag.eof, lex.next().tag);
|
||||
|
||||
var lex2 = Lexer.init("#librarypath");
|
||||
try std.testing.expectEqual(Tag.invalid, lex2.next().tag);
|
||||
}
|
||||
|
||||
test "lex string" {
|
||||
var lex = Lexer.init("\"Hello\"");
|
||||
const tok = lex.next();
|
||||
|
||||
Reference in New Issue
Block a user