Fzzbzz

From Esolang
Jump to navigation Jump to search

Fzzbzz is a dsl for describing programs that behave fizzbuzzishly.

Grammar

`fzzbzz` is the symbol for well formed Fzzbzz programs. Please excuse the ellipses.

open = '<'
close = '>'
equals = '='
slash = '/'
comma = ','
digit = '0' | '1' | ... | '9'
lowchar = 'a' | 'b' | ... | 'z'
capchar = 'A' | 'B' | ... | 'Z'
alpha = lowchar | capchar
alphanumeric = alpha | digit
int = digit | int, digit
string = alpha | string, alphanumeric

lower = open, int
upper = int, close
rules = int, equals, string | rules, comma, int, equals, string
fzzbzz = lower, slash, rules, slash, upper

As you've no doubt surmised, the integers leading and ending the fzzbzz form define the lower and upper bounds of the resultant program's main loop respectively. The "rule" forms (integer+equals+string triples) define what to print and when. Once the loop counter modulo the integer part of the triple yields zero, the program will print the string part of the triple.

Examples

Canonical Fizzbuzz

<1/3=fizz,5=buzz/100>

Boy Wonder Fizzbuzz

<99/3=holy,5=cow,7=batman/111>

One more for the road

<47/4=capital,7=steez/57>

Implementation

There exists a reference implementation of a fzzbzz compiler targeting C on github.

See also