mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
@@ -861,6 +861,7 @@ Bit_Field_Field :: struct {
|
|||||||
name: ^Expr,
|
name: ^Expr,
|
||||||
type: ^Expr,
|
type: ^Expr,
|
||||||
bit_size: ^Expr,
|
bit_size: ^Expr,
|
||||||
|
tag: tokenizer.Token,
|
||||||
comments: ^Comment_Group,
|
comments: ^Comment_Group,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2832,11 +2832,17 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
|||||||
expect_token(p, .Or)
|
expect_token(p, .Or)
|
||||||
bit_size := parse_expr(p, true)
|
bit_size := parse_expr(p, true)
|
||||||
|
|
||||||
|
tag: tokenizer.Token
|
||||||
|
if p.curr_tok.kind == .String {
|
||||||
|
tag = expect_token(p, .String)
|
||||||
|
}
|
||||||
|
|
||||||
field := ast.new(ast.Bit_Field_Field, name.pos, bit_size)
|
field := ast.new(ast.Bit_Field_Field, name.pos, bit_size)
|
||||||
|
|
||||||
field.name = name
|
field.name = name
|
||||||
field.type = type
|
field.type = type
|
||||||
field.bit_size = bit_size
|
field.bit_size = bit_size
|
||||||
|
field.tag = tag
|
||||||
|
|
||||||
append(&fields, field)
|
append(&fields, field)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
package test_core_odin_parser
|
package test_core_odin_parser
|
||||||
|
|
||||||
|
import "base:runtime"
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:log"
|
||||||
import "core:odin/ast"
|
import "core:odin/ast"
|
||||||
import "core:odin/parser"
|
import "core:odin/parser"
|
||||||
import "base:runtime"
|
import "core:odin/tokenizer"
|
||||||
import "core:testing"
|
import "core:testing"
|
||||||
|
|
||||||
@test
|
@test
|
||||||
@@ -34,7 +38,7 @@ Foo :: bit_field uint {}
|
|||||||
Foo :: bit_field uint {hello: bool | 1}
|
Foo :: bit_field uint {hello: bool | 1}
|
||||||
|
|
||||||
Foo :: bit_field uint {
|
Foo :: bit_field uint {
|
||||||
hello: bool | 1,
|
hello: bool | 1 ` + "`fmt:\"-\"`" + `,
|
||||||
hello: bool | 5,
|
hello: bool | 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +52,17 @@ Foo :: bit_field uint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
p := parser.default_parser()
|
p := parser.default_parser()
|
||||||
|
|
||||||
|
p.err = proc(pos: tokenizer.Pos, format: string, args: ..any) {
|
||||||
|
message := fmt.tprintf(format, ..args)
|
||||||
|
log.errorf("%s(%d:%d): %s", pos.file, pos.line, pos.column, message)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.warn = proc(pos: tokenizer.Pos, format: string, args: ..any) {
|
||||||
|
message := fmt.tprintf(format, ..args)
|
||||||
|
log.warnf("%s(%d:%d): %s", pos.file, pos.line, pos.column, message)
|
||||||
|
}
|
||||||
|
|
||||||
ok := parser.parse_file(&p, &file)
|
ok := parser.parse_file(&p, &file)
|
||||||
testing.expect(t, ok, "bad parse")
|
testing.expect(t, ok, "bad parse")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user