Skip to content

Parse a simple expression with binary oprators and calculate result

License

Notifications You must be signed in to change notification settings

snubydev/zig-parser-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(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)

About

Parse a simple expression with binary oprators and calculate result

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages