mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Merge pull request #5388 from BradLewis/fix/parser-stb-image
Fix issue parsing `vendor/stb/image` with the `core:odin/parser` parser
This commit is contained in:
@@ -2307,6 +2307,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
open := expect_token(p, .Open_Paren)
|
open := expect_token(p, .Open_Paren)
|
||||||
p.expr_level += 1
|
p.expr_level += 1
|
||||||
expr := parse_expr(p, false)
|
expr := parse_expr(p, false)
|
||||||
|
skip_possible_newline(p)
|
||||||
p.expr_level -= 1
|
p.expr_level -= 1
|
||||||
close := expect_token(p, .Close_Paren)
|
close := expect_token(p, .Close_Paren)
|
||||||
|
|
||||||
@@ -3526,6 +3527,7 @@ parse_binary_expr :: proc(p: ^Parser, lhs: bool, prec_in: int) -> ^ast.Expr {
|
|||||||
case .When:
|
case .When:
|
||||||
x := expr
|
x := expr
|
||||||
cond := parse_expr(p, lhs)
|
cond := parse_expr(p, lhs)
|
||||||
|
skip_possible_newline(p)
|
||||||
else_tok := expect_token(p, .Else)
|
else_tok := expect_token(p, .Else)
|
||||||
y := parse_expr(p, lhs)
|
y := parse_expr(p, lhs)
|
||||||
te := ast.new(ast.Ternary_When_Expr, expr.pos, end_pos(p.prev_tok))
|
te := ast.new(ast.Ternary_When_Expr, expr.pos, end_pos(p.prev_tok))
|
||||||
@@ -3780,10 +3782,6 @@ parse_import_decl :: proc(p: ^Parser, kind := Import_Decl_Kind.Standard) -> ^ast
|
|||||||
import_name.pos = p.curr_tok.pos
|
import_name.pos = p.curr_tok.pos
|
||||||
}
|
}
|
||||||
|
|
||||||
if !is_using && is_blank_ident(import_name) {
|
|
||||||
error(p, import_name.pos, "illegal import name: '_'")
|
|
||||||
}
|
|
||||||
|
|
||||||
path := expect_token_after(p, .String, "import")
|
path := expect_token_after(p, .String, "import")
|
||||||
|
|
||||||
decl := ast.new(ast.Import_Decl, tok.pos, end_pos(path))
|
decl := ast.new(ast.Import_Decl, tok.pos, end_pos(path))
|
||||||
|
|||||||
@@ -66,3 +66,31 @@ Foo :: bit_field uint {
|
|||||||
ok := parser.parse_file(&p, &file)
|
ok := parser.parse_file(&p, &file)
|
||||||
testing.expect(t, ok, "bad parse")
|
testing.expect(t, ok, "bad parse")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
test_parse_parser :: proc(t: ^testing.T) {
|
||||||
|
context.allocator = context.temp_allocator
|
||||||
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
|
|
||||||
|
pkg, ok := parser.parse_package_from_path(ODIN_ROOT + "core/odin/parser")
|
||||||
|
|
||||||
|
testing.expect(t, ok, "parser.parse_package_from_path failed")
|
||||||
|
|
||||||
|
for key, value in pkg.files {
|
||||||
|
testing.expectf(t, value.syntax_error_count == 0, "%v should contain zero errors", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
test_parse_stb_image :: proc(t: ^testing.T) {
|
||||||
|
context.allocator = context.temp_allocator
|
||||||
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
|
|
||||||
|
pkg, ok := parser.parse_package_from_path(ODIN_ROOT + "vendor/stb/image")
|
||||||
|
|
||||||
|
testing.expect(t, ok, "parser.parse_package_from_path failed")
|
||||||
|
|
||||||
|
for key, value in pkg.files {
|
||||||
|
testing.expectf(t, value.syntax_error_count == 0, "%v should contain zero errors", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user