sam701 / zig-toml Goto Github PK
View Code? Open in Web Editor NEWZig TOML (v1.0.0) parser
License: MIT License
Zig TOML (v1.0.0) parser
License: MIT License
pub fn main() !void {
var parser = toml.Parser(Watah).init(std.heap.page_allocator);
var parsed = try parser.parseString(
\\forsen = "abc"
);
std.debug.print("{s} {any}\n", .{ parsed.value.forsen, parsed.value.fdefault });
}
const Watah = struct {
forsen: []const u8,
fdefault: u8 = 2,
};
Even though fdefault
has a default value of 2 here, the parser returns an error because it doesn't find it in the string:
> zig run src/main.zig
error: MissingRequiredField
D:\VSRepos\test\src\zig-toml\src\struct_mapping.zig:37:25: 0x7ff7eb4876a9 in intoStruct__anon_4214 (main.exe.obj)
return error.MissingRequiredField;
^
D:\VSRepos\test\src\zig-toml\src\main.zig:98:17: 0x7ff7eb4888d8 in parseString (main.exe.obj)
return err;
^
D:\VSRepos\test\src\main.zig:6:18: 0x7ff7eb488c65 in main (main.exe.obj)
var parsed = try parser.parseString(
this is an example of toml
[tasks.a]
cmd = "echo 123"
[tasks.b]
cmd = "echo 123"
I need a possible way to parse this tasks, I can't predict the keys
Thank you
$ zig fetch --save https://github.com/sam701/zig-toml/archive/2b82dbc747b1a9c79d7e53ef77a1bcb3fbb3830b.tar.gz
error: unable to determine name; fetched package has no build.zig.zon file
I tried run/building it with many different versions.
0.10.0, 0.10.1, 0.9.1 and the 3 newest 0.11.0-dev and all of them give me pretty much the same error.
With the 0.11.0-dev.1478+ce20ebb50 I get the following error when I run "zig run build.zig".
/home/toni/.local/bin/lib/std/start.zig:601:45: error: root struct of file 'build' has no member named 'main'
switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) {
~~~~^~~~~
/home/toni/.local/bin/lib/std/start.zig:550:12: note: called from here
return @call(.always_inline, callMain, .{});
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/toni/.local/bin/lib/std/start.zig:500:36: note: called from here
return initEventLoopAndCallMain();
~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/toni/.local/bin/lib/std/start.zig:464:17: note: called from here
std.os.exit(@call(.always_inline, callMainWithArgs, .{ argc, argv, envp }));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.