Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 716 Bytes

README.md

File metadata and controls

26 lines (18 loc) · 716 Bytes

(avatar) Zig parser example

Parse a simple arithmetic expression with binary oprators and calculate result.

Example

given a string with math expression "500 * ( 13 + 8 ) * 10"
parse and calculate the result?

Usage

Install zig 0.11+ programming language from ziglang.org

$ zig build-exe main.zig

$ ./main "500 * ( 13 + 8 ) * 10"

Tests

$ zig test test_main.zig

$ zig test test_parser.zig

Links

Inspired by Jonathan Blow "Discussion with Casey Muratori about how easy precedence is..." (youtube)