Odin grammar for tree-sitter
tree-sitter-grammars / tree-sitter-odin Goto Github PK
View Code? Open in Web Editor NEWOdin grammar for tree-sitter
License: MIT License
Odin grammar for tree-sitter
License: MIT License
Odin grammar for tree-sitter
Some fields are getting randomly highlighted. I say randomly because I couldn't make any sense of the pattern.
It seems to me that the cause for the bug is the way how I format my code. By putting the '{' on the same line as the procedure declaration the problem disappears,
Another way I've found that eliminates the problems is putting a semicolon at the end of the first line with a field highlighted with the white color, by doing that the following lines of the procedure would get fixed. Putting the semicolon at the end of line with a red highlighted field doesn`t do anything.
The code is from the Odin's Idiomatic Examples collection and it can be found here. All images presents valid Odin code.
Using this page https://meimporta.eu/tree-sitter/json2ebnf.html we can get a navigable railroad diagram for tree-sitter grammars like this project.
See also tree-sitter/tree-sitter#2268 .
Cheers !
Lately I've noticed that most of my projects are having syntax highlighting issues with strings being highlighted as not closed despite having clear end markers. I didn't notice it being at all this bad until recently, which I think coincides with an upgrade (unexpected downgrade) of the nvim-treesitter
plugin which bundles this repository as the Odin parser by default.
Some examples:
testing.expect_value(t, s, "foo")
testing.expect(
t,
slice.equal(remaining_arguments, expected_arguments),
fmt.tprintf("Expected remaining arguments to equal %v, got: %v", remaining_arguments),
)
i: int
expected_arguments = []string{}
i, remaining_arguments, error = parse_arguments_as_type({"123"}, int, context.allocator)
testing.expect_value(t, error, nil)
testing.expect_value(t, i, 123)
testing.expect(
t,
slice.equal(remaining_arguments, expected_arguments),
fmt.tprintf("Expected remaining arguments to equal %v, got: %v", remaining_arguments),
)
What actually seems to close the example above is yet another missed closing quote:
ts: TestStruct
expected_arguments = []string{"rest", "of", "arguments"}
ts, remaining_arguments, error = parse_arguments_as_type(
{
"-2",
"123",
"--field-one",
"foo",
"--no-tag",
"123.456",
"--field-three",
"true",
"rest",
"of",
"arguments",
},
TestStruct,
context.allocator,
)
testing.expect_value(t, error, nil)
testing.expect_value(
t,
ts,
TestStruct{field_one = "foo", field_two = 123, field_three = true, no_tag = 123.456},
)
@(test, private = "package")
test_parse_argument_as_type :: proc(t: ^testing.T) {
context.logger = log.create_console_logger()
tid: typeid
tid = string
bytes, error := parse_argument_as_type("foo", tid, context.allocator)
s := mem.reinterpret_copy(string, raw_data(bytes))
testing.expect_value(t, error, nil)
testing.expect(t, s == "foo", fmt.tprintf("Expected 'foo', got '%s'", s))
tid = int
bytes, error = parse_argument_as_type("123", tid, context.allocator)
i := mem.reinterpret_copy(int, raw_data(bytes))
testing.expect_value(t, error, nil)
testing.expect(t, i == 123, fmt.tprintf("Expected 123, got %d", i))
The above one goes on for several procedures and type definitions until we reach this:
@(test, private = "package")
test_struct_decoding_info :: proc(t: ^testing.T) {
cli_info, allocator_error := struct_decoding_info(TestStruct)
if allocator_error != nil {
fmt.panicf("Allocator error: %s", allocator_error)
}
fields := []FieldCliInfo {
{
name = "field_one",
type = string,
cli_short_name = "1",
cli_long_name = "field-one",
offset = 0,
required = false,
size = 16,
},
{
name = "field_two",
type = int,
cli_short_name = "2",
cli_long_name = "field-two",
offset = 16,
required = true,
size = 8,
},
{
name = "field_three",
type = bool,
cli_short_name = "",
cli_long_name = "field-three",
offset = 24,
required = true,
size = 1,
},
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.