Skip to content

A Programming Language just for writing Fizz Buzz program. :)

License

Notifications You must be signed in to change notification settings

yhirose/fizzbuzzlang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FizzBuzzLang

A Programming Language just for writing Fizz Buzz program. :)

for n from 1 to 100
  puts n % 3 == 0 ? (n % 5 == 0 ? 'FizzBuzz' : 'Fizz') : (n % 5 == 0 ? 'Buzz' : n)

Build and Run demo

> make
./fzbz fizzbuzz.fzbz
1
2
Fizz
4
Buzz
...

PEG grammar

# Syntax Rules
EXPRESSION              <- TERNARY
TERNARY                 <- CONDITION ('?' EXPRESSION ':' EXPRESSION)?
CONDITION               <- MULTIPLICATIVE (ConditionOperator MULTIPLICATIVE)?
MULTIPLICATIVE          <- CALL (MultiplicativeOperator CALL)*
CALL                    <- PRIMARY (EXPRESSION)?
PRIMARY                 <- FOR / Identifier / '(' EXPRESSION ')' / String / Number
FOR                     <- 'for' Identifier 'from' Number 'to' Number EXPRESSION

# Token Rules
ConditionOperator       <- '=='
MultiplicativeOperator  <- '%'
Identifier              <- !Keyword < [a-zA-Z][a-zA-Z0-9_]* >
String                  <- "'" < ([^'] .)* > "'"
Number                  <- < [0-9]+ >

Keyword                 <- 'for' / 'from' / 'to'
%whitespace             <- [ \t\r\n]*

License

MIT

About

A Programming Language just for writing Fizz Buzz program. :)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published