top | item 40295275

(no title)

himujjal | 1 year ago

This. Writing a parser in Zig is so simple. Just allocate once, and then start writing your parser.

One allocator for parser, one for scanner. One for type allocation. Keep them all for semantic analysis. Write the output renderer (binary/language). Deallocate.

In this whole process, it makes it so easy to not think about memory anymore. Just enjoy writing your program.

discuss

order

JonChesterfield|1 year ago

The scanner can probably be zero allocation though - zig should be able to express an iterator over the input byte array that returns a token on dereference without needing more state than the position in the array

lylejantzi3rd|1 year ago

Is there a detailed blog post or a book or something you can share that shows how easy it is to write a parser in zig?